summaryrefslogtreecommitdiffstats
path: root/PROTOCOL
blob: fb08edbf2bd5a4ea8eaffa3376b7b7b32da5dc06 (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
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
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
 * 0x110   START_TCP
 * 0x111   END_JOB       ?? Sent at end of job
 * 0x120   GET_STATUS
 * 0x121   DATA
 * 0x130   GET_ID        (IEEE1284 Printer ID)
 * 0x151   FLUSH

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

FLUSH_REQ (0x0151)
-------------------
43 50 4e 50   CPNP 
01 51         FLUSH
00 00 00 07   SEQUENCE
00 00 00 00   (no args)
00 04         4-byte payload

00 00 00 00

FLUSH_RESP (0x8151)
--------------------
43 50 4e 50   CPNP
81 51         FLUSH
00 00 00 07   SEQUENCE
00 00 00 00   (no args)
00 04         4-byte payload

00 00 10 00

START_TCP_REQ (0x0110)
-------------------
43 50 4e 50   CPNP 
01 10         START_TCP
00 00 00 07   SEQUENCE
00 00 00 00   (no args)
01 88         392-byte payload

00 00 00 00 00 00 00 00

00 4b 00 41 00 4c 00 41
00 4d 00 41 00 54 00 41 00 00 00 00 00 00 00 00   PC name (UTF-16)
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00

00 70 00 69 00 7a 00 7a
00 61 00 00 00 00 00 00 00 00 00 00 00 00 00 00   username (UTF-16)
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00

00 54 00 65 00 73 00 74
00 20 00 50 00 61 00 67 00 65 00 00 00 00 00 00   Job name (UTF-16)
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00

START_TCP_RESP (0x8151)
--------------------
43 50 4e 50   CPNP
81 10         START_TCP
00 00 00 07   SEQUENCE
00 00 00 00   (no args)
00 08         8-byte payload

30 30 30 30 PP PP 00 00     PP == TCP PORT.

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? 0x01 or 0x02?)
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
  PP 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)
  PP:  Next Plane => 00 == Y, 01 == M, 02 == C.
  
[ 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 ZZ 00 00   (args/jobid)
00 40         (payload len, varies)

Four variations.  First one is flags:

00 00 00 00 XX XX XX XX TT TT TT TT YY YY YY YY   XX == msg len (0x40)
                                                  TT == 0x01 ???
						  YY == 00 00 40 00 (for YMC???)
00 00 00 RR 00 00 00 00 00 00 00 00 00 00 00 00   RR: 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 variation is for planar YMC data, consisting of 28B plane header, filled to 4KiB of size:

00 00 01 00 XX XX XX XX 01 00 00 00 YY YY YY YY   XX == total data len, YY == plane len (delta is header len, ie 28 bytes)

00 00 00 QQ 00 00 00 00 00 00 00 00 00 00 00 00
HH HH 00 00 VV VV 00 00 ?? 00 00 00               HH == rows (1232)
                                                  VV == cols (1808)
						  ?? == plane (00/01/02 == Y/M/C)
[... initial payload ...]

Third one is pure payload, used by jpeg printing.

Fourth 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 LL LL

 LL == bytes received 

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)