1 /*****************************************************************************\
2 ldlencap.h : definitions for the lidil encapsulation
4 Copyright (c) 2001 - 2002, Hewlett-Packard Co.
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions
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 Hewlett-Packard 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.
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 \***************************************************************************/
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
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
53 #define RESPONSE_COMMAND_EXECUTED 16
54 #define RESPONSE_AUTO 24
55 #define ABSOLUTE_CREDIT 32
56 #define INCREMENTAL_CREDIT 33
59 #define COMMAND_CANCEL 0
60 #define COMMAND_QUERY 5
61 #define COMMAND_CONTINUE 12
62 #define COMMAND_PREPARE_TO_CANCEL 12
64 // Auto response numbers 1-5 are reserved, but we'll probably only ever use number 1
65 #define AUTO_RESPONSE_STATUS 1
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
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 };
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,
83 const BYTE bySyncComplete[] = { 0x24, 0x00, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
84 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x24 };
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 };
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);
104 typedef unsigned short UInt16;
105 typedef unsigned long UInt32;
106 typedef unsigned char UChar;
107 typedef unsigned int Int16;
117 eLDLQueryPrinter = 5,
121 eLDLDataStreamVersion=12
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
143 #define LDL_MAX_IMAGE_SIZE 2048
146 #define SIZEOF_LDLHDR 10
147 #define SIZEOF_LDLTERM 1
148 #define SIZEOF_LDL_JOB_CMDOPT 5
150 // define possible operation field
151 #define OPERATION_STJOB 0
152 #define OPERATION_ENDJOB 1
153 #define OPERATION_CANCJOB 2
155 #define SIZEOF_LDL_LDPAGE_CMDOPT 17
157 // defn for possible option field settings
158 #define MEDIATYPE_PLAIN 0 // possible types for mediatype field
159 #define MEDIATYPE_PHOTO 3
161 #define MEDIASRC_MAINTRAY 0 // possible setting for mediasrc
163 #define MEDIADEST_MAINBIN 0 // possible setting for mediadest
165 #define QUALITYLEVEL_DRAFT -1 // possible setting for quality
166 #define QUALITYLEVEL_NORMAL 0
167 #define QUALITYLEVEL_BEST 1
168 #define QUALITYLEVEL_WONDER 2
170 #define SPECLOAD_NONE 0 // possible setting for specload
171 #define SPECLOAD_ENVELOPE 1
173 #define MEDIALD_SPEED 0x00000001 // bitfield defn for opt_fields
174 #define NEED_TO_SERVICE_PERIOD 0x00000002
175 #define MINTIME_BTW_SWEEP 0x00000004
177 #define DEVUNITS_XBOW 2400 // Crossbow device units is 2400 dots per inch
179 #define SIZEOF_LDL_LDPAGE_OPTFLDS 4
181 #define SIZEOF_LDL_COLROPT_ACTIVECOLR 2
183 #define NO_ACTIVE_COLORS 0x0000
185 #define SIZEOF_LDL_EJPAGE_CMDOPT 4
187 #define MEDIA_EJSPEED 0x00000001 // bitfield defn for opt_fields
189 #define SIZEOF_LDL_EJPAGE_OPTFLDS 1
191 #define SIZEOF_LDL_PRTSWP_CMDOPT 18
193 #define SWINGFMT_UNCOMPRSS 0 // define possible swing format
195 #define PRNDRN_LEFTTORIGHT 0 // define the possible print direction
196 #define PRNDRN_RIGHTTOLEFT 1
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
205 #define SIZEOF_LDL_PRTSWP_OPTFLDS 3
207 #define SIZEOF_LDL_PRTSWP_COLROPT 29
209 #define SIZEOF_LDL_LDSWPDATA_CMDOPT 2
214 #define OPERATION_CONTINUE 2
215 #define DATASTREAMVERSION 3
217 #define OPERATION_SPIT_PEN 2
219 // possible values for ldlversion
220 #define CURR_LDLVERSION 0x00000302 // lidil version of 0.3.2