versadac  1
versadac - Scalable Recorder Firmware
printer_driver.h
1 #ifndef PRINTER_DRIVER_H
2 #define PRINTER_DRIVER_H
3 
4 /**********************************************************************************************
5 *
6 * Copyright (c) 2012 Eurotherm Ltd.
7 *
8 * FileName : printer_driver.h
9 * Author : Andrew Hodgson
10 * Created : April 2012
11 * Description : Printer Driver Header
12 *
13 **********************************************************************************************/
14 #include "stdtypes.h"
15 #include "ENUM_AscPrintCmd.h"
16 #include "ENUM_AscPrintStatus.h"
17 #include "ENUM_ReportFieldStyles.h"
18 #include "ENUM_PrinterDriverConfigTokens.h"
19 #include "ENUM_PrinterDriverConfigLineId.h"
20 
21 /* Typedefs */
22 #define PRINTER_NAME_LEN 31
23 
24 #define PRINTER_POLL_CYCLE 10 /* if idle poll printer every 10 seconds */
25 #define PRINTER_POLL_RETRIES 2 /* on failure try again */
26 
27 #define FB_MESSAGES_MAX_SIZE 80
28 #define FB_MESSAGES_MAX_SEQ 9
29 
30 #define MAX_PRINTER_MSG_SIZE 400
31 
32 #define PRINTER_QUEUE_PATH "/pipe/printerq"
33 
34 // ascii output states to be used by output interface
35 enum PrinterOutputStates
36 {
37  PRINTER_UNINITIALISED,
38  PRINTER_WAITING_FOR_OUTPUT_DATA,
39  PRINTER_WAITING_FOR_TRANSLATION,
40  PRINTER_WAITING_FOR_RECOVERY,
41  PRINTER_SEND_WAKEUP,
42  PRINTER_DETECT,
43  PRINTER_SEND_RESET,
44  PRINTER_SEND_INIT,
45  PRINTER_POLL_STATUS,
46  PRINTER_POLL_PAPER_OUT,
47  PRINTER_POLL_PAPER_LOW,
48  PRINTER_TRANSMIT_OUTPUT_DATA
49 };
50 
51 typedef struct
52 {
53  int m_iStyle; // style to format see ENUM_reportFieldStyle
54  uint16 m_iSize; // size of message in bytes
55  uint8 m_pBuf[MAX_PRINTER_MSG_SIZE]; // buffer containing message
56  bool m_bAvailable; // set true when message loaded in the structure
57  bool m_bReport; // set true is message is a report message
58  double m_dTimestamp; // timestamp of the message used for comparison
60 
61 typedef struct
62 {
63  uint16 m_iCmdID;
64  bool m_bRequired;
65  uint8 *m_pCmdBytes;
66  uint16 m_iCmdLen;
67  bool m_bRspExpected;
68  bool m_bRspHdr;
69  uint16 m_iRspHdrLen;
70  bool m_bRspIsBits;
71  uint8 *m_pRspExpBytes;
72  uint16 m_iRspLen;
73  uint32 m_iRspCheckMask;
74  uint32 m_iRspCheckValue;
75  uint16 m_iTimeout; // millisecs
76  uint16 m_iDelay; // millisecs
78 
79 typedef struct
80 {
81  uint16 m_iStyleID;
82  bool m_bSupported;
83  uint8 *m_pBytes;
84  uint16 m_iLen;
85  uint16 m_iCarriageWidth;
87 
88 typedef struct
89 {
90  char m_printerName[PRINTER_NAME_LEN];
91  PrintCmdData_s m_cmds[ENUM_numberOfAscPrintCmds];
92  PrintStyleData_s m_styles[ENUM_numberOfFieldStyles];
93  uint8 m_txMessageBuf[MAX_PRINTER_MSG_SIZE];
94  uint16 m_txCharCount;
95  uint8 m_rxMessageBuf[MAX_PRINTER_MSG_SIZE];
96  uint16 m_rxCharCount;
97  uint32 m_iStatus;
98  bool m_bPrintMsgPending;
99  bool m_bCutRequired;
100  double m_dLastPrinterComms;
101  bool m_bResetPrinter;
103 
104 void printerTask();
105 uint32 getPrinterStatus();
106 
107 #endif
Definition: printer_driver.h:88
Definition: printer_driver.h:61
Definition: printer_driver.h:51
Definition: printer_driver.h:79