summaryrefslogtreecommitdiffstats
path: root/PROTOCOL
blob: f7f4cc54db1def2aa47cade47325b021aa5ae99b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
Canon CPNP protocol
-------------------

This is another attempt to formalize the CPNP spec.  

Taken from the CP900

All fields are BIG ENDIAN unless otherwise specified.

Packet Header: 16 bytes 

43:50:4e:50               'CPNP'
YX:XX                     Command.  Bit 15 is 0 for request, 1 for resp.
00:00:00:00               Msg Sequence Num -- should increment monotically
                          and responses must have the same seq as request.
00:00:00:00               Options for command, usually null
00:00                     Payload length

Identified commands:

 * 0x000   NULL          ???  No idea what this does
 * 0x101   DISCOVER
 * 0x130   GET_ID        (IEEE1284 Printer ID)
 * 0x120   GET_STATUS
 * 0x151   FLUSH
 * 0x110   START_TCP
 * 0x111   END_JOB       ?? Sent at end of job
 * 0x121   DATA

DISCOVER_REQ (0x0101)
---------------------
43:50:4e:50   CPNP
01:01         DISCOVER
00:00:00:06   SEQUENCE
00:00:00:00   (no args)
00:00         (no payload)

DISCOVER_RESP (0x8101)
----------------------
43:50:4e:50   CPNP
81:01         DISCOVER
00:00:00:06   SEQUENCE
00:00:00:00   (no args)
00:10         16-byte payload

00:01:08:00   (???)
06            MAC ADDR length
04            IP ADDR length
18:0c:ac:a4:b8:17  Printer MAC Address
c0:a8:01:b5        IP address (192.168.1.181)

GET_ID_REQ (0x0130)
-------------------
43 50 4e 50   CPNP 
01 30         GET_ID
00 00 00 07   SEQUENCE
00 00 00 00   (no args)
00 04         4-byte payload

00 00 00 00

GET_ID_RESP (0x8130)
--------------------
43 50 4e 50   CPNP
81 30         GET_ID
00 00 00 07   SEQUENCE
00 00 00 00   (no args)
00 47         71-byte payload

00 45         IEEE1284 string length
[rest]        IEEE1284 data, semicolon separated tokens

NULL_REQ (0x0000)
-----------------
43 50 4e 50   CPNP
00 00         NULL
00 00 00 08   SEQUENCE
00 00 00 00   (no args)
00 00         (no payload)

NULL_RESP (0x8000)
------------------
43 50 4e 50   CPNP
00 00         NULL
00 00 00 08   SEQUENCE
00 00 00 00   (no args)
00 08         (8-byte payload)

86 09 01 00   (???) 
00 00 00 00

GET_STATUS_REQ (0x0120)
-----------------------
43 50 4e 50   CPNP 
01 20         GET_STATUS
00 00 00 00   SEQUENCE
00 XX 00 00   (??? Job ID for TCP?)
00 00         (no payload)

GET_STATUS_RESP (0x8120) over UDP
----------------------------------
43 50 4e 50   CPNP 
81 20         GET_STATUS
00 00 00 00   SEQUENCE
00 00 00 00   (always null)
02 00         (512-byte payload)

01 01
YY XX         YY paper, XX ribbon. 01 = missing, 04 = ready. 
43 61 6e 6f 6e 20 43 50 39 30 30 00 == 'Canon CP900'  (ie printer identifier)

00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 01 01 02 01 01 01
00 80 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ff ff ff ff 40 00 40 00 40 1f 40 1f d0 04 10 07
03 00 00 00 01 00 00 00 11 0f 2f 32 00 00 00 00
01 00 00 00 0e 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 07 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

GET_STATUS_RESP (0x8120) over TCP
----------------------------------
43 50 4e 50   CPNP 
81 20         GET_STATUS
00 00 00 00   SEQUENCE
00 XX 00 00   (seen 0x01 or 0x02 -- maybe job id?)
00 40         (64-byte payload)

  [ Attempt to decode the details ]
  
  00 00 01 10 04 04 00 00 00 00 00 00 00 00 00 00
  00 00 SS 00 01 00 00 00 XX XX XX XX YY YY YY YY
  00 90 01 00 00 00 00 00 00 00 00 00 00 00 00 00
  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

  SS: State. 00 wait/01 flags/02 data req/03 done/04 error
  XX:  Data req offset (Little endian)
  YY:  Data req length (Little endian)
  
