| 1 | /* |
| 2 | * Sony UP-D series Photo Printer CUPS backend |
| 3 | * |
| 4 | * (c) 2013-2025 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 sonyupd_backend |
| 28 | |
| 29 | #include "backend_common.h" |
| 30 | |
| 31 | /* Printer status |
| 32 | --> 1b e0 00 00 00 00 XX 00 [[ XX is 0xe on UPD895, 0xf on others ]] |
| 33 | <-- this struct |
| 34 | */ |
| 35 | struct sony_updsts { |
| 36 | uint8_t len; /* 0x0d/0x0e (ie number of bytes AFTER this one) */ |
| 37 | uint8_t zero1; /* 0x00 */ |
| 38 | uint8_t printing; /* UPD_PRINTING_* */ |
| 39 | uint8_t remain; /* Number of remaining pages */ |
| 40 | uint8_t sts0; /* UPD_STS0_* */ |
| 41 | uint8_t sts1; /* UPD_STS1_* */ |
| 42 | uint8_t sts2; /* UPD_STS2_* */ |
| 43 | uint8_t sts3; /* UPD_STS3_* */ |
| 44 | uint8_t ribbon; /* 0x04 = R206/6x8 or C48/4x8 */ |
| 45 | uint8_t paper; /* 0x38 = EMPTY, 0xa8/0x90 = loaded */ |
| 46 | uint16_t max_cols; /* BE */ |
| 47 | uint16_t max_rows; /* BE */ |
| 48 | uint8_t percent; /* 0-99, if job is printing (UP-D89x) */ |
| 49 | } __attribute__((packed)); |
| 50 | |
| 51 | struct sony_prints { |
| 52 | uint8_t zero[4]; |
| 53 | uint16_t remain; /* BE, remaining prints on media */ |
| 54 | } __attribute((packed)); |
| 55 | |
| 56 | #define UPD_PRINTING_BW 0xe0 /* UPD-895/897 only */ |
| 57 | #define UPD_PRINTING_Y 0x40 |
| 58 | #define UPD_PRINTING_M 0x80 |
| 59 | #define UPD_PRINTING_C 0xc0 |
| 60 | #define UPD_PRINTING_O 0x20 |
| 61 | #define UPD_PRINTING_IDLE 0x00 |
| 62 | |
| 63 | /* Confirmed on UP-DR200 */ |
| 64 | #define UPD_STS0_OK 0x00 |
| 65 | #define UPD_STS0_NORIBBON 0x10 |
| 66 | #define UPD_STS0_NOPAPER 0x20 |
| 67 | #define UPD_STS0_DOOROPEN 0x40 |
| 68 | |
| 69 | /* Confirmed on UP-D89x */ |
| 70 | #define UPD_STS1_IDLE 0x00 |
| 71 | #define UPD_STS1_DOOROPEN 0x08 |
| 72 | #define UPD_STS1_NOPAPER 0x40 |
| 73 | #define UPD_STS1_PRINTING 0x80 |
| 74 | #define UPD_STS1_PRINTING2 0xC0 |
| 75 | |
| 76 | /* Confirmed on UP-D711 */ |
| 77 | #define UPD7_STS0_IDLE 0x00 |
| 78 | #define UPD7_STS0_NOPAPER 0x08 |
| 79 | #define UPD7_STS0_DOOROPEN 0x40 |
| 80 | //#define UPD7_STS0_PRINTING 0x80 |
| 81 | //#define UPD7_STS0_PRINTING2 0xC0 |
| 82 | |
| 83 | #define UPD_RIBBON_R206 0x04 |
| 84 | #define UPD_RIBBON_C48 0x04 |
| 85 | #define NDC_RIBBON_D2T 0x02 |
| 86 | |
| 87 | /* Private data structures */ |
| 88 | struct upd_printjob { |
| 89 | struct dyesub_job_common common; |
| 90 | |
| 91 | uint8_t *databuf; |
| 92 | int datalen; |
| 93 | uint32_t copies_offset; |
| 94 | |
| 95 | uint16_t rows; |
| 96 | uint16_t cols; |
| 97 | uint32_t imglen; |
| 98 | }; |
| 99 | |
| 100 | struct upd_ctx { |
| 101 | struct dyesub_connection *conn; |
| 102 | |
| 103 | int native_bpp; |
| 104 | |
| 105 | struct sony_updsts stsbuf; |
| 106 | struct sony_prints printbuf; |
| 107 | |
| 108 | struct marker marker; |
| 109 | }; |
| 110 | |
| 111 | static const char *upd_ribbons(int type, uint8_t code) |
| 112 | { |
| 113 | if (type == P_SONY_UPD895 || type == P_SONY_UPD897) { |
| 114 | return "UP-110 Roll"; |
| 115 | } else if (type == P_SONY_UPD711) { |
| 116 | return "UPP-84 Roll"; |
| 117 | } else if (type == P_SONY_UPCR10) { |
| 118 | if (code == UPD_RIBBON_C48) |
| 119 | return "2UPC-C48 (4x8)"; |
| 120 | } else if (type == P_SONY_UPDR150) { |
| 121 | /* DR200/DR150 */ |
| 122 | if (code == UPD_RIBBON_R206) |
| 123 | return "R206 (8x6)"; |
| 124 | } else if (type == P_NDC) { |
| 125 | if (code == NDC_RIBBON_D2T) { |
| 126 | return "RK-D2T (4x6)"; |
| 127 | } |
| 128 | } |
| 129 | |
| 130 | return "Unknown"; |
| 131 | } |
| 132 | |
| 133 | static int sonyupd_media_maxes(uint8_t type, uint8_t media) |
| 134 | { |
| 135 | if (type == P_SONY_UPDR150) { |
| 136 | if (media == UPD_RIBBON_R206) |
| 137 | return 350; |
| 138 | else |
| 139 | return 700; // XXX guess until we have more codes? |
| 140 | |
| 141 | // XXX also differs for DR200 vs DR150? |
| 142 | } else if (type == P_SONY_UPCR10) { |
| 143 | if (media == UPD_RIBBON_C48) |
| 144 | return 150; |
| 145 | return 200; // XXX guess until we have more codes. |
| 146 | } else if (type == P_NDC) { |
| 147 | if (media == NDC_RIBBON_D2T) { |
| 148 | return 600; |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | return CUPS_MARKER_UNAVAILABLE; |
| 153 | } |
| 154 | |
| 155 | // UP-DR200 |
| 156 | // 2UPC-R203 3.5x5 (770) |
| 157 | // 2UPC-R204 4x6 (700) |
| 158 | // 2UPC-R205 5x7 (400) |
| 159 | // 2UPC-R206 6x8 (350) |
| 160 | |
| 161 | // UP-DR150 |
| 162 | // 2UPC-R153 (610) |
| 163 | // 2UPC-R154 (550) |
| 164 | // 2UPC-R155 (335) |
| 165 | // 2UPC-R156 (295) |
| 166 | |
| 167 | // UP-CR10L & UP-CX1 |
| 168 | |
| 169 | // 2UPC-C13 (344) |
| 170 | // 2UPC-C14 (200) |
| 171 | // 2UPC-C15 (172) |
| 172 | // 2UPC-C48 (150) |
| 173 | |
| 174 | // print order: ->YMCO-> |
| 175 | // current prints (power on) |
| 176 | // total prints (lifetime) |
| 177 | // f/w version |
| 178 | |
| 179 | static const char* upd895_statuses(uint8_t code) |
| 180 | { |
| 181 | switch (code) { |
| 182 | case UPD_STS1_IDLE: |
| 183 | return "Idle"; |
| 184 | case UPD_STS1_DOOROPEN: |
| 185 | return "Door open"; |
| 186 | case UPD_STS1_NOPAPER: |
| 187 | return "No paper"; |
| 188 | case UPD_STS1_PRINTING: |
| 189 | case UPD_STS1_PRINTING2: |
| 190 | return "Printing"; |
| 191 | default: |
| 192 | return "Unknown"; |
| 193 | } |
| 194 | } |
| 195 | |
| 196 | static const char* upd711_statuses(uint8_t code) |
| 197 | { |
| 198 | switch (code) { |
| 199 | case UPD7_STS0_IDLE: |
| 200 | return "Idle"; |
| 201 | case UPD7_STS0_DOOROPEN: |
| 202 | return "Door open"; |
| 203 | case UPD7_STS0_NOPAPER: |
| 204 | return "No paper"; |
| 205 | #if 0 |
| 206 | case UPD7_STS0_PRINTING: |
| 207 | case UPD7_STS0_PRINTING2: |
| 208 | return "Printing"; |
| 209 | #endif |
| 210 | default: |
| 211 | return "Unknown"; |
| 212 | } |
| 213 | } |
| 214 | |
| 215 | static const char* updr200_statuses(uint8_t code) |
| 216 | { |
| 217 | switch (code) { |
| 218 | case UPD_STS0_OK: |
| 219 | return "OK"; |
| 220 | case UPD_STS0_DOOROPEN: |
| 221 | return "Door open"; |
| 222 | case UPD_STS0_NOPAPER: |
| 223 | return "No paper"; |
| 224 | case UPD_STS0_NORIBBON: |
| 225 | return "No ribbon"; |
| 226 | default: |
| 227 | return "Unknown"; |
| 228 | } |
| 229 | } |
| 230 | |
| 231 | /* Now for the code */ |
| 232 | |
| 233 | static int sony_get_status(struct upd_ctx *ctx, struct sony_updsts *buf) |
| 234 | { |
| 235 | int ret, num = 0; |
| 236 | uint8_t query[7] = { 0x1b, 0xe0, 0, 0, 0, 0x0f, 0 }; |
| 237 | |
| 238 | if (ctx->conn->type == P_SONY_UPD895 || |
| 239 | ctx->conn->type == P_NDC) |
| 240 | query[5] = 0x0e; |
| 241 | |
| 242 | if ((ret = send_data(ctx->conn, |
| 243 | query, sizeof(query)))) |
| 244 | return CUPS_BACKEND_FAILED; |
| 245 | |
| 246 | ret = read_data(ctx->conn, (uint8_t*) buf, sizeof(*buf), |
| 247 | &num); |
| 248 | |
| 249 | if (ret < 0) |
| 250 | return CUPS_BACKEND_FAILED; |
| 251 | #if 0 |
| 252 | if (ctx->conn->type == P_SONY_UPD895 && ret != 14) |
| 253 | return CUPS_BACKEND_FAILED; |
| 254 | else if (ret != 15) |
| 255 | return CUPS_BACKEND_FAILED; |
| 256 | #endif |
| 257 | |
| 258 | buf->max_cols = be16_to_cpu(buf->max_cols); |
| 259 | buf->max_rows = be16_to_cpu(buf->max_rows); |
| 260 | |
| 261 | return CUPS_BACKEND_OK; |
| 262 | } |
| 263 | |
| 264 | static int sony_get_prints(struct upd_ctx *ctx, struct sony_prints *buf) |
| 265 | { |
| 266 | int ret, num = 0; |
| 267 | uint8_t query[7] = { 0x1b, 0xef, 0, 0, 0, 0x06, 0 }; |
| 268 | |
| 269 | if ((ret = send_data(ctx->conn, |
| 270 | query, sizeof(query)))) |
| 271 | return CUPS_BACKEND_FAILED; |
| 272 | |
| 273 | ret = read_data(ctx->conn, (uint8_t*) buf, sizeof(*buf), |
| 274 | &num); |
| 275 | |
| 276 | if (ret < 0) |
| 277 | return CUPS_BACKEND_FAILED; |
| 278 | |
| 279 | buf->remain = be16_to_cpu(buf->remain); |
| 280 | |
| 281 | return CUPS_BACKEND_OK; |
| 282 | } |
| 283 | |
| 284 | static void* upd_init(void) |
| 285 | { |
| 286 | struct upd_ctx *ctx = malloc(sizeof(struct upd_ctx)); |
| 287 | if (!ctx) { |
| 288 | ERROR("Memory Allocation Failure!\n"); |
| 289 | return NULL; |
| 290 | } |
| 291 | memset(ctx, 0, sizeof(struct upd_ctx)); |
| 292 | return ctx; |
| 293 | } |
| 294 | |
| 295 | static int upd_attach(void *vctx, struct dyesub_connection *conn, uint8_t jobid) |
| 296 | { |
| 297 | struct upd_ctx *ctx = vctx; |
| 298 | |
| 299 | UNUSED(jobid); |
| 300 | |
| 301 | ctx->conn = conn; |
| 302 | |
| 303 | if (ctx->conn->type == P_SONY_UPD895 || ctx->conn->type == P_SONY_UPD897 || ctx->conn->type == P_SONY_UPD711) { |
| 304 | ctx->marker.color = "#000000"; /* Ie black! */ |
| 305 | ctx->native_bpp = 1; |
| 306 | } else { |
| 307 | ctx->marker.color = "#00FFFF#FF00FF#FFFF00"; |
| 308 | ctx->native_bpp = 3; |
| 309 | } |
| 310 | |
| 311 | if (test_mode < TEST_MODE_NOATTACH) { |
| 312 | int ret; |
| 313 | if ((ret = sony_get_status(ctx, &ctx->stsbuf))) { |
| 314 | return ret; |
| 315 | } |
| 316 | if (ctx->native_bpp == 1 && (ret = sony_get_prints(ctx, &ctx->printbuf))) { |
| 317 | return ret; |
| 318 | } |
| 319 | } |
| 320 | |
| 321 | if (test_mode >= TEST_MODE_NOATTACH && getenv("MEDIA_CODE")) { |
| 322 | ctx->marker.numtype = strtol(getenv("MEDIA_CODE"), NULL, 16); |
| 323 | } else { |
| 324 | ctx->marker.numtype = ctx->stsbuf.ribbon; |
| 325 | } |
| 326 | |
| 327 | ctx->marker.name = upd_ribbons(ctx->conn->type, ctx->stsbuf.ribbon); |
| 328 | if (test_mode >= TEST_MODE_NOATTACH || ctx->native_bpp == 1) { |
| 329 | ctx->marker.levelmax = CUPS_MARKER_UNAVAILABLE; |
| 330 | ctx->marker.levelnow = CUPS_MARKER_UNKNOWN; |
| 331 | } else { |
| 332 | ctx->marker.levelmax = sonyupd_media_maxes(ctx->conn->type, ctx->stsbuf.ribbon); |
| 333 | ctx->marker.levelnow = ctx->printbuf.remain; |
| 334 | } |
| 335 | |
| 336 | |
| 337 | return CUPS_BACKEND_OK; |
| 338 | } |
| 339 | |
| 340 | static void upd_cleanup_job(const void *vjob) |
| 341 | { |
| 342 | const struct upd_printjob *job = vjob; |
| 343 | |
| 344 | if (job->databuf) |
| 345 | free(job->databuf); |
| 346 | |
| 347 | free((void*)job); |
| 348 | } |
| 349 | |
| 350 | //#define MAX_PRINTJOB_LEN (2048*2764*3 + 2048) /* Sony */ |
| 351 | #define MAX_PRINTJOB_LEN (2444*3644*3 + 2048) /* DPB and ASK series */ |
| 352 | |
| 353 | static int ndc_read_parse(struct upd_ctx *ctx, struct upd_printjob *job, int data_fd, uint32_t *copies_offset) |
| 354 | { |
| 355 | int run = 1; |
| 356 | uint32_t param_offset = 0; |
| 357 | (void)ctx; |
| 358 | |
| 359 | while(run) { |
| 360 | int i; |
| 361 | int remain = 0; |
| 362 | |
| 363 | uint32_t cmdlen; |
| 364 | uint8_t cmdbuf[11]; |
| 365 | |
| 366 | /* Read the ESC and command */ |
| 367 | i = read(data_fd, cmdbuf, 2); |
| 368 | if (i < 0) { |
| 369 | return CUPS_BACKEND_CANCEL; |
| 370 | } |
| 371 | if (i == 0) |
| 372 | break; |
| 373 | |
| 374 | if (cmdbuf[0] != 0x1b) { |
| 375 | ERROR("Unexpected data in stream! (%02x)\n", cmdbuf[0]); |
| 376 | return CUPS_BACKEND_CANCEL; |
| 377 | } |
| 378 | |
| 379 | /* Work out command specifics */ |
| 380 | if (cmdbuf[1] == 0xea) { // Data transfer |
| 381 | cmdlen = 11; |
| 382 | } else { // everything else |
| 383 | cmdlen = 7; |
| 384 | } |
| 385 | |
| 386 | if (job->datalen + cmdlen > MAX_PRINTJOB_LEN) { |
| 387 | ERROR("Buffer overflow when parsing printjob! (%d+%d)\n", |
| 388 | job->datalen, remain); |
| 389 | return CUPS_BACKEND_CANCEL; |
| 390 | } |
| 391 | |
| 392 | /* Some special casing */ |
| 393 | if (cmdbuf[1] == 0x0a) |
| 394 | run = 0; |
| 395 | else if (cmdbuf[1] == 0xee) |
| 396 | *copies_offset = job->datalen + 7 + sizeof(uint32_t)*2; |
| 397 | else if (cmdbuf[1] == 0xe1) |
| 398 | param_offset = job->datalen + 14 + sizeof(uint32_t)*2; |
| 399 | |
| 400 | /* Read remainder of cmd */ |
| 401 | i = read(data_fd, cmdbuf + 2, cmdlen - 2); |
| 402 | if (i != (int)(cmdlen - 2)) { |
| 403 | ERROR("Unexpected read length! (%d)\n", i); |
| 404 | return CUPS_BACKEND_CANCEL; |
| 405 | } |
| 406 | |
| 407 | /* Move cmdbuf into job buffer */ |
| 408 | memcpy(job->databuf + job->datalen, &cmdlen, sizeof(uint32_t)); |
| 409 | job->datalen += sizeof(uint32_t); |
| 410 | memcpy(job->databuf + job->datalen, cmdbuf, cmdlen); |
| 411 | job->datalen += cmdlen; |
| 412 | |
| 413 | /* Work out data transfer length */ |
| 414 | if (cmdbuf[1] == 0xea) { /* Image data transfer */ |
| 415 | uint32_t datalen; |
| 416 | memcpy(&datalen, cmdbuf + 6, sizeof(uint32_t)); |
| 417 | datalen = be32_to_cpu(datalen); |
| 418 | memcpy(job->databuf + job->datalen, &datalen, sizeof(uint32_t)); |
| 419 | job->datalen += sizeof(uint32_t); |
| 420 | remain = datalen; |
| 421 | |
| 422 | job->imglen = datalen; |
| 423 | } else { // everything else |
| 424 | uint32_t datalen; |
| 425 | uint16_t len; |
| 426 | memcpy(&len, cmdbuf + 4, sizeof(uint16_t)); |
| 427 | len = be16_to_cpu(len); |
| 428 | if (len) { |
| 429 | datalen = len; |
| 430 | memcpy(job->databuf + job->datalen, &datalen, sizeof(uint32_t)); |
| 431 | job->datalen += sizeof(uint32_t); |
| 432 | } |
| 433 | remain = len; |
| 434 | } |
| 435 | |
| 436 | if(dyesub_debug) |
| 437 | DEBUG("Data block (len %d)\n", remain); |
| 438 | |
| 439 | /* Make sure we're not too large */ |
| 440 | if (job->datalen + remain > MAX_PRINTJOB_LEN) { |
| 441 | ERROR("Buffer overflow when parsing printjob! (%d+%d)\n", |
| 442 | job->datalen, remain); |
| 443 | return CUPS_BACKEND_CANCEL; |
| 444 | } |
| 445 | |
| 446 | /* Read in the data chunk */ |
| 447 | while (remain > 0) { |
| 448 | i = read(data_fd, job->databuf + job->datalen, remain); |
| 449 | if (i < 0) { |
| 450 | return CUPS_BACKEND_CANCEL; |
| 451 | } |
| 452 | if (i == 0) |
| 453 | break; |
| 454 | remain -= i; |
| 455 | job->datalen += i; |
| 456 | } |
| 457 | } |
| 458 | |
| 459 | /* Parse some other stuff */ |
| 460 | if (param_offset) { |
| 461 | memcpy(&job->cols, job->databuf + param_offset, sizeof(uint16_t)); |
| 462 | memcpy(&job->rows, job->databuf + param_offset + 2, sizeof(uint16_t)); |
| 463 | job->cols = be16_to_cpu(job->cols); |
| 464 | job->rows = be16_to_cpu(job->rows); |
| 465 | } |
| 466 | |
| 467 | return CUPS_BACKEND_OK; |
| 468 | } |
| 469 | |
| 470 | static int sony_read_parse(struct upd_ctx *ctx, struct upd_printjob *job, int data_fd, uint32_t *copies_offset) { |
| 471 | |
| 472 | int len, run = 1; |
| 473 | uint32_t param_offset = 0; |
| 474 | uint32_t data_offset = 0; |
| 475 | |
| 476 | while(run) { |
| 477 | int i; |
| 478 | int keep = 0; |
| 479 | i = read(data_fd, job->databuf + job->datalen, 4); |
| 480 | if (i < 0) { |
| 481 | return CUPS_BACKEND_CANCEL; |
| 482 | } |
| 483 | if (i == 0) |
| 484 | break; |
| 485 | |
| 486 | memcpy(&len, job->databuf + job->datalen, sizeof(len)); |
| 487 | len = le32_to_cpu(len); |
| 488 | |
| 489 | /* Filter out chunks we don't send to the printer */ |
| 490 | if (len & 0xf0000000) { |
| 491 | switch (len) { |
| 492 | case 0xfffffff3: |
| 493 | if(dyesub_debug) |
| 494 | DEBUG("Block ID '%08x' (len %d)\n", len, 0); |
| 495 | len = 0; |
| 496 | if (ctx->conn->type == P_SONY_UPDR150) |
| 497 | run = 0; |
| 498 | break; |
| 499 | case 0xfffffff7: |
| 500 | if(dyesub_debug) |
| 501 | DEBUG("Block ID '%08x' (len %d)\n", len, 0); |
| 502 | len = 0; |
| 503 | if (ctx->conn->type == P_SONY_UPCR10) |
| 504 | run = 0; |
| 505 | break; |
| 506 | case 0xfffffff8: // 895 |
| 507 | case 0xfffffff4: // 897/711 |
| 508 | if(dyesub_debug) |
| 509 | DEBUG("Block ID '%08x' (len %d)\n", len, 0); |
| 510 | len = 0; |
| 511 | if (ctx->conn->type == P_SONY_UPD895 || ctx->conn->type == P_SONY_UPD897 || ctx->conn->type == P_SONY_UPD711) |
| 512 | run = 0; |
| 513 | break; |
| 514 | case 0xfffffff5: |
| 515 | if (ctx->conn->type == P_SONY_UPD711) { |
| 516 | if(dyesub_debug) |
| 517 | DEBUG("Block ID '%08x' (len %d)\n", len, 0); |
| 518 | len = 0; |
| 519 | } else { |
| 520 | if(dyesub_debug) |
| 521 | DEBUG("Block ID '%08x' (len %d)\n", len, 4); |
| 522 | len = 4; |
| 523 | } |
| 524 | break; |
| 525 | case 0xffffff97: |
| 526 | if(dyesub_debug) |
| 527 | DEBUG("Block ID '%08x' (len %d)\n", len, 12); |
| 528 | len = 12; |
| 529 | break; |
| 530 | case 0xffffffef: |
| 531 | if (ctx->conn->type == P_SONY_UPD895 || ctx->conn->type == P_SONY_UPD897) { |
| 532 | if(dyesub_debug) |
| 533 | DEBUG("Block ID '%08x' (len %d)\n", len, 0); |
| 534 | len = 0; |
| 535 | } else { |
| 536 | if(dyesub_debug) |
| 537 | DEBUG("Block ID '%08x' (len %d)\n", len, 4); |
| 538 | len = 4; |
| 539 | } |
| 540 | break; |
| 541 | case 0xffffffeb: |
| 542 | case 0xffffffee: |
| 543 | if(dyesub_debug) |
| 544 | DEBUG("Block ID '%08x' (len %d)\n", len, 4); |
| 545 | len = 4; |
| 546 | break; |
| 547 | case 0xffffffec: |
| 548 | if (ctx->conn->type == P_SONY_UPD897 || ctx->conn->type == P_SONY_UPD711) { |
| 549 | if(dyesub_debug) |
| 550 | DEBUG("Block ID '%08x' (len %d)\n", len, 4); |
| 551 | len = 4; |
| 552 | } else { |
| 553 | if(dyesub_debug) |
| 554 | DEBUG("Block ID '%08x' (len %d)\n", len, 0); |
| 555 | len = 0; |
| 556 | } |
| 557 | break; |
| 558 | default: |
| 559 | if(dyesub_debug) |
| 560 | DEBUG("Block ID '%08x' (len %d)\n", len, 0); |
| 561 | len = 0; |
| 562 | break; |
| 563 | } |
| 564 | } else { |
| 565 | /* Only keep these chunks */ |
| 566 | if(dyesub_debug) |
| 567 | DEBUG("Data block (len %d)\n", len); |
| 568 | if (len > 0) |
| 569 | keep = 1; |
| 570 | } |
| 571 | if (keep) |
| 572 | job->datalen += sizeof(uint32_t); |
| 573 | |
| 574 | /* Make sure we're not too large */ |
| 575 | if (job->datalen + len > MAX_PRINTJOB_LEN) { |
| 576 | ERROR("Buffer overflow when parsing printjob! (%d+%d)\n", |
| 577 | job->datalen, len); |
| 578 | return CUPS_BACKEND_CANCEL; |
| 579 | } |
| 580 | |
| 581 | /* Read in the data chunk */ |
| 582 | while(len > 0) { |
| 583 | i = read(data_fd, job->databuf + job->datalen, len); |
| 584 | if (i < 0) { |
| 585 | return CUPS_BACKEND_CANCEL; |
| 586 | } |
| 587 | if (i == 0) |
| 588 | break; |
| 589 | |
| 590 | /* Work out offset of copies command */ |
| 591 | if (job->databuf[job->datalen] == 0x1b) { |
| 592 | int offset = 0; |
| 593 | if (i == 7) |
| 594 | offset = 4; |
| 595 | |
| 596 | switch (job->databuf[job->datalen + 1]) { |
| 597 | case 0x15: /* Print dimensions */ |
| 598 | param_offset = job->datalen + 16 + offset; |
| 599 | break; |
| 600 | // XXX case 0xc0: |
| 601 | // for param 03, take the value at offset 4 -- for (eg) 4x6 on 8x6 media, needs to be set to 0x02 |
| 602 | case 0xee: |
| 603 | *copies_offset = job->datalen + 7 + offset; |
| 604 | break; |
| 605 | case 0xe1: /* Image dimensions */ |
| 606 | param_offset = job->datalen + 14 + offset; |
| 607 | break; |
| 608 | case 0xea: |
| 609 | data_offset = job->datalen + 6 + offset; |
| 610 | break; |
| 611 | default: |
| 612 | break; |
| 613 | } |
| 614 | } |
| 615 | |
| 616 | if (keep) |
| 617 | job->datalen += i; |
| 618 | len -= i; |
| 619 | } |
| 620 | } |
| 621 | if (!job->datalen) { |
| 622 | return CUPS_BACKEND_CANCEL; |
| 623 | } |
| 624 | |
| 625 | /* Parse some other stuff */ |
| 626 | if (param_offset) { |
| 627 | memcpy(&job->cols, job->databuf + param_offset, sizeof(uint16_t)); |
| 628 | memcpy(&job->rows, job->databuf + param_offset + 2, sizeof(uint16_t)); |
| 629 | job->cols = be16_to_cpu(job->cols); |
| 630 | job->rows = be16_to_cpu(job->rows); |
| 631 | } |
| 632 | if (data_offset) { |
| 633 | memcpy(&job->imglen, job->databuf + data_offset, sizeof(uint32_t)); |
| 634 | job->imglen = be32_to_cpu(job->imglen); |
| 635 | } |
| 636 | |
| 637 | return CUPS_BACKEND_OK; |
| 638 | } |
| 639 | |
| 640 | static int upd_read_parse(void *vctx, const void **vjob, int data_fd, int copies) { |
| 641 | struct upd_ctx *ctx = vctx; |
| 642 | struct upd_printjob *job = NULL; |
| 643 | uint32_t copies_offset = 0; |
| 644 | int rval = CUPS_BACKEND_OK; |
| 645 | |
| 646 | if (!ctx) |
| 647 | return CUPS_BACKEND_FAILED; |
| 648 | |
| 649 | job = malloc(sizeof(*job)); |
| 650 | if (!job) { |
| 651 | ERROR("Memory allocation failure!\n"); |
| 652 | return CUPS_BACKEND_RETRY_CURRENT; |
| 653 | } |
| 654 | memset(job, 0, sizeof(*job)); |
| 655 | job->common.jobsize = sizeof(*job); |
| 656 | job->common.copies = copies; |
| 657 | |
| 658 | job->datalen = 0; |
| 659 | job->databuf = malloc(MAX_PRINTJOB_LEN); |
| 660 | if (!job->databuf) { |
| 661 | ERROR("Memory allocation failure!\n"); |
| 662 | rval = CUPS_BACKEND_RETRY_CURRENT; |
| 663 | goto done; |
| 664 | } |
| 665 | |
| 666 | if (ctx->conn->type == P_NDC) { |
| 667 | rval = ndc_read_parse(ctx, job, data_fd, &copies_offset); |
| 668 | } else { |
| 669 | rval = sony_read_parse(ctx, job, data_fd, &copies_offset); |
| 670 | } |
| 671 | |
| 672 | /* Some models specify copies in the print job */ |
| 673 | if (copies_offset) { |
| 674 | uint16_t tmp; |
| 675 | memcpy(&tmp, job->databuf + copies_offset, sizeof(tmp)); |
| 676 | tmp = be16_to_cpu(tmp); |
| 677 | if (tmp < copies) { /* Use larger of our copy counts */ |
| 678 | tmp = cpu_to_be16(copies); |
| 679 | memcpy(job->databuf + copies_offset, &tmp, sizeof(tmp)); |
| 680 | } else { |
| 681 | job->common.copies = tmp; |
| 682 | } |
| 683 | job->copies_offset = copies_offset; |
| 684 | } |
| 685 | |
| 686 | if (!job->datalen) { |
| 687 | rval = CUPS_BACKEND_CANCEL; |
| 688 | goto done; |
| 689 | } |
| 690 | |
| 691 | /* Sanity check job parameters */ |
| 692 | if (job->imglen != (uint32_t)(job->rows * job->cols * ctx->native_bpp)) |
| 693 | { |
| 694 | ERROR("Job data length mismatch (%u vs %d)!\n", |
| 695 | job->imglen, job->rows * job->cols * ctx->native_bpp); |
| 696 | rval = CUPS_BACKEND_CANCEL; |
| 697 | goto done; |
| 698 | } |
| 699 | |
| 700 | #if 0 |
| 701 | { |
| 702 | FILE *fp = fopen("/tmp/foo.prn", "wb"); |
| 703 | fwrite(job->databuf, job->datalen, 1, fp); |
| 704 | fclose(fp); |
| 705 | } |
| 706 | #endif |
| 707 | |
| 708 | done: |
| 709 | if (rval) { |
| 710 | upd_cleanup_job(job); |
| 711 | } else { |
| 712 | *vjob = job; |
| 713 | } |
| 714 | |
| 715 | return rval; |
| 716 | } |
| 717 | |
| 718 | static int upd_main_loop(void *vctx, const void *vjob, int wait_for_return) { |
| 719 | struct upd_ctx *ctx = vctx; |
| 720 | int i, ret; |
| 721 | int copies; |
| 722 | |
| 723 | const struct upd_printjob *job = vjob; |
| 724 | |
| 725 | if (!ctx) |
| 726 | return CUPS_BACKEND_FAILED; |
| 727 | if (!job) |
| 728 | return CUPS_BACKEND_FAILED; |
| 729 | |
| 730 | /* Hardware copies or not? */ |
| 731 | if (job->copies_offset) |
| 732 | copies = 1; |
| 733 | else |
| 734 | copies = job->common.copies; |
| 735 | |
| 736 | top: |
| 737 | /* Send Unknown CMD. Resets? */ |
| 738 | if (ctx->conn->type == P_SONY_UPD897) { |
| 739 | const uint8_t cmdbuf[7] = { 0x1b, 0x1f, 0, 0, 0, 0, 0 }; |
| 740 | ret = send_data(ctx->conn, |
| 741 | cmdbuf, sizeof(cmdbuf)); |
| 742 | if (ret) |
| 743 | return CUPS_BACKEND_FAILED; |
| 744 | } |
| 745 | |
| 746 | /* Query printer status */ |
| 747 | ret = sony_get_status(ctx, &ctx->stsbuf); |
| 748 | |
| 749 | if (ret) |
| 750 | return CUPS_BACKEND_FAILED; |
| 751 | |
| 752 | /* Sanity check job parameters */ |
| 753 | if (ctx->conn->type == P_SONY_UPD711) { |
| 754 | if (job->rows > ctx->stsbuf.max_cols || |
| 755 | job->cols > ctx->stsbuf.max_rows) { |
| 756 | ERROR("Job dimensions (%u/%u) exceed printer max (%u/%u)\n", |
| 757 | job->cols, job->rows, |
| 758 | ctx->stsbuf.max_rows, |
| 759 | ctx->stsbuf.max_cols); |
| 760 | return CUPS_BACKEND_CANCEL; |
| 761 | } |
| 762 | } else { |
| 763 | if (job->rows > ctx->stsbuf.max_rows || |
| 764 | job->cols > ctx->stsbuf.max_cols) { |
| 765 | ERROR("Job dimensions (%u/%u) exceed printer max (%u/%u)\n", |
| 766 | job->cols, job->rows, |
| 767 | ctx->stsbuf.max_cols, |
| 768 | ctx->stsbuf.max_rows); |
| 769 | return CUPS_BACKEND_CANCEL; |
| 770 | } |
| 771 | } |
| 772 | |
| 773 | |
| 774 | /* Check for idle */ |
| 775 | if (ctx->conn->type == P_SONY_UPD711) { |
| 776 | if (ctx->stsbuf.sts0 != UPD7_STS0_IDLE) { |
| 777 | if (ctx->stsbuf.sts1 == UPD_STS1_PRINTING) { // XXX |
| 778 | INFO("Waiting for printer idle...\n"); |
| 779 | sleep(1); |
| 780 | goto top; |
| 781 | } else { |
| 782 | ERROR("Printer error: %s (%02x)\n", upd711_statuses(ctx->stsbuf.sts0), ctx->stsbuf.sts0); |
| 783 | return CUPS_BACKEND_STOP; |
| 784 | } |
| 785 | } |
| 786 | } else { |
| 787 | if (ctx->stsbuf.sts0 != UPD7_STS0_IDLE) { |
| 788 | if (ctx->stsbuf.sts1 == UPD_STS1_PRINTING) { |
| 789 | INFO("Waiting for printer idle...\n"); |
| 790 | sleep(1); |
| 791 | goto top; |
| 792 | } else { |
| 793 | if (ctx->conn->type == P_SONY_UPD895 || ctx->conn->type == P_SONY_UPD897) { |
| 794 | ERROR("Printer error: %s (%02x)\n", upd895_statuses(ctx->stsbuf.sts1), ctx->stsbuf.sts1); |
| 795 | } else { |
| 796 | ERROR("Printer error: %s (%02x)\n", updr200_statuses(ctx->stsbuf.sts0), ctx->stsbuf.sts0); |
| 797 | } |
| 798 | return CUPS_BACKEND_STOP; |
| 799 | } |
| 800 | } |
| 801 | } |
| 802 | |
| 803 | /* Send RESET */ |
| 804 | if (ctx->conn->type != P_SONY_UPD895) { |
| 805 | const uint8_t rstbuf[7] = { 0x1b, 0x16, 0, 0, 0, 0, 0 }; |
| 806 | ret = send_data(ctx->conn, |
| 807 | rstbuf, sizeof(rstbuf)); |
| 808 | if (ret) |
| 809 | return CUPS_BACKEND_FAILED; |
| 810 | } |
| 811 | |
| 812 | #if 0 /* Unknown query */ |
| 813 | if (ctx->conn->type == P_SONY_UPD897) { |
| 814 | // -> 1b e6 00 00 00 08 00 |
| 815 | // <- ??? |
| 816 | } |
| 817 | #endif |
| 818 | |
| 819 | /* Send over job */ |
| 820 | i = 0; |
| 821 | while (i < job->datalen) { |
| 822 | uint32_t len; |
| 823 | memcpy(&len, job->databuf + i, sizeof(len)); |
| 824 | len = le32_to_cpu(len); |
| 825 | |
| 826 | i += sizeof(uint32_t); |
| 827 | |
| 828 | if ((ret = send_data(ctx->conn, |
| 829 | job->databuf + i, len))) |
| 830 | return CUPS_BACKEND_FAILED; |
| 831 | |
| 832 | i += len; |
| 833 | } |
| 834 | |
| 835 | // XXX generate and send copy cmd instead of using the offset. |
| 836 | // 1b ee 00 00 00 02 00 NN NN (BE) |
| 837 | |
| 838 | /* Wait for completion! */ |
| 839 | retry: |
| 840 | sleep(1); |
| 841 | |
| 842 | /* Check for idle */ |
| 843 | ret = sony_get_status(ctx, &ctx->stsbuf); |
| 844 | if (ret) |
| 845 | return ret; |
| 846 | |
| 847 | switch (ctx->stsbuf.sts1) { // XXX UP-D711 too... |
| 848 | case UPD_STS1_IDLE: |
| 849 | goto done; |
| 850 | case UPD_STS1_PRINTING: |
| 851 | case UPD_STS1_PRINTING2: |
| 852 | break; |
| 853 | default: |
| 854 | if (ctx->conn->type == P_SONY_UPD895 || ctx->conn->type == P_SONY_UPD897) { |
| 855 | ERROR("Printer error: %s (%02x)\n", upd895_statuses(ctx->stsbuf.sts1), ctx->stsbuf.sts1); |
| 856 | } else if (ctx->conn->type == P_SONY_UPD711) { |
| 857 | ERROR("Printer error: %s (%02x)\n", upd711_statuses(ctx->stsbuf.sts0), ctx->stsbuf.sts0); |
| 858 | } else { |
| 859 | ERROR("Printer error: %s (%02x)\n", updr200_statuses(ctx->stsbuf.sts0), ctx->stsbuf.sts0); |
| 860 | } |
| 861 | return CUPS_BACKEND_STOP; |
| 862 | } |
| 863 | |
| 864 | if (!wait_for_return && ctx->stsbuf.printing != UPD_PRINTING_IDLE) { |
| 865 | INFO("Fast return mode enabled.\n"); |
| 866 | } else { |
| 867 | goto retry; |
| 868 | } |
| 869 | |
| 870 | /* Clean up */ |
| 871 | if (terminate) |
| 872 | copies = 1; |
| 873 | |
| 874 | done: |
| 875 | INFO("Print complete (%d copies remaining)\n", copies - 1); |
| 876 | |
| 877 | if (copies && --copies) { |
| 878 | goto top; |
| 879 | } |
| 880 | |
| 881 | return CUPS_BACKEND_OK; |
| 882 | } |
| 883 | |
| 884 | static int upd895_dump_status(struct upd_ctx *ctx) |
| 885 | { |
| 886 | int ret = sony_get_status(ctx, &ctx->stsbuf); |
| 887 | if (ret < 0) |
| 888 | return CUPS_BACKEND_FAILED; |
| 889 | |
| 890 | if (ctx->conn->type == P_SONY_UPD895 || ctx->conn->type == P_SONY_UPD897) { |
| 891 | INFO("Printer status: %s (%02x)\n", upd895_statuses(ctx->stsbuf.sts1), ctx->stsbuf.sts1); |
| 892 | } else if (ctx->conn->type == P_SONY_UPD711) { |
| 893 | INFO("Printer status: %s (%02x)\n", upd711_statuses(ctx->stsbuf.sts0), ctx->stsbuf.sts0); |
| 894 | } else { |
| 895 | INFO("Printer status: %s (%02x)\n", updr200_statuses(ctx->stsbuf.sts0), ctx->stsbuf.sts0); |
| 896 | } |
| 897 | |
| 898 | if (ctx->stsbuf.printing != UPD_PRINTING_IDLE && |
| 899 | ctx->stsbuf.sts1 == UPD_STS1_PRINTING) |
| 900 | INFO("Remaining copies to print: %d\n", ctx->stsbuf.remain); |
| 901 | |
| 902 | |
| 903 | INFO("Media: %s (%02x)\n", upd_ribbons(ctx->conn->type, ctx->stsbuf.ribbon), ctx->stsbuf.ribbon); |
| 904 | |
| 905 | if (ctx->native_bpp != 1) { |
| 906 | if ((ret = sony_get_prints(ctx, &ctx->printbuf))) |
| 907 | return ret; |
| 908 | INFO("Media remaining: %d/%d\n", ctx->printbuf.remain, sonyupd_media_maxes(ctx->conn->type, ctx->stsbuf.ribbon)); |
| 909 | } |
| 910 | return CUPS_BACKEND_OK; |
| 911 | } |
| 912 | |
| 913 | |
| 914 | static void upd_cmdline(void) |
| 915 | { |
| 916 | DEBUG("\t\t[ -s ] # Query printer status\n"); |
| 917 | } |
| 918 | |
| 919 | static int upd_cmdline_arg(void *vctx, int argc, char **argv) |
| 920 | { |
| 921 | struct upd_ctx *ctx = vctx; |
| 922 | int i, j = 0; |
| 923 | |
| 924 | if (!ctx) |
| 925 | return -1; |
| 926 | |
| 927 | while ((i = getopt(argc, argv, GETOPT_LIST_GLOBAL "s")) >= 0) { |
| 928 | switch(i) { |
| 929 | GETOPT_PROCESS_GLOBAL |
| 930 | case 's': |
| 931 | j = upd895_dump_status(ctx); |
| 932 | break; |
| 933 | } |
| 934 | |
| 935 | if (j) return j; |
| 936 | } |
| 937 | |
| 938 | return CUPS_BACKEND_OK; |
| 939 | } |
| 940 | |
| 941 | static int upd_query_markers(void *vctx, struct marker **markers, int *count) |
| 942 | { |
| 943 | struct upd_ctx *ctx = vctx; |
| 944 | int ret = sony_get_status(ctx, &ctx->stsbuf); |
| 945 | |
| 946 | *markers = &ctx->marker; |
| 947 | *count = 1; |
| 948 | |
| 949 | if (ret) |
| 950 | return CUPS_BACKEND_FAILED; |
| 951 | |
| 952 | if (ctx->native_bpp != 1 && (ret = sony_get_prints(ctx, &ctx->printbuf))) { |
| 953 | return ret; |
| 954 | } |
| 955 | |
| 956 | if (ctx->conn->type == P_SONY_UPD711) { |
| 957 | if (ctx->stsbuf.sts0 == UPD7_STS0_NOPAPER || |
| 958 | ctx->stsbuf.sts0 == UPD7_STS0_DOOROPEN) { |
| 959 | ctx->marker.levelnow = 0; |
| 960 | } else { |
| 961 | ctx->marker.levelnow = CUPS_MARKER_UNKNOWN_OK; |
| 962 | } |
| 963 | } else { |
| 964 | if (ctx->stsbuf.sts1 == UPD_STS1_NOPAPER || |
| 965 | ctx->stsbuf.sts1 == UPD_STS1_DOOROPEN) { |
| 966 | if (ctx->native_bpp == 1) { |
| 967 | ctx->marker.levelnow = 0; |
| 968 | } else { |
| 969 | ctx->marker.levelnow = ctx->printbuf.remain; |
| 970 | } |
| 971 | } else { |
| 972 | if (ctx->native_bpp == 1) { |
| 973 | ctx->marker.levelnow = CUPS_MARKER_UNKNOWN_OK; |
| 974 | } else { |
| 975 | ctx->marker.levelnow = ctx->printbuf.remain; |
| 976 | } |
| 977 | } |
| 978 | } |
| 979 | |
| 980 | return CUPS_BACKEND_OK; |
| 981 | } |
| 982 | |
| 983 | static const char *sonyupd_prefixes[] = { |
| 984 | "sonyupd", /* Family Name */ |
| 985 | "dnp-sl10", // Unknown if shared with CR10L |
| 986 | // Backwards compatibility |
| 987 | "sonyupdr150", "sonyupdr200", "sonyupcr10", |
| 988 | NULL |
| 989 | }; |
| 990 | |
| 991 | static const struct device_id sonyupd_devices[] = { |
| 992 | { 0x054c, 0x0049, P_SONY_UPD895, NULL, "sony-upd895"}, |
| 993 | { 0x054c, 0x01e7, P_SONY_UPD897, NULL, "sony-upd897"}, |
| 994 | { 0x054c, 0x01e8, P_SONY_UPDR150, NULL, "sony-updr150"}, |
| 995 | { 0x054c, 0x0226, P_SONY_UPCR10, NULL, "sony-upcr10l"}, |
| 996 | { 0x054c, 0x02d4, P_SONY_UPCR10, NULL, "sony-upcx1"}, |
| 997 | { 0x054c, 0x035f, P_SONY_UPDR150, NULL, "sony-updr200"}, |
| 998 | { 0x054c, 0x068c, P_SONY_UPD711, NULL, "sony-upd711"}, |
| 999 | { 0x07ce, 0xc005, P_NDC, NULL, "ndc-dpb-1500"}, |
| 1000 | { 0x07ce, 0xc007, P_NDC, NULL, "ndc-dpb-4000"}, |
| 1001 | { 0x07ce, 0xc007, P_NDC, NULL, "fujifilm-ask-4000"}, |
| 1002 | // DNP Q8? |
| 1003 | { 0x07ce, 0xc009, P_NDC, NULL, "ndc-dpb-6000"}, |
| 1004 | { 0x07ce, 0xc009, P_NDC, NULL, "fujifilm-ask-2000"}, // duplicate, has different IEEE1284 |
| 1005 | { 0x07ce, 0xc010, P_NDC, NULL, "ndc-dpb-7000"}, |
| 1006 | { 0x07ce, 0xc011, P_NDC, NULL, "fujifilm-ask-2500"}, |
| 1007 | { 0, 0, 0, NULL, NULL} |
| 1008 | }; |
| 1009 | |
| 1010 | const struct dyesub_backend sonyupd_backend = { |
| 1011 | .name = "Sony UP-D", |
| 1012 | .version = "0.56", |
| 1013 | .uri_prefixes = sonyupd_prefixes, |
| 1014 | .devices = sonyupd_devices, |
| 1015 | .cmdline_arg = upd_cmdline_arg, |
| 1016 | .cmdline_usage = upd_cmdline, |
| 1017 | .init = upd_init, |
| 1018 | .attach = upd_attach, |
| 1019 | .cleanup_job = upd_cleanup_job, |
| 1020 | .read_parse = upd_read_parse, |
| 1021 | .main_loop = upd_main_loop, |
| 1022 | .query_markers = upd_query_markers, |
| 1023 | }; |
| 1024 | |
| 1025 | /* Sony spool file format |
| 1026 | |
| 1027 | The spool file is a series of 4-byte commands, followed by optional |
| 1028 | arguments. The purpose of the commands is unknown, but they presumably |
| 1029 | instruct the driver to perform certain things. |
| 1030 | |
| 1031 | If you treat these 4 bytes as a 32-bit little-endian number, if any of the |
| 1032 | least significant 4 bits are non-zero, the value is is to |
| 1033 | be interpreted as a driver command. If the most significant bits are |
| 1034 | zero, the value signifies that the following N bytes of data should be |
| 1035 | sent to the printer as-is. |
| 1036 | |
| 1037 | Known driver "commands": |
| 1038 | |
| 1039 | 97 ff ff ff |
| 1040 | eb ff ff ff ?? 00 00 00 |
| 1041 | ec ff ff ff ?? 00 00 00 |
| 1042 | ed ff ff ff ?? 00 00 00 |
| 1043 | ee ff ff ff ?? 00 00 00 |
| 1044 | ef ff ff ff XX 00 00 00 # XX == print size (0x01/0x02/0x03/0x04) |
| 1045 | ef ff ff ff # On UP-D895/897 |
| 1046 | f3 ff ff ff |
| 1047 | f4 ff ff ff # End of job on UP-D897 |
| 1048 | f5 ff ff ff YY 00 00 00 # YY == ??? (seen 0x01) |
| 1049 | f7 ff ff ff # End of job on UP-D895 |
| 1050 | |
| 1051 | All printer commands start with 0x1b, and are at least 7 bytes long. |
| 1052 | General Command format: |
| 1053 | |
| 1054 | 1b XX ?? ?? LL LL 00 # XX is cmd, LL is data/response length, BE. |
| 1055 | |
| 1056 | If least significant bit of XX is 1, it is a WRITE, and LL is number of bytes of the payload. If LSB is 0, it is a READ, and printer will return LL bytes. |
| 1057 | |
| 1058 | UNKNOWN QUERY [possibly media?] |
| 1059 | |
| 1060 | <- 1b 03 00 00 00 13 00 |
| 1061 | -> 70 00 00 00 00 00 00 0b 00 00 00 00 00 00 00 00 |
| 1062 | 00 00 00 |
| 1063 | |
| 1064 | UNKNOWN CMD (UP-DR & SL10 & UP-D895 & UP-DP10 & DPB/ASK) [ possibly START? ] |
| 1065 | |
| 1066 | <- 1b 0a 00 00 00 00 00 |
| 1067 | |
| 1068 | IMAGE DIMENSIONS |
| 1069 | |
| 1070 | <- 1b 15 00 00 00 0d 00 |
| 1071 | <- 00 00 00 00 ZZ QQ QQ WW WW YY YY XX XX |
| 1072 | |
| 1073 | QQ/WW/YY/XX are (origin_cols/origin_rows/cols/rows) in BE. |
| 1074 | ZZ is 0x07 on UP-DR series, 0x01 on UP-D89x/711 series, 0x60 on Fujifilms |
| 1075 | |
| 1076 | RESET |
| 1077 | |
| 1078 | <- 1b 16 00 00 00 00 00 |
| 1079 | |
| 1080 | UNKNOWN CMD (UP-DR & SL & UP-D897, may be PRINT START?) |
| 1081 | |
| 1082 | <- 1b 17 00 00 00 00 00 |
| 1083 | |
| 1084 | UNKNOWN CMD |
| 1085 | |
| 1086 | <- 1b 1f 00 00 00 00 00 |
| 1087 | |
| 1088 | SET PARAM |
| 1089 | |
| 1090 | <- 1b c0 00 NN LL LL 00 # LL is response length, NN is number. |
| 1091 | <- [ LL bytes] |
| 1092 | |
| 1093 | QUERY PARAM |
| 1094 | |
| 1095 | <- 1b c1 00 NN LL LL 00 # LL is response length, NN is number. |
| 1096 | -> [ LL bytes ] |
| 1097 | |
| 1098 | PARAMS SEEN: |
| 1099 | 0c, len 5 [ 02 0c 00 01 XX ] XX == Long Feed Every XX pages (D711 only?) |
| 1100 | 0b, len 5 [ 02 0b 00 01 XX ] XX == Print Info (D711 only?) |
| 1101 | 0a, len 5 [ 02 0a 00 01 XX ] XX == Paper type (UP-D711 only?) |
| 1102 | 03, len 5 [ 02 03 00 01 XX ] (UPDR200, 00 = normal, 02 is multicut/div2 print, 01 seen at end of stream too.. |
| 1103 | 02, len 06 [ 02 02 00 03 00 00 ] |
| 1104 | 01, len 10 [ 02 01 00 06 00 02 00 00 00 00 ] (UP-D897/711) |
| 1105 | 00, len 5 [ 02 01 00 01 XX ] XX == Gamma table (89x/711 only?) |
| 1106 | |
| 1107 | STATUS QUERY |
| 1108 | |
| 1109 | <- 1b e0 00 00 XX XX 00 # XX = 0x000e (UP-D895 or NDC), 0x000f (All others) |
| 1110 | -> [14 or 15 bytes, see 'struct sony_updsts' ] |
| 1111 | |
| 1112 | PRINT PARAMETERS |
| 1113 | |
| 1114 | <- 1b e1 00 00 00 0b 00 |
| 1115 | <- 00 ZZ PP QQ QQ WW WW XX XX YY YY |
| 1116 | |
| 1117 | QQ == origin_cols, WW == origin_rows |
| 1118 | XX = cols, YY == rows |
| 1119 | ZZ == 0x04 on UP-DP10/DPB-xxxx/ASK-xxxx, 08 on UPD89x/77x, otherwise 0x80 |
| 1120 | PP == 00/01 for fast/slow (UPD711), 00 glossy, 08 texture (UP-DP10 + UP-DR150), 0c matte, +0x10 for "nocorrection" on UP-DR200.. |
| 1121 | |
| 1122 | UNKNOWN |
| 1123 | |
| 1124 | <- 1b e5 00 00 00 08 00 |
| 1125 | <- 00 00 00 00 00 00 00 XX 00 # Seen 01, 12, 0d, etc. |
| 1126 | |
| 1127 | UNKNOWN (UP-D897) |
| 1128 | |
| 1129 | <- 1b e6 00 00 00 08 00 |
| 1130 | -> 07 00 00 00 00 00 00 00 |
| 1131 | |
| 1132 | DATA TRANSFER |
| 1133 | |
| 1134 | <- 1b ea 00 00 00 00 ZZ ZZ ZZ ZZ 00 # ZZ is BIG ENDIAN |
| 1135 | <- [ ZZ ZZ ZZ ZZ bytes of data ] |
| 1136 | |
| 1137 | UNKNOWN CMD (UP-DR and UP-D) |
| 1138 | |
| 1139 | <- 1b ed 00 00 00 00 00 |
| 1140 | |
| 1141 | QUERY REMAINING PRINTS (UPDR series) |
| 1142 | |
| 1143 | <- 1b ef 00 00 00 06 00 |
| 1144 | -> 05 00 00 00 NN NN # NN NN print count on media remaining |
| 1145 | |
| 1146 | COPIES |
| 1147 | |
| 1148 | <- 1b ee 00 00 00 02 00 |
| 1149 | <- NN NN # Number of copies (BE, 1-???) |
| 1150 | |
| 1151 | UNKNOWN (UPDR series) |
| 1152 | |
| 1153 | <- 1b f5 00 00 00 02 00 |
| 1154 | <- ?? ?? |
| 1155 | |
| 1156 | UNKNOWN (Fujifilm ASK2000 series) |
| 1157 | |
| 1158 | <- 1b 23 00 00 00 04 00 |
| 1159 | <- ff ff ff ff |
| 1160 | |
| 1161 | UNKNOWN (Fujifilm ASK2000/4000 series) |
| 1162 | |
| 1163 | <- 1b 1e 00 00 00 0c 00 |
| 1164 | 00 00 00 00 00 00 00 00 00 00 00 00 |
| 1165 | |
| 1166 | ************************************************************************ |
| 1167 | |
| 1168 | The data stream sent to the printer consists of all the commands in the |
| 1169 | spool file, plus a couple other ones that generate responses. It is |
| 1170 | unknown if those additional commands are necessary. This is a typical |
| 1171 | sequence: |
| 1172 | |
| 1173 | [[ Sniff start of a UP-DR150 ]] |
| 1174 | |
| 1175 | <- 1b e0 00 00 00 0f 00 [ STATUS QUERY ] |
| 1176 | -> 0e 00 00 00 00 00 00 00 04 a8 08 00 0a a4 00 |
| 1177 | ----- ----- |
| 1178 | MAX_C MAX_R |
| 1179 | <- 1b 16 00 00 00 00 00 |
| 1180 | -> "reset" ?? |
| 1181 | |
| 1182 | [[ begin job ]] |
| 1183 | |
| 1184 | <- 1b ef 00 00 00 06 00 |
| 1185 | -> 05 00 00 00 00 22 |
| 1186 | |
| 1187 | <- 1b e5 00 00 00 08 00 ** In spool file |
| 1188 | <- 00 00 00 00 00 00 01 00 |
| 1189 | |
| 1190 | <- 1b c1 00 02 06 00 00 [ Query Param 2, length 6 ] |
| 1191 | -> 02 02 00 03 00 00 |
| 1192 | |
| 1193 | <- 1b ee 00 00 00 02 00 ** In spool file |
| 1194 | <- 00 01 |
| 1195 | |
| 1196 | <- 1b 15 00 00 00 0d 00 ** In spool file |
| 1197 | <- 00 00 00 00 07 00 00 00 00 08 00 0a a4 |
| 1198 | |
| 1199 | <- 1b 03 00 00 00 13 00 |
| 1200 | -> 70 00 00 00 00 00 00 0b 00 00 00 00 00 00 00 00 |
| 1201 | 00 00 00 |
| 1202 | |
| 1203 | <- 1b e1 00 00 00 0b 00 ** In spool file |
| 1204 | <- 00 80 00 00 00 00 00 08 00 0a a4 |
| 1205 | |
| 1206 | <- 1b 03 00 00 00 13 00 |
| 1207 | -> 70 00 00 00 00 00 00 0b 00 00 00 00 00 00 00 00 |
| 1208 | 00 00 00 |
| 1209 | |
| 1210 | <- 1b ea 00 00 00 00 00 ff 60 00 00 ** In spool file |
| 1211 | <- [[ 0x0060ff00 bytes of data ]] |
| 1212 | |
| 1213 | <- 1b e0 00 00 00 0f 00 |
| 1214 | -> 0e 00 00 00 00 00 00 00 04 a8 08 00 0a a4 00 |
| 1215 | |
| 1216 | <- 1b 0a 00 00 00 00 00 ** In spool file, marks end of file? |
| 1217 | <- 1b 17 00 00 00 00 00 ** In spool file |
| 1218 | |
| 1219 | [[fin]] |
| 1220 | |
| 1221 | ************** |
| 1222 | |
| 1223 | Sony UP-CL10 / DNP SL-10 / UP-CX1 spool format: |
| 1224 | |
| 1225 | 60 ff ff ff |
| 1226 | f8 ff ff ff |
| 1227 | fd ff ff ff (or: f0 ff ff ff) |
| 1228 | 14 00 00 00 |
| 1229 | 1b 15 00 00 00 0d 00 00 00 00 00 07 00 00 00 00 WW WW HH HH |
| 1230 | fb ff ff ff |
| 1231 | f4 ff ff ff |
| 1232 | 0b 00 00 00 |
| 1233 | 1b ea 00 00 00 00 SH SH SH SH 00 |
| 1234 | SL SL SL SL |
| 1235 | |
| 1236 | [[ Data, rows * cols * 3 bytes ]] |
| 1237 | |
| 1238 | f3 ff ff ff |
| 1239 | 0f 00 00 00 |
| 1240 | 1b e5 00 00 00 08 00 00 00 00 00 00 00 00 00 |
| 1241 | 12 00 00 00 |
| 1242 | 1b e1 00 00 00 0b 00 00 80 GG 00 00 00 00 WW WW HH HH |
| 1243 | fa ff ff ff |
| 1244 | 09 00 00 00 |
| 1245 | 1b ee 00 00 00 02 00 00 NN |
| 1246 | 07 00 00 00 |
| 1247 | 1b 0a 00 00 00 00 00 |
| 1248 | f9 ff ff ff |
| 1249 | fc ff ff ff |
| 1250 | 07 00 00 00 |
| 1251 | 1b 17 00 00 00 00 00 |
| 1252 | f7 ff ff ff |
| 1253 | |
| 1254 | WW WW == Columns, Big Endian |
| 1255 | HH HH == Rows, Big Endian |
| 1256 | SL SL SL SL == Plane size, Little Endian (Rows * Cols * 3) |
| 1257 | SH SH SH SH == Plane size, Big Endian (Rows * Cols * 3) |
| 1258 | NN == Copies |
| 1259 | GG == Overcoat, 0x00 glossy, 0x0c matte (UP-CX1 only) |
| 1260 | |
| 1261 | ************** |
| 1262 | |
| 1263 | Sony UP-D895 spool format: |
| 1264 | |
| 1265 | XX XX == cols, BE (fixed at 1280/0x500) |
| 1266 | YY YY == rows, BE (798/0x031e,1038/0x040e,1475/0x05c3, 2484/09b4) @ 960/1280/1920/3840+4096 |
| 1267 | SS SS SS SS == data len (rows * cols, LE) |
| 1268 | S' S' S' S' == data len (rows * cols, BE) |
| 1269 | NN == copies (1 -> ??) |
| 1270 | GG GG == ??? 0000/0050/011b/04aa/05aa at each resolution. |
| 1271 | G' == Gamma 01 (soft), 03 (hard), 02 (normal) |
| 1272 | |
| 1273 | 9c ff ff ff 97 ff ff ff 00 00 00 00 00 00 00 00 00 00 00 00 ff ff ff ff |
| 1274 | |
| 1275 | 14 00 00 00 |
| 1276 | 1b 15 00 00 00 0d 00 00 00 00 00 01 GG GG 00 00 YY YY XX XX |
| 1277 | 0b 00 00 00 |
| 1278 | 1b ea 00 00 00 00 S' S' S' S' 00 |
| 1279 | SS SS SS SS |
| 1280 | ...DATA... (rows * cols) |
| 1281 | ff ff ff ff |
| 1282 | 09 00 00 00 |
| 1283 | 1b ee 00 00 00 02 00 00 NN |
| 1284 | 0f 00 00 00 |
| 1285 | 1b e5 00 00 00 08 00 00 00 00 00 00 00 00 00 |
| 1286 | 0c 00 00 00 |
| 1287 | 1b c0 00 00 00 05 00 02 00 00 01 G' |
| 1288 | 11 00 00 00 |
| 1289 | 1b c0 00 01 00 0a 00 02 01 00 06 00 00 00 00 00 00 |
| 1290 | 12 00 00 00 |
| 1291 | 1b e1 00 00 00 0b 00 00 08 00 GG GG 00 00 YY YY XX XX |
| 1292 | 07 00 00 00 |
| 1293 | 1b 0a 00 00 00 00 00 |
| 1294 | fd ff ff ff f7 ff ff ff f8 ff ff ff |
| 1295 | |
| 1296 | ************** |
| 1297 | |
| 1298 | Sony UP-D897 spool format: |
| 1299 | |
| 1300 | NN NN == copies (00 for printer selected) |
| 1301 | XX XX == cols (fixed @ 1280) |
| 1302 | YY YY == rows |
| 1303 | GG == gamma -- Table 2 == 2, Table 1 == 3, Table 3 == 1, Table 4 == 4 |
| 1304 | DD == "dark" +- 64. |
| 1305 | LL == "light" +- 64. |
| 1306 | AA == "advanced" +- 32. |
| 1307 | SS == Sharpness 0-14 |
| 1308 | ZZ ZZ ZZ ZZ == Data length (BE) |
| 1309 | Z` Z` Z` Z` == Data length (LE) |
| 1310 | |
| 1311 | |
| 1312 | 83 ff ff ff fc ff ff ff |
| 1313 | fb ff ff ff f5 ff ff ff |
| 1314 | f1 ff ff ff f0 ff ff ff |
| 1315 | ef ff ff ff |
| 1316 | |
| 1317 | 14 00 00 00 |
| 1318 | 1b 15 00 00 00 0d 00 00 00 00 00 01 00 a2 00 00 YY YY XX XX |
| 1319 | |
| 1320 | 0b 00 00 00 |
| 1321 | 1b ea 00 00 00 00 ZZ ZZ ZZ ZZ 00 |
| 1322 | |
| 1323 | Z` Z` Z` Z` |
| 1324 | ...DATA... |
| 1325 | |
| 1326 | ea ff ff ff |
| 1327 | |
| 1328 | 09 00 00 00 |
| 1329 | 1b ee 00 00 00 02 00 NN NN |
| 1330 | |
| 1331 | ee ff ff ff 01 00 00 00 |
| 1332 | |
| 1333 | 0e 00 00 00 |
| 1334 | 1b e5 00 00 00 08 00 00 00 00 00 DD LL SS AA |
| 1335 | |
| 1336 | eb ff ff ff ?? 00 00 00 <--- 02/05 5 at #3, 2 otherwise. Sharpness? |
| 1337 | |
| 1338 | 0c 00 00 00 |
| 1339 | 1b c0 00 00 00 05 00 02 00 00 01 GG |
| 1340 | |
| 1341 | ec ff ff ff ?? 00 00 00 <--- 01/00/02/01/01 Seen. Unknown. |
| 1342 | |
| 1343 | 11 00 00 00 |
| 1344 | 1b c0 00 01 00 0a 00 02 01 00 06 00 00 00 00 00 00 |
| 1345 | |
| 1346 | ed ff ff ff 00 00 00 00 |
| 1347 | |
| 1348 | 12 00 00 00 |
| 1349 | 1b e1 00 00 00 0b 00 00 08 00 00 a2 00 00 YY YY XX XX |
| 1350 | |
| 1351 | fa ff ff ff |
| 1352 | |
| 1353 | 07 00 00 00 |
| 1354 | 1b 0a 00 00 00 00 00 |
| 1355 | |
| 1356 | fc ff ff ff fd ff ff ff ff ff ff ff |
| 1357 | |
| 1358 | 07 00 00 00 |
| 1359 | 1b 17 00 00 00 00 00 |
| 1360 | |
| 1361 | f4 ff ff ff |
| 1362 | |
| 1363 | **************** |
| 1364 | |
| 1365 | Sony UP-D711 spool format: |
| 1366 | |
| 1367 | NN NN == copies (00 for printer selected) |
| 1368 | XX XX == cols (fixed @ 896) |
| 1369 | YY YY == rows |
| 1370 | GG == gamma -- Table 2 == 2, Table 1 == 3, Table 3 == 1, Table 4 == 4 |
| 1371 | DD == "dark" +- 64. |
| 1372 | LL == "light" +- 64. |
| 1373 | AA == "advanced" +- 32. |
| 1374 | SS == Sharpness 0-14 |
| 1375 | PP == Paper type (S = 00, HG = 01) |
| 1376 | KK == Long Feed every KK prints, 00 disables. |
| 1377 | RR == Speed (00 - Low, 01 = High) |
| 1378 | PI == Print Info (01 - Yes, 00 - No) |
| 1379 | |
| 1380 | ZZ ZZ ZZ ZZ == Data length (BE) |
| 1381 | Z` Z` Z` Z` == Data length (LE) |
| 1382 | |
| 1383 | 83 ff ff ff fc ff ff ff |
| 1384 | fb ff ff ff f5 ff ff ff |
| 1385 | |
| 1386 | 07 00 00 00 |
| 1387 | 1b 15 00 00 00 0d 00 |
| 1388 | |
| 1389 | 0d 00 00 00 |
| 1390 | 00 00 00 00 01 01 43 00 00 XX XX YY YY |
| 1391 | |
| 1392 | 0b 00 00 00 |
| 1393 | |
| 1394 | 1b ea 00 00 00 00 ZZ ZZ ZZ ZZ 00 |
| 1395 | Z` Z` Z` Z` |
| 1396 | ...DATA... |
| 1397 | |
| 1398 | ea ff ff ff |
| 1399 | |
| 1400 | 07 00 00 00 |
| 1401 | 1b ee 00 00 00 02 00 |
| 1402 | 02 00 00 00 |
| 1403 | NN NN |
| 1404 | |
| 1405 | ee ff ff ff 01 00 00 00 |
| 1406 | |
| 1407 | 07 00 00 00 |
| 1408 | 1b e5 00 00 00 08 00 |
| 1409 | 08 00 00 00 |
| 1410 | 00 00 00 00 DD LL SS AA |
| 1411 | |
| 1412 | eb ff ff ff 02 00 00 00 |
| 1413 | |
| 1414 | 07 00 00 00 |
| 1415 | 1b c0 00 00 00 05 00 |
| 1416 | 05 00 00 00 |
| 1417 | 02 00 00 01 GG |
| 1418 | |
| 1419 | ec ff ff ff PI 00 00 00 |
| 1420 | |
| 1421 | 07 00 00 00 |
| 1422 | 1b c0 00 01 00 0a 00 |
| 1423 | 0a 00 00 00 |
| 1424 | 02 01 00 06 00 00 00 00 00 00 |
| 1425 | |
| 1426 | ed ff ff ff 00 00 00 00 |
| 1427 | |
| 1428 | 07 00 00 00 |
| 1429 | 1b c0 00 0a 00 05 00 |
| 1430 | 05 00 00 00 |
| 1431 | 02 0a 00 01 PP |
| 1432 | |
| 1433 | 07 00 00 00 |
| 1434 | 1b c0 00 0c 00 05 00 |
| 1435 | 05 00 00 00 |
| 1436 | 02 0c 00 01 KK |
| 1437 | |
| 1438 | 07 00 00 00 |
| 1439 | 1b c0 00 0b 00 05 00 |
| 1440 | 05 00 00 00 |
| 1441 | 02 0b 00 01 PI |
| 1442 | |
| 1443 | 07 00 00 00 |
| 1444 | 1b e1 00 00 00 0b 00 |
| 1445 | 0b 00 00 00 |
| 1446 | 00 08 RR 01 43 00 00 XX XX YY YY |
| 1447 | |
| 1448 | fa ff ff ff |
| 1449 | |
| 1450 | 07 00 00 00 |
| 1451 | 1b 0a 00 00 00 00 00 |
| 1452 | |
| 1453 | fc ff ff ff fd ff ff ff |
| 1454 | ff ff ff ff |
| 1455 | |
| 1456 | 07 00 00 00 |
| 1457 | 1b 17 00 00 00 00 00 |
| 1458 | |
| 1459 | f4 ff ff ff |
| 1460 | |
| 1461 | **************** |
| 1462 | |
| 1463 | UP-D895 comms protocol: |
| 1464 | |
| 1465 | <-- 1b e0 00 00 00 0e 00 |
| 1466 | --> 0d 00 XX YY 00 SS 00 ZZ 00 00 RR RR CC CC |
| 1467 | |
| 1468 | RR : Max rows |
| 1469 | CC : Max columns (fixed at 0x0500/1280) |
| 1470 | XX : 0xe0 when printing, 0x00 otherwise. |
| 1471 | YY : Number of remaining copies |
| 1472 | SS : Status |
| 1473 | 0x00 = Idle |
| 1474 | 0x08 = Door open |
| 1475 | 0x40 = Paper empty |
| 1476 | 0x80 = Printing |
| 1477 | ?? = Cooling down |
| 1478 | ?? = Busy / Waiting |
| 1479 | ZZ : Status2 |
| 1480 | 0x01 = Print complete |
| 1481 | 0x02 = no prints yet |
| 1482 | |
| 1483 | UP-D897 comms protocol: |
| 1484 | |
| 1485 | <-- 1b e0 00 00 00 0f 00 |
| 1486 | --> 0e 00 XX YY 00 SS TT 01 02 02 RR RR CC CC PP |
| 1487 | |
| 1488 | RR : Max rows |
| 1489 | CC : Max columns (fixed at 0x0500/1280) |
| 1490 | XX : 0xe0 when printing, 0x00 otherwise. |
| 1491 | YY : Number of remaining copies |
| 1492 | SS : Status |
| 1493 | 0x00 = Idle |
| 1494 | ?? 0x08 = Door open |
| 1495 | 0x40 = Paper empty |
| 1496 | 0x80 = Printing |
| 1497 | ?? = Cooling down |
| 1498 | ?? = Busy / Waiting |
| 1499 | TT : Status 2 |
| 1500 | 0x00 = Okay |
| 1501 | 0x08 = ?? Error state? |
| 1502 | 0x80 = Printing |
| 1503 | PP : Percentage complete (0-99) |
| 1504 | |
| 1505 | UP-D711 comms protocol: |
| 1506 | |
| 1507 | <-- 1b e0 00 00 00 0f 00 |
| 1508 | --> 0e 00 XX YY SS 00 TT 01 02 02 RR RR CC CC PP |
| 1509 | |
| 1510 | RR : Max rows |
| 1511 | CC : Max columns (fixed at 0x380/896) |
| 1512 | XX : 0xe0 when printing, 0x00 otherwise. |
| 1513 | YY : Number of remaining copies |
| 1514 | SS : Status |
| 1515 | 0x00 = Idle |
| 1516 | 0x08 = Paper empty |
| 1517 | 0x40 = Door open |
| 1518 | ?? 0x80 = Printing |
| 1519 | ?? = Cooling down |
| 1520 | ?? = Busy / Waiting |
| 1521 | ?? TT : Status 2 |
| 1522 | 0x00 = Okay |
| 1523 | 0x08 = ?? Error state? |
| 1524 | 0x80 = Printing |
| 1525 | PP : Percentage complete (0-99) |
| 1526 | |
| 1527 | Other commands seen: |
| 1528 | |
| 1529 | <-- 1b 16 00 00 00 00 00 -- Reset |
| 1530 | |
| 1531 | <-- 1b c1 00 01 00 0a 00 -- Query ID 1, legth 10 |
| 1532 | --> 02 01 00 06 00 02 00 00 00 00 |
| 1533 | |
| 1534 | <-- 1b c1 00 00 00 05 00 -- Query id 0, length 5 |
| 1535 | --> 02 01 00 01 03 |
| 1536 | |
| 1537 | <-- 1b e6 00 00 00 08 00 |
| 1538 | --> 07 00 00 00 00 00 00 00 |
| 1539 | |
| 1540 | <-- 1b 17 00 00 00 00 00 -- Unknown? |
| 1541 | |
| 1542 | CR10L: status progression when printing: |
| 1543 | |
| 1544 | 0e 00 00 00 00 00 00 00 04 a0 04 e0 07 38 00 |
| 1545 | 0e 00 00 01 00 80 00 01 04 a0 04 e0 07 38 64 |
| 1546 | 0e 00 40 01 00 80 00 01 04 a0 04 e0 07 38 64 <-- Y |
| 1547 | 0e 00 80 01 00 80 00 01 04 a0 04 e0 07 38 64 <-- M |
| 1548 | 0e 00 c0 01 00 80 00 01 04 a0 04 e0 07 38 64 <-- C |
| 1549 | 0e 00 20 01 00 80 00 01 04 a0 04 e0 07 38 64 <-- O |
| 1550 | 0e 00 20 01 00 80 00 01 04 a0 04 e0 07 38 00 |
| 1551 | 0e 00 00 01 00 80 00 01 04 a0 04 e0 07 38 00 |
| 1552 | 0e 00 00 00 00 00 00 00 04 a0 04 e0 07 38 00 |
| 1553 | |
| 1554 | UP-DR200 comms protocol: |
| 1555 | |
| 1556 | <-- 1b e0 00 00 00 0f 00 |
| 1557 | --> 0e 00 XX NN E0 E1 00 E3 RT PT CC CC RR RR %% |
| 1558 | |
| 1559 | XX : Print state (eg Y/M/C/O -- see UPD_PRINTING_* ) |
| 1560 | E0 : Error code0 (see UPD_STS0_*) |
| 1561 | E1 : Error code1 (see UPD_STS1_*) |
| 1562 | E3 : Unknown (00 or 01) |
| 1563 | NN : Number of remaining copies (00 when complete/idle) |
| 1564 | CC : Max Cols (0x0800 on 6" ribbon) |
| 1565 | RR : Max Rows (0x0aa4 on 6x8) |
| 1566 | RT : Ribbon type (04 = R206/8x6) |
| 1567 | PT : Paper type (38 = empty, a8 = 6") |
| 1568 | %% : Percentage complete (0-99) |
| 1569 | |
| 1570 | Seen on UP-DR200: |
| 1571 | |
| 1572 | 0e 00 00 00 00 00 00 00 04 a8 08 00 0a a4 00 READY (R206 6x8 ribbon) |
| 1573 | 0e 00 00 00 40 00 00 00 04 a8 08 00 0a a4 00 DOOR OPEN |
| 1574 | 0e 00 00 00 20 00 00 00 04 38 08 00 0a a4 00 LOAD PAPER |
| 1575 | 0e 00 00 00 10 08 00 00 00 a8 08 00 0a a4 00 LOAD RIBBON |
| 1576 | |
| 1577 | 0e 00 00 01 00 c0 00 01 04 a8 08 00 0a a4 00 PRINT START |
| 1578 | 0e 00 40 01 00 c0 00 01 04 a8 08 00 0a a4 %% PRINT Y |
| 1579 | 0e 00 80 01 00 c0 00 01 04 a8 08 00 0a a4 %% PRINT M |
| 1580 | 0e 00 c0 01 00 c0 00 01 04 a8 08 00 0a a4 %% PRINT C |
| 1581 | 0e 00 20 01 00 c0 00 01 04 a8 08 00 0a a4 %% PRINT OC |
| 1582 | 0e 00 00 00 00 00 00 00 04 a8 08 00 0a a4 00 PRINT DONE / READY |
| 1583 | |
| 1584 | */ |