Debian Codegraph @

src/cups/backend_kodak1400.c

raw symbols SCIP
1 /*
2 * Kodak Professional 1400/805 CUPS backend
3 *
4 * (c) 2013-2024 Solomon Peachy <[email protected]>
5 *
6 * The latest version of this program can be found at:
7 *
8 * https://git.shaftnet.org/gitea/slp/selphy_print.git
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the Free
12 * Software Foundation; either version 2 of the License, or (at your option)
13 * any later version.
14 *
15 * This program is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
17 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 * for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, see <https://www.gnu.org/licenses/>.
22 *
23 * SPDX-License-Identifier: GPL-2.0+
24 *
25 */
26
27 #define BACKEND kodak1400_backend
28
29 #include "backend_common.h"
30
31 /* Program states */
32 enum {
33 S_IDLE = 0,
34 S_PRINTER_READY_Y,
35 S_PRINTER_SENT_Y,
36 S_PRINTER_READY_M,
37 S_PRINTER_SENT_M,
38 S_PRINTER_READY_C,
39 S_PRINTER_SENT_C,
40 S_PRINTER_READY_L,
41 S_PRINTER_SENT_L,
42 S_PRINTER_DONE,
43 S_FINISHED,
44 };
45
46 #define CMDBUF_LEN 96
47 #define READBACK_LEN 8
48
49 /* File header */
50 struct kodak1400_hdr {
51 uint8_t hdr[4];
52 uint16_t columns;
53 uint16_t null1;
54 uint16_t rows;
55 uint16_t null2;
56 uint32_t planesize;
57 uint32_t null3;
58 uint8_t matte;
59 uint8_t laminate;
60 uint8_t unk1; /* Always 0x01 */
61 uint8_t lam_strength;
62 uint8_t null4[12];
63 } __attribute__((packed));
64
65 /* Private data structure */
66 struct kodak1400_printjob {
67 struct dyesub_job_common common;
68
69 struct kodak1400_hdr hdr;
70 uint8_t *plane_r;
71 uint8_t *plane_g;
72 uint8_t *plane_b;
73 };
74
75 struct kodak1400_ctx {
76 struct dyesub_connection *conn;
77
78 struct marker marker;
79 };
80
81 static const char *kodak1400_errormsgs(uint8_t code1, uint8_t code2)
82 {
83 if (code1 == 0x00 && code2 == 0x08)
84 return "No paper tray";
85 else if (code1 == 0x02 && code2 == 0x00)
86 return "Paper jam";
87 else if (code1 == 0x02 && code2 == 0x01)
88 return "Cover open during printing";
89 else if (code1 == 0x08 && code2 == 0x00)
90 return "Top cover open";
91 else if (code1 == 0x10) // code2 == 0x00 and 0x01
92 return "Media mismatch";
93 else if (code1 == 0x40 && code2 == 0x00)
94 return "Paper empty";
95 else
96 return "Unknown";
97 }
98
99 static int send_plane(struct kodak1400_ctx *ctx,
100 const struct kodak1400_printjob *job,
101 uint8_t planeno, uint8_t *planedata,
102 uint8_t *cmdbuf)
103 {
104 uint16_t temp16;
105 int ret;
106
107 if (planeno != 1) {
108 memset(cmdbuf, 0, CMDBUF_LEN);
109 cmdbuf[0] = 0x1b;
110 cmdbuf[1] = 0x74;
111 cmdbuf[2] = 0x00;
112 cmdbuf[3] = 0x50;
113
114 if ((ret = send_data(ctx->conn,
115 cmdbuf, CMDBUF_LEN)))
116 return ret;
117 }
118
119 memset(cmdbuf, 0, CMDBUF_LEN);
120 cmdbuf[0] = 0x1b;
121 cmdbuf[1] = 0x5a;
122 cmdbuf[2] = 0x54;
123 cmdbuf[3] = planeno;
124
125 if (planedata) {
126 temp16 = be16_to_cpu(job->hdr.columns);
127 memcpy(cmdbuf+7, &temp16, 2);
128 temp16 = be16_to_cpu(job->hdr.rows);
129 memcpy(cmdbuf+9, &temp16, 2);
130 }
131
132 if ((ret = send_data(ctx->conn,
133 cmdbuf, CMDBUF_LEN)))
134 return ret;
135
136 if (planedata) {
137 int i;
138 for (i = 0 ; i < job->hdr.rows ; i++) {
139 if ((ret = send_data(ctx->conn,
140 planedata + i * job->hdr.columns,
141 job->hdr.columns)))
142 return ret;
143 }
144 }
145
146 memset(cmdbuf, 0, CMDBUF_LEN);
147 cmdbuf[0] = 0x1b;
148 cmdbuf[1] = 0x74;
149 cmdbuf[2] = 0x01;
150 cmdbuf[3] = 0x50;
151
152 if ((ret = send_data(ctx->conn,
153 cmdbuf, CMDBUF_LEN)))
154 return ret;
155
156 return CUPS_BACKEND_OK;
157 }
158
159 #define TONE_CURVE_SIZE 1552
160 static int kodak1400_set_tonecurve(struct kodak1400_ctx *ctx, char *fname)
161 {
162 uint8_t cmdbuf[8];
163 uint8_t respbuf[64];
164 int ret = 0, num = 0;
165
166 INFO("Set Tone Curve from '%s'\n", fname);
167
168 uint16_t *data = malloc(TONE_CURVE_SIZE);
169
170 if (!data) {
171 ERROR("Memory Allocation Failure!\n");
172 return -1;
173 }
174
175 /* Read in file */
176 if ((ret = dyesub_read_file(fname, data, TONE_CURVE_SIZE, NULL))) {
177 ERROR("Failed to read Tone Curve file\n");
178 goto done;
179 }
180
181 /* Byteswap data to printer's format */
182 for (ret = 0; ret < (TONE_CURVE_SIZE-16)/2 ; ret++) {
183 data[ret] = cpu_to_le16(be16_to_cpu(data[ret]));
184 }
185 /* Null-terminate */
186 memset(data + (TONE_CURVE_SIZE-16)/2, 0, 16);
187
188 /* Clear tables */
189 memset(cmdbuf, 0, sizeof(cmdbuf));
190 cmdbuf[0] = 0x1b;
191 cmdbuf[1] = 0xa2;
192 if ((ret = send_data(ctx->conn,
193 cmdbuf, 2))) {
194 ret = -3;
195 goto done;
196 }
197
198 ret = read_data(ctx->conn,
199 respbuf, sizeof(respbuf), &num);
200
201 if (ret < 0)
202 goto done;
203 if (num != 8) {
204 ERROR("Short Read! (%d/%d)\n", num, 8);
205 ret = -4;
206 goto done;
207 }
208 if (respbuf[1] != 0x01) {
209 ERROR("Received unexpected response\n");
210 ret = -5;
211 goto done;
212 }
213
214 /* Set up the update command */
215 memset(cmdbuf, 0, sizeof(cmdbuf));
216 cmdbuf[0] = 0x1b;
217 cmdbuf[1] = 0xa0;
218 cmdbuf[2] = 0x02;
219 cmdbuf[3] = 0x03;
220 cmdbuf[4] = 0x06;
221 cmdbuf[5] = 0x10; /* 06 10 == TONE_CURVE_SIZE */
222 if ((ret = send_data(ctx->conn,
223 cmdbuf, 6)))
224 goto done;
225
226 /* Send the payload over */
227 if ((ret = send_data(ctx->conn,
228 (uint8_t *) data, TONE_CURVE_SIZE)))
229 goto done;
230
231 /* get the response */
232 ret = read_data(ctx->conn,
233 respbuf, sizeof(respbuf), &num);
234
235 if (ret < 0)
236 goto done;
237 if (num != 8) {
238 ERROR("Short Read! (%d/%d)\n", num, 8);
239 ret = -6;
240 goto done;
241 }
242 if (respbuf[1] != 0x00) {
243 ERROR("Received unexpected response!\n");
244 ret = -7;
245 goto done;
246 }
247
248 done:
249 free(data);
250
251 return ret;
252 }
253
254 static void kodak1400_cmdline(void)
255 {
256 DEBUG("\t\t[ -C filename ] # Set tone curve\n");
257 }
258
259 static int kodak1400_cmdline_arg(void *vctx, int argc, char **argv)
260 {
261 struct kodak1400_ctx *ctx = vctx;
262 int i, j = 0;
263
264 if (!ctx)
265 return -1;
266
267 while ((i = getopt(argc, argv, GETOPT_LIST_GLOBAL "C:")) >= 0) {
268 switch(i) {
269 GETOPT_PROCESS_GLOBAL
270 case 'C':
271 j = kodak1400_set_tonecurve(ctx, optarg);
272 break;
273 default:
274 break; /* Ignore completely */
275 }
276
277 if (j) return j;
278 }
279
280 return CUPS_BACKEND_OK;
281 }
282
283 static void *kodak1400_init(void)
284 {
285 struct kodak1400_ctx *ctx = malloc(sizeof(struct kodak1400_ctx));
286 if (!ctx) {
287 ERROR("Memory Allocation Failure!\n");
288 return NULL;
289 }
290 memset(ctx, 0, sizeof(struct kodak1400_ctx));
291
292 return ctx;
293 }
294
295 static int kodak1400_attach(void *vctx, struct dyesub_connection *conn,
296 uint8_t jobid)
297 {
298 struct kodak1400_ctx *ctx = vctx;
299
300 UNUSED(jobid);
301
302 ctx->conn = conn;
303
304 ctx->marker.color = "#00FFFF#FF00FF#FFFF00";
305 ctx->marker.name = "Unknown";
306 ctx->marker.numtype = -1;
307 ctx->marker.levelmax = CUPS_MARKER_UNAVAILABLE;
308 ctx->marker.levelnow = CUPS_MARKER_UNKNOWN;
309
310 return CUPS_BACKEND_OK;
311 }
312
313 static void kodak1400_cleanup_job(const void *vjob)
314 {
315 const struct kodak1400_printjob *job = vjob;
316
317 if (job->plane_r)
318 free(job->plane_r);
319 if (job->plane_g)
320 free(job->plane_g);
321 if (job->plane_b)
322 free(job->plane_b);
323
324 free((void*)job);
325 }
326
327 static int kodak1400_read_parse(void *vctx, const void **vjob, int data_fd, int copies) {
328 struct kodak1400_ctx *ctx = vctx;
329 int i, ret;
330
331 struct kodak1400_printjob *job = NULL;
332
333 if (!ctx)
334 return CUPS_BACKEND_FAILED;
335
336 job = malloc(sizeof(*job));
337 if (!job) {
338 ERROR("Memory allocation failure!\n");
339 return CUPS_BACKEND_RETRY_CURRENT;
340 }
341 memset(job, 0, sizeof(*job));
342 job->common.jobsize = sizeof(*job);
343 job->common.copies = copies;
344
345 /* Read in then validate header */
346 ret = read(data_fd, &job->hdr, sizeof(job->hdr));
347 if (ret < 0 || ret != sizeof(job->hdr)) {
348 if (ret == 0) {
349 kodak1400_cleanup_job(job);
350 return CUPS_BACKEND_CANCEL;
351 }
352 ERROR("Read failed (%d/%d/%d)\n",
353 ret, 0, (int)sizeof(job->hdr));
354 perror("ERROR: Read failed");
355 return CUPS_BACKEND_CANCEL;
356 }
357 if (job->hdr.hdr[0] != 'P' ||
358 job->hdr.hdr[1] != 'G' ||
359 job->hdr.hdr[2] != 'H' ||
360 job->hdr.hdr[3] != 'D') {
361 ERROR("Unrecognized data format!\n");
362 return CUPS_BACKEND_CANCEL;
363 }
364 job->hdr.planesize = le32_to_cpu(job->hdr.planesize);
365 job->hdr.rows = le16_to_cpu(job->hdr.rows);
366 job->hdr.columns = le16_to_cpu(job->hdr.columns);
367
368 /* Set up plane data */
369 job->plane_r = malloc(job->hdr.planesize);
370 job->plane_g = malloc(job->hdr.planesize);
371 job->plane_b = malloc(job->hdr.planesize);
372 if (!job->plane_r || !job->plane_g || !job->plane_b) {
373 ERROR("Memory allocation failure!\n");
374 return CUPS_BACKEND_RETRY_CURRENT;
375 }
376 for (i = 0 ; i < job->hdr.rows ; i++) {
377 int j;
378 uint8_t *ptr;
379 for (j = 0 ; j < 3 ; j++) {
380 int remain;
381 if (j == 0)
382 ptr = job->plane_r + i * job->hdr.columns;
383 else if (j == 1)
384 ptr = job->plane_g + i * job->hdr.columns;
385 else if (j == 2)
386 ptr = job->plane_b + i * job->hdr.columns;
387 else
388 ptr = NULL;
389
390 remain = job->hdr.columns;
391 do {
392 ret = read(data_fd, ptr, remain);
393 if (ret < 0) {
394 ERROR("Read failed (%d/%d/%u) (%d/%u @ %d)\n",
395 ret, remain, job->hdr.columns,
396 i, job->hdr.rows, j);
397 perror("ERROR: Read failed");
398 return CUPS_BACKEND_CANCEL;
399 }
400 ptr += ret;
401 remain -= ret;
402 } while (remain);
403 }
404 }
405
406 *vjob = job;
407
408 return CUPS_BACKEND_OK;
409 }
410
411 static uint8_t idle_data[READBACK_LEN] = { 0xe4, 0x72, 0x00, 0x00,
412 0x00, 0x00, 0x00, 0x00 };
413
414 static int kodak1400_main_loop(void *vctx, const void *vjob, int wait_for_return)
415 {
416 struct kodak1400_ctx *ctx = vctx;
417
418 uint8_t rdbuf[READBACK_LEN], rdbuf2[READBACK_LEN];
419 uint8_t cmdbuf[CMDBUF_LEN];
420 int last_state = -1, state = S_IDLE;
421 int num, ret;
422 uint16_t temp16;
423 int copies;
424 (void)wait_for_return;
425
426 const struct kodak1400_printjob *job = vjob;
427
428 if (!ctx)
429 return CUPS_BACKEND_FAILED;
430 if (!job)
431 return CUPS_BACKEND_FAILED;
432
433 copies = job->common.copies;
434
435 top:
436 if (state != last_state) {
437 if (dyesub_debug)
438 DEBUG("last_state %d new %d\n", last_state, state);
439 }
440
441 /* Send Status Query */
442 memset(cmdbuf, 0, CMDBUF_LEN);
443 cmdbuf[0] = 0x1b;
444 cmdbuf[1] = 0x72;
445
446 if ((ret = send_data(ctx->conn,
447 cmdbuf, CMDBUF_LEN)))
448 return CUPS_BACKEND_FAILED;
449
450 /* Read in the printer status */
451 ret = read_data(ctx->conn,
452 rdbuf, READBACK_LEN, &num);
453
454 if (ret < 0)
455 return CUPS_BACKEND_FAILED;
456 if (memcmp(rdbuf, rdbuf2, READBACK_LEN)) {
457 memcpy(rdbuf2, rdbuf, READBACK_LEN);
458 } else if (state == last_state) {
459 sleep(1);
460 }
461 last_state = state;
462
463 /* Error handling */
464 if (rdbuf[4] || rdbuf[5]) {
465 ERROR("Error code reported: %s (%02x/%02x), terminating print\n",
466 kodak1400_errormsgs(rdbuf[4], rdbuf[5]),
467 rdbuf[4], rdbuf[5]);
468 return CUPS_BACKEND_STOP; // HOLD/CANCEL/FAILED?
469 }
470
471 fflush(logger);
472
473 switch (state) {
474 case S_IDLE:
475 INFO("Printing started\n");
476
477 /* Send reset/attention */
478 memset(cmdbuf, 0, CMDBUF_LEN);
479 cmdbuf[0] = 0x1b;
480
481 if ((ret = send_data(ctx->conn,
482 cmdbuf, CMDBUF_LEN)))
483 return CUPS_BACKEND_FAILED;
484
485 /* Send page setup */
486 memset(cmdbuf, 0, CMDBUF_LEN);
487 cmdbuf[0] = 0x1b;
488 cmdbuf[1] = 0x5a;
489 cmdbuf[2] = 0x53;
490 temp16 = be16_to_cpu(job->hdr.columns);
491 memcpy(cmdbuf+3, &temp16, 2);
492 temp16 = be16_to_cpu(job->hdr.rows);
493 memcpy(cmdbuf+5, &temp16, 2);
494
495 if ((ret = send_data(ctx->conn,
496 cmdbuf, CMDBUF_LEN)))
497 return CUPS_BACKEND_FAILED;
498
499 /* Send lamination toggle? */
500 memset(cmdbuf, 0, CMDBUF_LEN);
501 cmdbuf[0] = 0x1b;
502 cmdbuf[1] = 0x59;
503 cmdbuf[2] = job->hdr.matte; // ???
504
505 if ((ret = send_data(ctx->conn,
506 cmdbuf, CMDBUF_LEN)))
507 return CUPS_BACKEND_FAILED;
508
509 /* Send matte toggle */
510 memset(cmdbuf, 0, CMDBUF_LEN);
511 cmdbuf[0] = 0x1b;
512 cmdbuf[1] = 0x60;
513 cmdbuf[2] = job->hdr.laminate;
514
515 if (send_data(ctx->conn,
516 cmdbuf, CMDBUF_LEN))
517 return CUPS_BACKEND_FAILED;
518
519 /* Send lamination strength */
520 memset(cmdbuf, 0, CMDBUF_LEN);
521 cmdbuf[0] = 0x1b;
522 cmdbuf[1] = 0x62;
523 cmdbuf[2] = job->hdr.lam_strength;
524
525 if ((ret = send_data(ctx->conn,
526 cmdbuf, CMDBUF_LEN)))
527 return CUPS_BACKEND_FAILED;
528
529 /* Send unknown */
530 memset(cmdbuf, 0, CMDBUF_LEN);
531 cmdbuf[0] = 0x1b;
532 cmdbuf[1] = 0x61;
533 cmdbuf[2] = job->hdr.unk1; // ???
534
535 if ((ret = send_data(ctx->conn,
536 cmdbuf, CMDBUF_LEN)))
537 return CUPS_BACKEND_FAILED;
538
539 state = S_PRINTER_READY_Y;
540 break;
541 case S_PRINTER_READY_Y:
542 INFO("Sending YELLOW plane\n");
543 if ((ret = send_plane(ctx, job, 1, job->plane_b, cmdbuf)))
544 return CUPS_BACKEND_FAILED;
545 state = S_PRINTER_SENT_Y;
546 break;
547 case S_PRINTER_SENT_Y:
548 if (!memcmp(rdbuf, idle_data, READBACK_LEN))
549 state = S_PRINTER_READY_M;
550 break;
551 case S_PRINTER_READY_M:
552 INFO("Sending MAGENTA plane\n");
553 if ((ret = send_plane(ctx, job, 2, job->plane_g, cmdbuf)))
554 return CUPS_BACKEND_FAILED;
555 state = S_PRINTER_SENT_M;
556 break;
557 case S_PRINTER_SENT_M:
558 if (!memcmp(rdbuf, idle_data, READBACK_LEN))
559 state = S_PRINTER_READY_C;
560 break;
561 case S_PRINTER_READY_C:
562 INFO("Sending CYAN plane\n");
563 if ((ret = send_plane(ctx, job, 3, job->plane_r, cmdbuf)))
564 return CUPS_BACKEND_FAILED;
565 state = S_PRINTER_SENT_C;
566 break;
567 case S_PRINTER_SENT_C:
568 if (!memcmp(rdbuf, idle_data, READBACK_LEN)) {
569 if (job->hdr.laminate)
570 state = S_PRINTER_READY_L;
571 else
572 state = S_PRINTER_DONE;
573 }
574 break;
575 case S_PRINTER_READY_L:
576 INFO("Laminating page\n");
577 if ((ret = send_plane(ctx, job, 4, NULL, cmdbuf)))
578 return CUPS_BACKEND_FAILED;
579 state = S_PRINTER_SENT_L;
580 break;
581 case S_PRINTER_SENT_L:
582 if (!memcmp(rdbuf, idle_data, READBACK_LEN))
583 state = S_PRINTER_DONE;
584 break;
585 case S_PRINTER_DONE:
586 INFO("Cleaning up\n");
587 /* Cleanup */
588 memset(cmdbuf, 0, CMDBUF_LEN);
589 cmdbuf[0] = 0x1b;
590 cmdbuf[1] = 0x74;
591 cmdbuf[2] = 0x00;
592 cmdbuf[3] = 0x50;
593
594 if ((ret = send_data(ctx->conn,
595 cmdbuf, CMDBUF_LEN)))
596 return CUPS_BACKEND_FAILED;
597
598 state = S_FINISHED;
599 break;
600 default:
601 break;
602 };
603
604 if (state != S_FINISHED)
605 goto top;
606
607 /* Clean up */
608 if (terminate)
609 copies = 1;
610
611 INFO("Print complete (%d copies remaining)\n", copies - 1);
612
613 if (copies && --copies) {
614 state = S_IDLE;
615 goto top;
616 }
617
618 return CUPS_BACKEND_OK;
619 }
620
621 static int kodak1400_query_markers(void *vctx, struct marker **markers, int *count)
622 {
623 struct kodak1400_ctx *ctx = vctx;
624
625 *markers = &ctx->marker;
626 *count = 1;
627
628 return CUPS_BACKEND_OK;
629 }
630
631 static const char *kodak1400_prefixes[] = {
632 "kodak1400", // Family driver, do NOT nuke!
633 // backwards compatibility
634 "kodak805",
635 NULL,
636 };
637
638 static const struct device_id kodak1400_devices[] = {
639 { 0x040a, 0x4022, P_KODAK_1400_805, "Kodak", "kodak-1400"},
640 { 0x040a, 0x4034, P_KODAK_1400_805, "Kodak", "kodak-805"},
641 { 0x06d3, 0x038b, P_KODAK_1400_805, NULL, "mitsubishi-3020d"},
642 { 0x06d3, 0x038b, P_KODAK_1400_805, NULL, "mitsubishi-3020du"}, /* Duplicate */
643 { 0x06d3, 0x038b, P_KODAK_1400_805, NULL, "mitsubishi-3020de"}, /* Duplicate */
644 { 0x06d3, 0x03aa, P_KODAK_1400_805, NULL, "mitsubishi-3020da" },
645 { 0x06d3, 0x03aa, P_KODAK_1400_805, NULL, "mitsubishi-3020dae" }, /* Duplicate */
646 { 0, 0, 0, NULL, NULL}
647 };
648
649 const struct dyesub_backend kodak1400_backend = {
650 .name = "Kodak 1400/805",
651 .version = "0.44",
652 .uri_prefixes = kodak1400_prefixes,
653 .devices = kodak1400_devices,
654 .cmdline_usage = kodak1400_cmdline,
655 .cmdline_arg = kodak1400_cmdline_arg,
656 .init = kodak1400_init,
657 .attach = kodak1400_attach,
658 .cleanup_job = kodak1400_cleanup_job,
659 .read_parse = kodak1400_read_parse,
660 .main_loop = kodak1400_main_loop,
661 .query_markers = kodak1400_query_markers,
662 };
663
664 /* Kodak 1400/805 data format
665
666 Spool file consists of 36-byte header followed by row-interleaved BGR data.
667 Native printer resolution is 2560 pixels per row, and 3010 or 3612 rows.
668
669 Header:
670
671 50 47 48 44 "PGHD"
672 XX XX Number of columns, Little endian. Fixed at 2560.
673 00 00 NULL
674 XX XX Number of rows, Little Endian
675 00 00 NULL
676 XX XX XX XX Number of bytes per plane, Little Endian
677 00 00 00 00 NULL
678 XX 00 Glossy, 01 Matte (Note: Kodak805 only supports Glossy)
679 XX 01 to laminate, 00 to not.
680 01 Unknown, always set to 01
681 XX Lamination Strength:
682
683 3c Glossy
684 28 Matte +5
685 2e Matte +4
686 34 Matte +3
687 3a Matte +2
688 40 Matte +1
689 46 Matte
690 52 Matte -1
691 5e Matte -2
692 6a Matte -3
693 76 Matte -4
694 82 Matte -5
695
696 00 00 00 00 00 00 00 00 00 00 00 00 NULL
697
698 ************************************************************************
699
700 The data format actually sent to the Kodak 1400 is rather different.
701
702 All commands are null-padded to 96 bytes.
703 All readback values are 8 bytes long.
704
705 Multi-byte numbers are sent BIG ENDIAN.
706
707 Image data is sent via planes, one scanline per URB.
708
709 <-- 1b 72 # Status query
710 --> e4 72 00 00 00 00 00 00 # Idle response
711
712 <-- 1b 00 # Reset/attention?
713 <-- 1b 5a 53 0a 00 0b c2 # Setup (ie hdr.columns and hdr.rows)
714 <-- 1b 59 01 # ?? hdr.matte ?
715 <-- 1b 60 XX # hdr.lamination
716 <-- 1b 62 XX # hdr.lam_strength
717 <-- 1b 61 01 # ?? hdr.unk1 ?
718
719 <-- 1b 5a 54 01 00 00 00 0a 00 0b c2 # start of plane 1 data
720 <-- row 1
721 <-- row 2
722 <-- row last
723
724 <-- 1b 74 01 50 # ??
725
726 <-- 1b 72 # Status query
727 --> e4 72 00 00 00 00 50 59 # Printing plane 1
728 [ repeats until...]
729 <-- 1b 72 # Status query
730 --> e4 72 00 00 40 00 50 59 # Paper loaded?
731 [ repeats until...]
732 <-- 1b 72 # Status query
733 --> e4 72 00 00 00 00 50 59 # Printing plane 1
734 [ repeats until...]
735 <-- 1b 72 # Status query
736 --> e4 72 00 00 00 00 00 00 # Idle response
737
738 <-- 1b 74 00 50 # ??
739 <-- 1b 5a 54 02 00 00 00 0a 00 0b c2 # start of plane 2 data
740 <-- row 1
741 <-- row 2
742 <-- row last
743 <-- 1b 74 01 50 # ??
744
745 <-- 1b 72 # Status query
746 --> e4 72 00 00 00 00 50 4d # Printing plane 2
747 [ repeats until...]
748 <-- 1b 72 # Status query
749 --> e4 72 00 00 00 00 00 00 # Idle response
750
751 <-- 1b 74 00 50 # ??
752 <-- 1b 5a 54 03 00 00 00 0a 00 0b c2 # start of plane 3 data
753 <-- row 1
754 <-- row 2
755 <-- row last
756 <-- 1b 74 01 50 # ??
757
758 <-- 1b 72 # Status query
759 --> e4 72 00 00 00 00 50 43 # Printing plane 3
760 [ repeats until...]
761 <-- 1b 72 # Status query
762 --> e4 72 00 00 00 00 00 00 # Idle response
763
764 ## this block is only present if lamination is used
765
766 <-- 1b 74 00 50 # ??
767 <-- 1b 5a 54 04 # start of lamination
768 <-- 1b 74 01 50 # ??
769
770 <-- 1b 72 # Status query
771 --> e4 72 00 00 00 00 50 50 # Laminating
772 [ repeats until...]
773 <-- 1b 72 # Status query
774 --> e4 72 00 00 00 00 00 00 # Idle response
775
776 ## end lamination block
777
778 <-- 1b 74 00 50 # ??
779
780 [[ DONE ]]
781
782 Other readback codes seen:
783
784 e4 72 00 00 40 00 50 59 -- ?? paper jam?
785 e4 72 00 00 10 00 50 59 -- media red blink, error red blink, [media mismatch]]
786 e4 72 00 00 10 01 50 59 -- ???
787 e4 72 00 00 00 04 50 59 -- media red blink, error red [media too small for image ?]
788 e4 72 00 00 02 00 50 59 -- media off, error red. [out of paper]
789 e4 72 00 00 02 01 00 00 -- media off, error red. [out of paper]
790 e4 72 00 00 02 00 00 00 -- media off, error red. [out of paper]
791 e4 72 00 00 02 00 50 50 -- media on, error red. [paper jam while laminating]
792
793 ^^ ^^ Status
794
795 00 00 Idle
796 50 59 Printing Y
797 50 4d Printing M
798 50 53 Printing C
799 50 50 Printing O
800 ^^ ^^ Error code
801 00 08 No paper tray
802 02 00 Paper jam
803 02 01 Cover popped open during printing
804 08 00 Top open
805 10 00 Media mismatch
806 10 01 ??
807 40 00 Failed to load media (paper empty?)
808
809
810 *********************************************
811 Calibration data:
812
813 <-- 1b a2 # ?? Reset cal tables?
814 --> 00 01 00 00 00 00 00 00
815
816 <-- 1b a0 02 03 06 10 # 06 10 == 1552 bytes aka the CAL data.
817 <-- cal data
818
819 [[ Data is organized as three blocks of 512 bytes followed by
820 16 NULL bytes.
821
822 Each block appears to be 256 entries of 16-bit LE data,
823 so each input value is translated into a 16-bit number in the printer.
824
825 Assuming blocks are ordered BGR.
826
827 ]]
828
829 --> 00 00 00 00 00 00 00 00
830
831 */