[ Examples of output I've seen ]

00 00 01 10 04 04 00 00 00 00 00 00 00 00 00 00 (??? variation 1)
00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00
00 90 01 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

00 00 01 10 04 04 00 00 00 00 00 00 00 00 00 00 (??? variation 2)
00 00 01 00 01 00 00 00 00 00 00 00 98 8f 01 00
00 90 01 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

00 00 00 00 40 00 00 00 01 00 00 00 00 00 04 00 (??? variation 3)
00 00 00 02 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

00 00 01 10 04 04 00 00 01 ff 00 00 00 00 00 00 (??? variation 4)
00 00 01 00 01 00 00 00 00 00 00 00 98 8f 01 00
00 90 01 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

[ data payload starts ]

00 00 01 10 04 04 00 00 05 ff 00 00 00 00 00 00 (??? variation 5)
02 00 02 00 00 00 00 00 00 00 00 00 98 8f 01 00
00 90 01 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

00 00 01 10 04 04 00 00 03 ff 00 00 00 00 00 00 (??? variation 6)
02 00 02 00 00 00 00 00 00 00 00 00 98 8f 01 00
00 90 01 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

00 00 01 10 04 04 00 00 07 ff 00 00 00 00 00 00 (??? variation 6)
02 00 02 00 00 00 00 00 00 00 00 00 98 8f 01 00
00 90 01 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

00 00 01 10 04 04 00 00 09 ff 00 00 00 00 00 00 (??? variation 7)
02 00 02 00 00 00 00 00 00 00 00 00 98 8f 01 00
00 90 01 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

00 00 01 10 04 04 00 00 0a ff 00 00 00 00 00 00 (??? variarion 8)
00 00 03 00 00 00 00 00 00 00 00 00 00 00 00 00
00 90 01 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

00 00 03 00 40 00 00 00 00 00 00 00 00 00 00 00 (??? variation 9.  done?)
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

 [... printing with exhausted ribbon ...]

00 00 01 10 04 04 00 00 01 ff 00 00 00 00 00 00 (??? variation 5a)
00 00 00 00 00 00 00 00 00 00 00 00 98 8f 01 00
00 90 01 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

00 00 01 10 04 04 00 00 00 ff 00 00 01 02 02 00 (??? variation 5b)
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 90 01 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

DATA (0x0121)
-----------------------
43 50 4e 50   CPNP
01 21         DATA
00 00 00 00   SEQUENCE
00 01 00 00   (args)
00 40         (payload len)

Three variations.  First one is flags:

00 00 00 00 XX XX XX XX 00 00 00 00 YY YY YY YY   XX == msg len (64) YY == unknown, always 0x01
00 00 QQ 00 00 00 00 00 00 00 00 00 00 00 00 00   QQ: 03 border, 02 none
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

Second one is pure payload.  payload len is actual bytes. (Max 4096 bytes?)

Third one is the end of job stuff:

00 00 03 00 XX XX XX XX 00 00 00 00 00 00 00 00   XX == msg len (64)
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

DATA_RESP (0x8121)
--------------------
43 50 4e 50   CPNP
81 21         DATA
00 00 00 00   SEQUENCE
00 01 00 00   (args)
00 04         (payload len)

Payload is always 4 bytes:

00 00 XX 00
00 00 LL LL

 LL == bytes received 
 XX == printer state.
       00: Wait        [ busy? ]
       01: Send flags  [ ready for job ]
       02: Send data   [ ready for image data ]
       03: Done        [ print complete, send final packet ]
       04: Error       [ reported error ]

  Not sure how to tell the difference which one is in use?

END_JOB_REQ (0x0111)
--------------------
43 50 4e 50   CPNP
01 11         END_JOB
00 00 00 00   SEQUENCE
00 01 00 00   (args, also seen 0x02)
00 00         (no payload)

END_JOB_RESP (0x8111)
---------------------
43 50 4e 50   CPNP
81 11         END_JOB
00 00 00 00   SEQUENCE
00 01 00 00   (args)
00 00         (no payload)