1 /*****************************************************************************\ 2 ldlencap.h : definitions for the lidil encapsulation 3 4 Copyright (c) 2001 - 2015, HP Co. 5 All rights reserved. 6 7 Redistribution and use in source and binary forms, with or without 8 modification, are permitted provided that the following conditions 9 are met: 10 1. Redistributions of source code must retain the above copyright 11 notice, this list of conditions and the following disclaimer. 12 2. Redistributions in binary form must reproduce the above copyright 13 notice, this list of conditions and the following disclaimer in the 14 documentation and/or other materials provided with the distribution. 15 3. Neither the name of HP nor the names of its 16 contributors may be used to endorse or promote products derived 17 from this software without specific prior written permission. 18 19 THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED 20 WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN 22 NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 24 TO, PATENT INFRINGEMENT; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 25 OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 26 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 \***************************************************************************/ 30 #ifndef _LDLENCAP 31 #define _LDLECNAP 32 33 // Wait times 34 #define PACKET_WAIT 5 35 #define IO_WAIT 5 36 #define CREDIT_WAIT 5 37 #define ERROR_WAIT 20 38 39 // Bytes to retrieve data from packet are 0-based, i.e. FRAME_BYTE is 1st byte of packet, 40 // but 0th element of buffer. Command packets and credit packets may have different elements 41 // with the same value 42 #define FRAME_BYTE 0 43 #define COMMAND_LENGTH_BYTE 1 44 #define PACKET_TYPE_BYTE 4 45 #define COMMAND_NUMBER_BYTE 5 46 #define REFERENCE_NUMBER_BYTE 6 47 #define DATA_LENGTH_BYTE 8 48 #define NUMBER_OF_COMMANDS_BYTE 10 49 #define COMMAND_OPT_BYTE 10 50 #define CREDIT_BYTE 11 51 52 // Packet types 53 #define RESPONSE_COMMAND_EXECUTED 16 54 #define RESPONSE_AUTO 24 55 #define ABSOLUTE_CREDIT 32 56 #define INCREMENTAL_CREDIT 33 57 58 // Command numbers 59 #define COMMAND_CANCEL 0 60 #define COMMAND_QUERY 5 61 #define COMMAND_CONTINUE 12 62 #define COMMAND_PREPARE_TO_CANCEL 12 63 64 // Auto response numbers 1-5 are reserved, but we'll probably only ever use number 1 65 #define AUTO_RESPONSE_STATUS 1 66 67 // MAX_PACKET_SIZE has to be a multiple of 64, which is the packet size of the printer 68 // See comment at LDLEncap::GetPackets 69 #define MAX_PACKET_READ_SIZE 256 70 71 // Special packet types 72 const BYTE byEnablePacing[] = { 0x24, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 73 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x24 }; 74 const BYTE byResetLIDIL[] = { 0x24, 0x00, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 75 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x24 }; 76 77 // The Sync packet has 245 bytes of 0's as command options and 2048 bytes of 0's as data following 78 // the trailing frame byte. Rather than explicitly initialize the entire Sync packet with 0's here, 79 // we'll just initialize up to the COMMAND_OPT_BYTE and fill in the rest of the command in the 80 // LDLEncap constructor using memcpy 81 const BYTE bySync[] = { 0x24, 0x01, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x08, 82 0x00 }; 83 const BYTE bySyncComplete[] = { 0x24, 0x00, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 84 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x24 }; 85 // Commands 86 //const BYTE byDisableResponses[] = { 0x24, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 87 // 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x24 }; 88 //const BYTE byEnableResponses[] = { 0x24, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 89 // 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x24 }; 90 //const BYTE byStatusQuery[] = { 0x24, 0x00, 0x10, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 91 // 0x00, 0x01, 0x00, 0x00, 0x00, 0xFF, 0x24 }; 92 const BYTE byEOCStatusQuery[] = { 0x24, 0x00, 0x10, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 93 0x00, 0x01, 0x02, 0x00, 0x01, 0xFF, 0x24 }; 94 const BYTE byContinue[] = { 0x24, 0x00, 0x10, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 95 0x00, 0x02, 0xFF, 0xFF, 0xFF, 0xFF, 0x24 }; 96 const BYTE byPrepareToCancel[] = { 0x24, 0x00, 0x10, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 97 0x00, 0x0A, 0xFF, 0xFF, 0xFF, 0xFF, 0x24 }; 98 99 const int CANCELSIZE = 16; 100 const int SYNCSIZE = 2304; 101 const int SYNC_CMD_OPT_SIZE = 245; 102 //const int QUERYSIZE = sizeof(byEnableResponses) + sizeof(byStatusQuery) + sizeof(byDisableResponses); 103 104 typedef unsigned short UInt16; 105 typedef unsigned long UInt32; 106 typedef unsigned char UChar; 107 typedef unsigned int Int16; 108 typedef long Int32; 109 typedef enum 110 { 111 eLDLStartJob = 0, 112 eLDLEndJob = 0, 113 eLDLLoadPage = 1, 114 eLDLEjectPage =2, 115 eLDLPrintSweep=3, 116 eLDLLoadSweepData=4, 117 eLDLQueryPrinter = 5, 118 eLDLComments=7, 119 eLDLHandlePen = 8, 120 eLDLControl = 12, 121 eLDLDataStreamVersion=12 122 }LDLCMD; 123 124 typedef enum 125 { 126 eLDLUnknownColor=-1, 127 eLDLBlack, 128 eLDLCyan, 129 eLDLMagenta, 130 eLDLYellow, 131 eLDLLoCyan, 132 eLDLLoMagenta, 133 eLDLLoBlack, 134 eLDLMaxColor 135 } COLORENUM; 136 137 138 #define LDLPACKET_MINSIZE 16 // define the minimum packet size defined by the protocol 139 #define FRAME_SYN '$' // defined the synchronization frame 140 #define OPTIMIZED_DELAYLIMIT 0 // defined how many PrintSweep will be sent before the 141 // first LoadSweepData command 142 143 #define LDL_MAX_IMAGE_SIZE 2048 144 145 146 #define SIZEOF_LDLHDR 10 147 #define SIZEOF_LDLTERM 1 148 #define SIZEOF_LDL_JOB_CMDOPT 5 149 150 // define possible operation field 151 #define OPERATION_STJOB 0 152 #define OPERATION_ENDJOB 1 153 #define OPERATION_CANCJOB 2 154 155 #define SIZEOF_LDL_LDPAGE_CMDOPT 17 156 157 // defn for possible option field settings 158 #define MEDIATYPE_PLAIN 0 // possible types for mediatype field 159 #define MEDIATYPE_PHOTO 3 160 161 #define MEDIASRC_MAINTRAY 0 // possible setting for mediasrc 162 163 #define MEDIADEST_MAINBIN 0 // possible setting for mediadest 164 165 #define QUALITYLEVEL_DRAFT -1 // possible setting for quality 166 #define QUALITYLEVEL_NORMAL 0 167 #define QUALITYLEVEL_BEST 1 168 #define QUALITYLEVEL_WONDER 2 169 170 #define SPECLOAD_NONE 0 // possible setting for specload 171 #define SPECLOAD_ENVELOPE 1 172 173 #define MEDIALD_SPEED 0x00000001 // bitfield defn for opt_fields 174 #define NEED_TO_SERVICE_PERIOD 0x00000002 175 #define MINTIME_BTW_SWEEP 0x00000004 176 177 #define DEVUNITS_XBOW 2400 // Crossbow device units is 2400 dots per inch 178 179 #define SIZEOF_LDL_LDPAGE_OPTFLDS 4 180 181 #define SIZEOF_LDL_COLROPT_ACTIVECOLR 2 182 183 #define NO_ACTIVE_COLORS 0x0000 184 185 #define SIZEOF_LDL_EJPAGE_CMDOPT 4 186 187 #define MEDIA_EJSPEED 0x00000001 // bitfield defn for opt_fields 188 189 #define SIZEOF_LDL_EJPAGE_OPTFLDS 1 190 191 #define SIZEOF_LDL_PRTSWP_CMDOPT 18 192 193 #define SWINGFMT_UNCOMPRSS 0 // define possible swing format 194 195 #define PRNDRN_LEFTTORIGHT 0 // define the possible print direction 196 #define PRNDRN_RIGHTTOLEFT 1 197 198 #define IPS_CARRSPEED 0x00000001 // bitfield defn for printsweep optional field 199 #define IPS_INIPRNSPEED 0x00000002 200 #define IPS_MEDIASPEED 0x00000004 201 #define PAPER_ACCURACY 0x00000008 202 #define ACCURATEPOSN_NEEDED 0x00000010 203 #define DRYTIME 0x00000020 // bit 6-31 undefined 204 205 #define SIZEOF_LDL_PRTSWP_OPTFLDS 3 206 207 #define SIZEOF_LDL_PRTSWP_COLROPT 29 208 209 #define SIZEOF_LDL_LDSWPDATA_CMDOPT 2 210 211 #define NO_ECHO 0 212 #define ECHO_DATA 1 213 214 #define OPERATION_CONTINUE 2 215 #define DATASTREAMVERSION 3 216 217 #define OPERATION_SPIT_PEN 2 218 219 // possible values for ldlversion 220 #define CURR_LDLVERSION 0x00000302 // lidil version of 0.3.2 221 222 #endif 223