1 /*___________________________________ epson-cbt.h ___________________________________*/ 2 3 /* 1 2 3 4 5 6 7 8 */ 4 /*34567890123456789012345678901234567890123456789012345678901234567890123456789012345678*/ 5 /*******************************************|********************************************/ 6 /* 7 * Copyright (c) 2009 Seiko Epson Corporation All rights reserved. 8 * 9 * Copyright protection claimed includes all forms and matters of 10 * copyrightable material and information now allowed by statutory or judicial 11 * law or hereinafter granted, including without limitation, material generated 12 * from the software programs which are displayed on the screen such as icons, 13 * screen display looks, etc. 14 * 15 */ 16 /*******************************************|********************************************/ 17 /* */ 18 /* Epson CBT Module Definitions */ 19 /* */ 20 /*******************************************|********************************************/ 21 #ifndef _EPSON_CBT_H_ 22 #define _EPSON_CBT_H_ 23 #ifdef __cplusplus 24 extern "C" { 25 #endif /* def __cplusplus */ 26 27 /*------------------------------------ Includes -------------------------------------*/ 28 /*******************************************|********************************************/ 29 #include "epson-typedefs.h" 30 #include "epson-escpr-def.h" 31 32 /*------------------------------------- Data Types -------------------------------------*/ 33 /*******************************************|********************************************/ 34 35 /*---------------------------------- Generic Macros ---------------------------------*/ 36 /*******************************************|********************************************/ 37 38 /*----------------------------------- Definitions ------------------------------------*/ 39 /*******************************************|********************************************/ 40 41 /*** Socket ID */ 42 /*** -------------------------------------------------------------------------------*/ 43 #define CBT_CBTCH_DATA 0x40 /* CBT Data Channel */ 44 #define CBT_CBTCH_CTRL 0x02 /* CBT Control Channel */ 45 46 /*** CBT Module Global Variables */ 47 /*** -------------------------------------------------------------------------------*/ 48 #define CBT_MAX_CH 3 /* Channel Count */ 49 #define CBT_MAX_RTMP 512 /* receive data work buffer size */ 50 51 #define CBT_SID_MAIN 0x00 /* Main Channel */ 52 #define CBT_SID_CTRL 0x02 /* Control Channel */ 53 #define CBT_SID_DATA 0x40 /* data channel (40H) */ 54 55 #define CBT_TXPSIZE 4096 /* JOB data packet size (4090+6) */ 56 #define CBT_RXPSIZE 512 /* ReverseData packet size */ 57 58 #define CBT_CREDIT_LPT 0x0080 /* Printer credit */ 59 #define CBT_CREDIT_DEF 0x0008 /* Host Credit */ 60 61 #define CBT_CMDREPLY_BUFFSZ 64 /* Command Reply Data Buffer size */ 62 63 #define CBT_READ_DMY 0 /* Read Option: Dummy Read */ 64 #define CBT_READ_NORMAL 1 /* Read Option: Normal Read */ 65 66 /*** CBT Mode */ 67 /*** -------------------------------------------------------------------------------*/ 68 #define CBT_MODE_CBTOFF 0 /* CBT Mode Off */ 69 #define CBT_MODE_CBTON 1 /* CBT Mode On */ 70 #define CBT_MODE_REQOFF 2 /* Request Off */ 71 #define CBT_MODE_CBTERR 3 /* CBT Error */ 72 73 /*** Command Packet Length */ 74 /*** -------------------------------------------------------------------------------*/ 75 #define CBT_CMD_SIZE_INIT 0x08 /* Init Command */ 76 #define CBT_CMD_SIZE_OPENCHANNEL 0x11 /* OpenChannel Command */ 77 #define CBT_CMD_SIZE_CLOSECHANNEL 0x0A /* CloseChannel Command */ 78 #define CBT_CMD_SIZE_CREDIT 0x0B /* Credit Command */ 79 #define CBT_CMD_SIZE_CREDITREQUEST 0x0D /* CreditRequest Command */ 80 #define CBT_CMD_SIZE_EXIT 0x07 /* Exit Command */ 81 #define CBT_CMD_SIZE_GETSOCKETID 0x07 /* GetSoketID Command (7-47) */ 82 #define CBT_CMD_SIZE_GETSERVICENAME 0x08 /* GetServiceName Command */ 83 #define CBT_CMD_SIZE_ERROR 0x0A /* Error Command */ 84 #define CBT_CMD_SIZE_EPSONPACKING 0x1B /* EpsonPackingCommand Command */ 85 86 #define CBT_RPY_SIZE_INIT 0x09 /* InitReply */ 87 #define CBT_RPY_SIZE_OPENCHANNEL 0x10 /* OpenChannelReply */ 88 #define CBT_RPY_SIZE_CLOSECHANNEL 0x0A /* CloseChannelReply */ 89 #define CBT_RPY_SIZE_CREDIT 0x0A /* CreditReply */ 90 #define CBT_RPY_SIZE_CREDITREQUEST 0x0C /* CreditRequestReply */ 91 #define CBT_RPY_SIZE_EXIT 0x08 /* ExitReply */ 92 #define CBT_RPY_SIZE_GETSOCKETID 0x09 /* GetSoketIDReply */ 93 #define CBT_RPY_SIZE_GETSERVICENAME 0x09 /* GetServiceNameReply */ 94 #define CBT_RPY_SIZE_EPSONPACKING 0x08 /* EpsonPackingCommandReply */ 95 96 /*** CBT Command */ 97 /*** -------------------------------------------------------------------------------*/ 98 #define CBT_CMD_INIT 0x00 99 #define CBT_CMD_OPENCHANNEL 0x01 100 #define CBT_CMD_CLOSECHANNEL 0x02 101 #define CBT_CMD_CREDIT 0x03 102 #define CBT_CMD_CREDITREQUEST 0x04 103 #define CBT_CMD_DEBIT 0x05 104 #define CBT_CMD_DEBITREQUEST 0x06 105 #define CBT_CMD_CONFIGSOCKET 0x07 106 #define CBT_CMD_EXIT 0x08 107 #define CBT_CMD_GETSOCKETID 0x09 108 #define CBT_CMD_GETSERVICENAME 0x0A 109 #define CBT_CMD_EPSONPACKING 0x45 110 #define CBT_CMD_CBT_ERROR 0x7F 111 #define CBT_CMD_CBT_NONE 0xFF 112 113 /*** Reply Command */ 114 /*** -------------------------------------------------------------------------------*/ 115 #define CBT_RPY_INIT 0x80 116 #define CBT_RPY_OPENCHANNEL 0x81 117 #define CBT_RPY_CLOSECHANNEL 0x82 118 #define CBT_RPY_CREDIT 0x83 119 #define CBT_RPY_CREDITREQUEST 0x84 120 #define CBT_RPY_DEBIT 0x85 121 #define CBT_RPY_DEBITREQUEST 0x86 122 #define CBT_RPY_CONFIGSOCKET 0x87 123 #define CBT_RPY_EXIT 0x88 124 #define CBT_RPY_GETSOCKETID 0x89 125 #define CBT_RPY_GETSERVICENAME 0x8A 126 #define CBT_RPY_EPSONPACKING 0xC5 127 128 /*----------------------------------- Error Code -------------------------------------*/ 129 /*******************************************|********************************************/ 130 #define EPCBT_ERR_INITDENIED -1 /* Printer Result=0x01 */ 131 #define EPCBT_ERR_VERSION -2 /* Printer Result=0x02 */ 132 #define EPCBT_ERR_CLOSEDENIED -3 /* Printer Result=0x03 */ 133 #define EPCBT_ERR_RESOURCE -4 /* Printer Result=0x04 */ 134 #define EPCBT_ERR_OPENCHANNEL -5 /* Printer Result=0x05 */ 135 #define EPCBT_ERR_CHOPENDED -6 /* Printer Result=0x06 */ 136 #define EPCBT_ERR_CREDITOVF -7 /* Printer Result=0x07 */ 137 #define EPCBT_ERR_CMDDENIED -8 /* Printer Result=0x08 */ 138 #define EPCBT_ERR_CHNOTSUPPORT -9 /* Printer Result=0x09 */ 139 #define EPCBT_ERR_NOSERVICE -10 /* Printer Result=0x0A */ 140 #define EPCBT_ERR_INITFAILED -11 /* Printer Result=0x0B */ 141 #define EPCBT_ERR_PACKETSIZE -12 /* Printer Result=0x0C */ 142 #define EPCBT_ERR_NULLPACKETSZ -13 /* Printer Result=0x0D */ 143 144 #define EPCBT_ERR_PARAM -20 /* Parameter Error */ 145 #define EPCBT_ERR_MEMORY -21 /* Memory Error */ 146 #define EPCBT_ERR_CBTNOTOPEN -22 /* Port Not Open */ 147 #define EPCBT_ERR_CBT2NDOPEN -23 /* Port end Open error */ 148 #define EPCBT_ERR_CHNOTOPEN -24 /* Channel Not Open or Close */ 149 #define EPCBT_ERR_CH2NDOPEN -25 /* Channel end Open */ 150 #define EPCBT_ERR_RPLYPSIZE -28 /* OpenChannel return Paket Size Fail */ 151 #define EPCBT_ERR_WRITEERROR -31 /* Write Error */ 152 #define EPCBT_ERR_READERROR -32 /* Read Error */ 153 #define EPCBT_ERR_FNCDISABLE -33 /* Not send or receive */ 154 155 #define EPCBT_ERR_FATAL -50 /* FATAL Error */ 156 #define EPCBT_ERR_CBTDISABLE -52 /* EpsonPackingCommand Fail */ 157 #define EPCBT_ERR_NOREPLY -55 /* Reply Time out */ 158 159 #define EPCBT_ERR_MULFORMEDPACKET -80 /* receibe paket data Fail */ 160 #define EPCBT_ERR_UEREPLY -82 /* miss match Reply */ 161 #define EPCBT_ERR_UERESULT -85 /* no define Result value */ 162 163 /*--------------------------- Data Structure Declarations ---------------------------*/ 164 /*******************************************|********************************************/ 165 166 /*** Channel Information */ 167 /*** -------------------------------------------------------------------------------*/ 168 typedef struct _tagCBTS_CHINFO_ { 169 EPS_UINT8 No; /* Channel No */ 170 EPS_INT32 PtSsize; /* Packet Size (PC -> Printer) */ 171 EPS_INT32 StPsize; /* Packet Size (Printer -> PC) */ 172 EPS_INT32 CreditP; /* receive credit from printer */ 173 EPS_INT32 CreditH; /* send credit from host */ 174 EPS_INT32 ReadSize; /* receive packet data size */ 175 EPS_UINT8* ReadBuff; /* receive packet data buffer */ 176 EPS_UINT8* RTmpBuff; /* receive data work buffer */ 177 EPS_INT32 RTmpTop; /* receive data work buffer, start data point */ 178 EPS_INT32 RTmpEnd; /* receive data work buffer, end data point */ 179 EPS_INT32 RTmpCnt; /* receive data work buffer, data size */ 180 } CBTS_CHINFO; 181 182 /*** Printer Status */ 183 /*** -------------------------------------------------------------------------------*/ 184 typedef struct _tagCBTS_PRNINFO_ { 185 EPS_INT16 Mode; /* CBT Mode */ 186 void* pPortInfo; /* Port Info */ 187 EPS_WritePortal pCbtWRtnFnc; /* Write Func */ 188 EPS_ReadPortal pCbtRRtnFnc; /* Read Func */ 189 EPS_UINT8* pWriteBuff; /* Write Work */ 190 EPS_UINT8* pCbtReadRtnBuff; /* Read Work 1 */ 191 EPS_UINT8* pCbtDataReadBuff; /* Read Work 2 */ 192 CBTS_CHINFO Chinfo[CBT_MAX_CH]; /* Channel information */ 193 } CBTS_PRNINFO; 194 195 /*-------------------------- Public Function Declarations ---------------------------*/ 196 /*******************************************|********************************************/ 197 extern EPS_INT32 cbtCommOpen (const EPS_USB_DEVICE*, EPS_FILEDSC* ); 198 extern EPS_INT32 cbtCommClose (EPS_FILEDSC ); 199 extern EPS_INT32 cbtCommChannelOpen (EPS_FILEDSC, EPS_INT32, EPS_BOOL ); 200 extern EPS_INT32 cbtCommChannelClose (EPS_FILEDSC, EPS_INT32 ); 201 extern EPS_INT32 cbtCommReadData (EPS_FILEDSC, EPS_INT32, EPS_UINT8*, EPS_INT32, EPS_INT32*); 202 extern EPS_INT32 cbtCommWriteData (EPS_FILEDSC, EPS_INT32, const EPS_UINT8*, EPS_INT32, EPS_INT32* ); 203 204 205 #ifdef __cplusplus 206 } 207 #endif /* def __cplusplus */ 208 209 #endif /* def _EPSON_CBT_H_ */ 210 211 /*___________________________________ epson-cbt.h ____________________________________*/ 212 213 /*34567890123456789012345678901234567890123456789012345678901234567890123456789012345678*/ 214 /* 1 2 3 4 5 6 7 8 */ 215 /*******************************************|********************************************/ 216 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%|%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ 217 /***** End of File *** End of File *** End of File *** End of File *** End of File ******/ 218 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%|%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ 219