| 1 | /* |
| 2 | * Kodak 8800/9810 Photo Printer CUPS backend |
| 3 | * |
| 4 | * (c) 2021-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 kodak8800_backend |
| 28 | |
| 29 | #include "backend_common.h" |
| 30 | |
| 31 | /* EK8800 command structures */ |
| 32 | struct rtp1_req { |
| 33 | uint8_t hdr[4]; /* "RTP1" */ |
| 34 | uint8_t cmd[4]; |
| 35 | uint32_t max_resplen; /* BE */ |
| 36 | uint32_t payload_len; /* BE */ |
| 37 | uint8_t payload[]; |
| 38 | }; |
| 39 | |
| 40 | struct rtp1_sts { |
| 41 | uint8_t base[2]; // x10 x10 or x10 x12 ? (10 == ok, 12 == error?) |
| 42 | uint16_t err; /* see kodak8800_errorstr() */ |
| 43 | uint8_t sts[4]; // [0] STATE_* [2] PRINT_* |
| 44 | }; |
| 45 | |
| 46 | struct rtp1_resp { |
| 47 | uint8_t hdr[4]; /* "RTP1" */ |
| 48 | uint8_t cmd[4]; |
| 49 | struct rtp1_sts sts; |
| 50 | uint32_t payload_len; /* BE */ |
| 51 | uint8_t payload[]; |
| 52 | }; |
| 53 | |
| 54 | #define STS_OK 0x10 |
| 55 | #define STS_ERR 0x12 |
| 56 | #define STS_ERR2 0x13 // Not sure what's different |
| 57 | |
| 58 | #define STATE_IDLE 0x00 |
| 59 | #define STATE_UNK 0x01 // XXX |
| 60 | #define STATE_PRINT 0x02 |
| 61 | |
| 62 | #define PRINT_IDLE 0x00 |
| 63 | #define PRINT_FEED 0x01 |
| 64 | #define PRINT_Y 0x02 |
| 65 | #define PRINT_M 0x03 |
| 66 | #define PRINT_C 0x04 |
| 67 | #define PRINT_O 0x05 |
| 68 | #define PRINT_EJECT 0x06 |
| 69 | |
| 70 | struct rtp1_counters { |
| 71 | uint32_t cutter_count; |
| 72 | uint32_t prints_finished; |
| 73 | uint32_t ribbon_head; // units of 300dpi (ie val / 300 == inches) |
| 74 | uint32_t paper_total; // uints of 300dpi |
| 75 | uint32_t prints_started; |
| 76 | }; |
| 77 | |
| 78 | struct rtp1_errorrecord { |
| 79 | uint8_t type; // ERROR_TYPE_* |
| 80 | uint16_t code; |
| 81 | uint8_t plane; // 0-3 |
| 82 | uint32_t printnum; |
| 83 | uint32_t ribbonnum; |
| 84 | uint32_t papernum; |
| 85 | } __attribute__((packed)); |
| 86 | |
| 87 | #define ERROR_TYPE_END 0x00 |
| 88 | #define ERROR_TYPE_USER 0x12 |
| 89 | #define ERROR_TYPE_SERVICE 0x13 |
| 90 | |
| 91 | #define NUM_ERRORRECS 32 |
| 92 | |
| 93 | struct rtp1_errorlog { |
| 94 | struct rtp1_errorrecord row[NUM_ERRORRECS]; |
| 95 | }; |
| 96 | |
| 97 | struct rtp1_mediastatus { |
| 98 | uint8_t unk[4]; // 00 01 00 02 00 01 00 01 |
| 99 | // 00 03 00 06 00 01 00 01 <<-- error state? |
| 100 | // 00 ff 00 02 00 01 00 01 |
| 101 | uint16_t media_type; // 00 01 (YMCX 8x10 Glossy) |
| 102 | uint16_t paper_type; // 00 01 (8") |
| 103 | uint32_t ribbon_remain; /* inches */ // also seen 00 0b ff f4 for error state |
| 104 | uint32_t paper_remain; /* in inches */ |
| 105 | }; |
| 106 | |
| 107 | /* These are guesses */ |
| 108 | #define PAPER_TYPE_7 0x01 |
| 109 | #define PAPER_TYPE_8 0x02 |
| 110 | #define PAPER_TYPE_8_5 0x03 |
| 111 | #define PAPER_TYPE_A4 0x04 |
| 112 | |
| 113 | #define MEDIA_TYPE_8x10_G 0x01 |
| 114 | #define MEDIA_TYPE_8x10_M 0x02 |
| 115 | #define MEDIA_TYPE_8x12_G 0x03 |
| 116 | #define MEDIA_TYPE_8x12_M 0x04 |
| 117 | |
| 118 | struct rtp1_serial { |
| 119 | uint8_t serial[64]; |
| 120 | }; |
| 121 | |
| 122 | struct rtp1_mfgmodel { |
| 123 | uint8_t mfg[64]; |
| 124 | uint8_t model[64]; |
| 125 | uint8_t serial[64]; |
| 126 | uint8_t fwver[64]; |
| 127 | }; |
| 128 | |
| 129 | struct rtp1_fwvers { |
| 130 | uint8_t dsp[12]; |
| 131 | uint8_t eng[12]; |
| 132 | uint8_t system[12]; |
| 133 | uint8_t head[12]; |
| 134 | uint8_t reset[12]; |
| 135 | }; |
| 136 | |
| 137 | struct rtp1_sensors { |
| 138 | uint8_t unk[6]; |
| 139 | // -> 02 00 06 2a ff 00 |
| 140 | // -> 02 00 06 2a ff 00 |
| 141 | // -> 10 00 02 2a ff 00 |
| 142 | uint8_t head_temp; |
| 143 | uint8_t head_temp_target; |
| 144 | }; |
| 145 | |
| 146 | const uint8_t rtp_sendimagedata[4] = { 0x00, 0x00, 0x00, 0x00 }; /* Resp len 0 */ |
| 147 | const uint8_t rtp_getmaxxfer[4] = { 0x01, 0x00, 0x00, 0x00 }; /* Resp len 4 (u32) */ |
| 148 | const uint8_t rtp_getstatus[4] = { 0x06, 0x00, 0x00, 0x00 }; /* Resp len 0 */ |
| 149 | const uint8_t rtp_getjobstatus[4] = { 0x06, 0x03, 0x00, 0x00 }; /* Req len 4, resp 14 XXX */ |
| 150 | const uint8_t rtp_getjobqstatus[4] = { 0x06, 0x05, 0x00, 0x00 }; /* Req len 4, resp 14 XXX */ |
| 151 | const uint8_t rtp_getmedia[4] = { 0x06, 0x40, 0x00, 0x00 }; /* Resp len 16 (rtp1_mediastatus) */ |
| 152 | const uint8_t rtp_getsensors[4] = { 0x06, 0x80, 0x00, 0x00 }; /* Resp len 8 (rtp1_sensors */ |
| 153 | const uint8_t rtp_getusererrors[4] = { 0x0c, 0x01, 0x00, 0x00 }; /* Resp len 512 (rtp1_errorlog) */ |
| 154 | const uint8_t rtp_getserverrors[4] = { 0x0c, 0x02, 0x00, 0x00 }; /* Resp len 512 (rtp1_errorlog) */ |
| 155 | const uint8_t rtp_getifaceerrors[4] = { 0x0c, 0x03, 0x00, 0x00 }; /* Resp len 512 (rtp1_errorlog) */ |
| 156 | const uint8_t rtp_openjob[4] = { 0x10, 0x00, 0x00, 0x00 }; /* Resp len 4 (u32) */ |
| 157 | const uint8_t rtp_closejob[4] = { 0x11, 0x00, 0x00, 0x00 }; /* Resp len 0 */ |
| 158 | const uint8_t rtp_canceljob[4] = { 0x12, 0x00, 0x00, 0x00 }; /* Resp len 0 */ |
| 159 | const uint8_t rtp_canceljobid[4] = { 0x12, 0x01, 0x00, 0x00 }; /* Req len 4, Resp len 0 */ |
| 160 | const uint8_t rtp_getmfgmodel[4] = { 0x13, 0x00, 0x00, 0x00 }; /* Resp len 256 (rtp1_mfgmodel) */ |
| 161 | const uint8_t rtp_getfwversions[4] = { 0x13, 0x80, 0x00, 0x00 }; /* Resp len 60 (rtp1_fwvers) */ |
| 162 | const uint8_t rtp_getserial[4] = { 0x81, 0x01, 0x00, 0x00 }; /* Resp len 64 (rtp1_serial) */ |
| 163 | const uint8_t rtp_getserialhead[4] = { 0x81, 0x01, 0x01, 0x00 }; /* Resp len 64 (rtp1_serial) */ |
| 164 | const uint8_t rtp_getcounters[4] = { 0x81, 0x04, 0x00, 0x00 }; /* Resp len 20 (rtp1_counters) */ |
| 165 | |
| 166 | // *** XXX cut & page alignment, media total? |
| 167 | // plus state of cutter, cover, ribbon panel position, etc.. |
| 168 | |
| 169 | struct rosetta_header { |
| 170 | uint8_t esc; |
| 171 | uint8_t hdr[15]; /* "MndROSETTA V001" */ |
| 172 | uint8_t payload[44]; |
| 173 | }; |
| 174 | |
| 175 | struct rosetta_block { |
| 176 | uint8_t esc; |
| 177 | uint8_t cmd[19]; /* ascii, space-padded */ |
| 178 | uint8_t zero[4]; |
| 179 | uint32_t payload_len; /* BE */ |
| 180 | uint8_t payload[]; |
| 181 | }; |
| 182 | |
| 183 | /* Private data structure */ |
| 184 | struct kodak8800_printjob { |
| 185 | struct dyesub_job_common common; |
| 186 | |
| 187 | int copies_offset; |
| 188 | uint8_t *databuf; |
| 189 | }; |
| 190 | |
| 191 | struct kodak8800_ctx { |
| 192 | struct dyesub_connection *conn; |
| 193 | |
| 194 | uint8_t jobid; |
| 195 | |
| 196 | char serial[32]; |
| 197 | char fwver[32]; |
| 198 | |
| 199 | struct marker marker; |
| 200 | }; |
| 201 | |
| 202 | static const char* kodak8800_errorstrs(uint16_t error) |
| 203 | { |
| 204 | switch (error) { |
| 205 | case 0x0105: return "Unknown 0105"; // seen after issuing START command with a bogus job |
| 206 | case 0x0203: return "Job not Open"; |
| 207 | case 0x0307: return "Command Disabled"; |
| 208 | case 0x0420: return "Ribbon too Short"; |
| 209 | case 0x0503: return "Operating System"; |
| 210 | case 0x0504: return "Cover Open"; |
| 211 | case 0x2001: return "Check Ribbon"; |
| 212 | // case 0x2002: return "Out of Paper"; |
| 213 | // case 0x2003: return "Ribbon Jammed"; |
| 214 | case 0x2004: return "Ribbon Access Door Open"; |
| 215 | // case 0x2005: return "Paper Access Door open"; |
| 216 | // case 0x2006: return "Cutter Jammed"; |
| 217 | // case 0x2007: return "Ribbon Failed to Advance"; |
| 218 | // case 0x2008: return "Ribbon Failed to Rewind"; |
| 219 | // case 0x2009: return "Paper Failed to Advance"; |
| 220 | // case 0x200a: return "Paper Failed to Rewind"; |
| 221 | // case 0x200b: return "Invalid Ribbon Barcode Type"; |
| 222 | // case 0x200c: return "Head Error"; |
| 223 | // case 0x200d: return "Invalid Head Position"; |
| 224 | // case 0x200e: return "Cooling Timeout Failure"; |
| 225 | // case 0x200f: return "Heating Timeout Failure"; |
| 226 | // 2040-2043 == "Ribbon Error" ? |
| 227 | // 2044 == "paper feed" ? |
| 228 | case 0x4302: return "Engine Protocol"; |
| 229 | // case 0x4303: return "Engine Command not Valid"; |
| 230 | // case 0x4304: return "Undefined Engine Command"; |
| 231 | // case 0x4305: return "Failure to Program Engine Flash"; |
| 232 | // case 0x4306: return "Engine Powering Up"; |
| 233 | // case 0x4307: return "VM Range"; |
| 234 | // case 0x4307: return "Ribbon ADC"; |
| 235 | // case 0x4309: return "Cam Homing"; |
| 236 | case 0x430a: return "Barcode Sensor"; |
| 237 | // case 0x430b: return "Unknown RTP"; |
| 238 | // case 0x430c: return "Device not Responding"; |
| 239 | // case 0x430d: return "Bad RTP Response Signature"; |
| 240 | // case 0x430e: return "Bad RTP Command Echo"; |
| 241 | // 8002 == printer not responding ? |
| 242 | case 0xff01: return "Unknown ff01"; // seen in interface log |
| 243 | case 0xff02: return "Host Read (instead of write)"; |
| 244 | case 0xff04: return "Unknown ff04"; // seen after issuing bad CANCELJOB |
| 245 | case 0xffff: return "Unknown ffff"; // seen in interface log |
| 246 | default: |
| 247 | return "Unknown"; |
| 248 | } |
| 249 | } |
| 250 | |
| 251 | /* Helper Functions */ |
| 252 | static int rtp1_docmd(struct kodak8800_ctx *ctx, const uint8_t *cmd, |
| 253 | const uint8_t *payload, uint32_t payload_len, |
| 254 | uint32_t maxresp_len, uint8_t *respbuf, struct rtp1_sts *sts) |
| 255 | { |
| 256 | int ret; |
| 257 | int num; |
| 258 | struct rtp1_req req; |
| 259 | struct rtp1_resp resp; |
| 260 | |
| 261 | /* Fill in header */ |
| 262 | req.hdr[0] = 'R'; |
| 263 | req.hdr[1] = 'T'; |
| 264 | req.hdr[2] = 'P'; |
| 265 | req.hdr[3] = '1'; |
| 266 | memcpy(req.cmd, cmd, sizeof(req.cmd)); |
| 267 | req.max_resplen = cpu_to_be32(maxresp_len); |
| 268 | req.payload_len = cpu_to_be32(payload_len); |
| 269 | |
| 270 | /* Send over cmd structure */ |
| 271 | if ((ret = send_data(ctx->conn, (uint8_t*) &req, |
| 272 | sizeof(req))) != 0) |
| 273 | return ret; |
| 274 | |
| 275 | /* Send over payload, if any */ |
| 276 | if (payload_len) |
| 277 | if ((ret = send_data(ctx->conn, payload, |
| 278 | payload_len)) != 0) |
| 279 | return ret; |
| 280 | |
| 281 | /* Read response header */ |
| 282 | int try = 0; |
| 283 | retry: |
| 284 | ret = read_data(ctx->conn, (uint8_t*) &resp, |
| 285 | sizeof(resp), &num); |
| 286 | if (try == 0 && num == 0) { |
| 287 | try = 1; |
| 288 | goto retry; |
| 289 | } |
| 290 | if (num != (int)sizeof(resp)) { |
| 291 | ERROR("Short Read! (%d/%d)\n", num, (int)sizeof(resp)); |
| 292 | ret = -4; |
| 293 | goto done; |
| 294 | } |
| 295 | |
| 296 | |
| 297 | /* Copy over the error code */ |
| 298 | if (sts) { |
| 299 | memcpy(sts, &resp.sts, sizeof(resp.sts)); |
| 300 | sts->err = be16_to_cpu(sts->err); |
| 301 | } |
| 302 | |
| 303 | |
| 304 | /* Read response payload, if any */ |
| 305 | resp.payload_len = be32_to_cpu(resp.payload_len); |
| 306 | if (!maxresp_len || !respbuf) { |
| 307 | if (resp.payload_len) |
| 308 | ERROR("No buffer supplied but printer sending %d bytes\n", (int)resp.payload_len); |
| 309 | goto done; |
| 310 | } |
| 311 | |
| 312 | if (resp.payload_len > maxresp_len) { |
| 313 | ERROR("Oversize response (%d/%d)\n", resp.payload_len, maxresp_len); |
| 314 | return CUPS_BACKEND_FAILED; |
| 315 | } |
| 316 | ret = read_data(ctx->conn, (uint8_t*) respbuf, |
| 317 | resp.payload_len, &num); |
| 318 | if (num != (int) resp.payload_len) { |
| 319 | ERROR("Short Read! (%d/%d)\n", num, (int)resp.payload_len); |
| 320 | ret = -4; |
| 321 | goto done; |
| 322 | } |
| 323 | |
| 324 | done: |
| 325 | return ret; |
| 326 | } |
| 327 | |
| 328 | static int rtp1_getmaxxfer(struct kodak8800_ctx *ctx, uint32_t *maxlen) |
| 329 | { |
| 330 | int ret; |
| 331 | |
| 332 | ret = rtp1_docmd(ctx, rtp_getmaxxfer, NULL, 0, 4, (uint8_t*)maxlen, NULL); |
| 333 | |
| 334 | *maxlen = be32_to_cpu(*maxlen); |
| 335 | |
| 336 | return ret; |
| 337 | } |
| 338 | |
| 339 | static int kodak8800_getinfo(struct kodak8800_ctx *ctx) |
| 340 | { |
| 341 | int ret; |
| 342 | struct rtp1_mfgmodel mfgmdl; |
| 343 | struct rtp1_serial headsn; |
| 344 | struct rtp1_fwvers fwvers; |
| 345 | |
| 346 | ret = rtp1_docmd(ctx, rtp_getmfgmodel, NULL, 0, |
| 347 | sizeof(mfgmdl), (uint8_t*) &mfgmdl, NULL); |
| 348 | if (ret) |
| 349 | return ret; |
| 350 | ret = rtp1_docmd(ctx, rtp_getserialhead, NULL, 0, |
| 351 | sizeof(headsn), (uint8_t*) &headsn, NULL); |
| 352 | if (ret) |
| 353 | return ret; |
| 354 | ret = rtp1_docmd(ctx, rtp_getfwversions, NULL, 0, |
| 355 | sizeof(fwvers), (uint8_t*) &fwvers, NULL); |
| 356 | if (ret) |
| 357 | return ret; |
| 358 | |
| 359 | fwvers.dsp[11] = 0; /* It's special */ |
| 360 | |
| 361 | INFO("Manufacturer: %s\n", (char*) mfgmdl.mfg); |
| 362 | INFO("Model: %s\n", (char*) mfgmdl.model); |
| 363 | INFO("Serial: %s\n", (char*) mfgmdl.serial); |
| 364 | INFO("Head Serial: %s\n", (char*) headsn.serial); |
| 365 | INFO("Main FW Version: %s\n", (char*) mfgmdl.fwver); |
| 366 | INFO("DSP FW Version: %s\n", (char*) fwvers.dsp); |
| 367 | INFO("Engine FW Version: %s\n", (char*) fwvers.eng); |
| 368 | INFO("System FW Version: %s\n", (char*) fwvers.system); |
| 369 | INFO("Head FW Version: %s\n", (char*) fwvers.head); |
| 370 | INFO("Reset FW Version: %s\n", (char*) fwvers.reset); |
| 371 | |
| 372 | return CUPS_BACKEND_OK; |
| 373 | } |
| 374 | |
| 375 | static int kodak8800_getmedia(struct kodak8800_ctx *ctx) |
| 376 | { |
| 377 | int ret; |
| 378 | struct rtp1_mediastatus media; |
| 379 | |
| 380 | ret = rtp1_docmd(ctx, rtp_getmedia, NULL, 0, |
| 381 | sizeof(media), (uint8_t*) &media, NULL); |
| 382 | if (ret) |
| 383 | return ret; |
| 384 | |
| 385 | media.media_type = be16_to_cpu(media.media_type); |
| 386 | media.paper_type = be16_to_cpu(media.paper_type); |
| 387 | media.ribbon_remain = be32_to_cpu(media.ribbon_remain); |
| 388 | media.paper_remain = be32_to_cpu(media.paper_remain); |
| 389 | |
| 390 | INFO("Ribbon Type: %s (%d)\n", media.paper_type == MEDIA_TYPE_8x10_G ? "Kodak 8810S" : " Unknown", media.media_type); |
| 391 | INFO("Paper Type: %s (%d)\n", media.paper_type == PAPER_TYPE_7 ? "8\"" : "Unknown", media.paper_type); //XXX |
| 392 | INFO("Remaining Paper: %d feet\n", media.paper_remain / 12); |
| 393 | INFO("Remaining Ribbon: %d feet\n", media.ribbon_remain / 12); |
| 394 | INFO("Remaining Prints: %d\n", media.ribbon_remain / 12 / 4); |
| 395 | |
| 396 | return CUPS_BACKEND_OK; |
| 397 | } |
| 398 | |
| 399 | static int kodak8800_getcounters(struct kodak8800_ctx *ctx) |
| 400 | { |
| 401 | int ret; |
| 402 | struct rtp1_counters counters; |
| 403 | |
| 404 | ret = rtp1_docmd(ctx, rtp_getcounters, NULL, 0, |
| 405 | sizeof(counters), (uint8_t*) &counters, NULL); |
| 406 | if (ret) |
| 407 | return ret; |
| 408 | |
| 409 | counters.cutter_count = be32_to_cpu(counters.cutter_count); |
| 410 | counters.prints_finished = be32_to_cpu(counters.prints_finished); |
| 411 | counters.prints_started = be32_to_cpu(counters.prints_started); |
| 412 | counters.ribbon_head = be32_to_cpu(counters.ribbon_head); |
| 413 | counters.paper_total = be32_to_cpu(counters.paper_total); |
| 414 | |
| 415 | INFO("Lifetime prints %d / %d\n", (int) counters.prints_finished, (int) counters.prints_started); |
| 416 | INFO("Cutter actuations: %d\n", (int) counters.cutter_count); |
| 417 | INFO("Total ribbon usage: %d feet\n", counters.ribbon_head / 300 / 12); |
| 418 | INFO("Total paper usage: %d feet\n", counters.paper_total / 300 / 12); |
| 419 | |
| 420 | return CUPS_BACKEND_OK; |
| 421 | } |
| 422 | |
| 423 | static int kodak8800_canceljob(struct kodak8800_ctx *ctx, int id) |
| 424 | { |
| 425 | int ret; |
| 426 | uint8_t jobcmd[4]; |
| 427 | uint32_t jobid; |
| 428 | |
| 429 | memcpy(jobcmd, rtp_canceljob, sizeof(jobcmd)); |
| 430 | |
| 431 | if (id > 0) { |
| 432 | jobid = id; |
| 433 | jobid = cpu_to_be32(jobid); |
| 434 | jobcmd[1] = 1; // XXX this might need to be the jobid |
| 435 | ret = rtp1_docmd(ctx, jobcmd, (uint8_t*)&jobid, sizeof(jobid), 0, NULL, NULL); |
| 436 | } else { |
| 437 | ret = rtp1_docmd(ctx, jobcmd, NULL, 0, 0, NULL, NULL); |
| 438 | } |
| 439 | |
| 440 | return ret; |
| 441 | } |
| 442 | |
| 443 | static int kodak8800_geterrorlog(struct kodak8800_ctx *ctx, int id) |
| 444 | { |
| 445 | int ret; |
| 446 | uint8_t jobcmd[4]; |
| 447 | struct rtp1_errorlog errors; |
| 448 | int i; |
| 449 | |
| 450 | if (id < 1 || id > 3) |
| 451 | return CUPS_BACKEND_FAILED; |
| 452 | |
| 453 | memcpy(jobcmd, rtp_getusererrors, sizeof(jobcmd)); |
| 454 | |
| 455 | jobcmd[1] = id; |
| 456 | |
| 457 | ret = rtp1_docmd(ctx, jobcmd, NULL, 0, sizeof(errors), (uint8_t*)&errors, NULL); |
| 458 | |
| 459 | if (ret) |
| 460 | return CUPS_BACKEND_FAILED; |
| 461 | DEBUG("PRINT / PAPER / RIBBON @ PL : CODE (Reason)\n"); |
| 462 | |
| 463 | for (i = 0; i < NUM_ERRORRECS; i++) { |
| 464 | if (errors.row[i].type == ERROR_TYPE_END) |
| 465 | continue; |
| 466 | INFO(" %06d / %06d / %06d @ %02d : x%04x (%s)\n", |
| 467 | be32_to_cpu(errors.row[i].printnum), |
| 468 | be32_to_cpu(errors.row[i].papernum) / 300 / 12, |
| 469 | be32_to_cpu(errors.row[i].ribbonnum) / 300 / 12, |
| 470 | errors.row[i].plane, |
| 471 | be16_to_cpu(errors.row[i].code), |
| 472 | kodak8800_errorstrs(be16_to_cpu(errors.row[i].code))); |
| 473 | } |
| 474 | |
| 475 | /* After an error log query, have to kick things */ |
| 476 | ret = rtp1_docmd(ctx, rtp_getstatus, NULL, 0, 0, NULL, NULL); |
| 477 | |
| 478 | return ret; |
| 479 | } |
| 480 | static void kodak8800_cmdline(void) |
| 481 | { |
| 482 | DEBUG("\t\t[ -e 1|2|3 ] # Query error logs\n"); |
| 483 | DEBUG("\t\t[ -i ] # Query printer info\n"); |
| 484 | DEBUG("\t\t[ -m ] # Query media info\n"); |
| 485 | DEBUG("\t\t[ -n ] # Query counters\n"); |
| 486 | DEBUG("\t\t[ -X id ] # Cancel job (0 for all)\n"); |
| 487 | } |
| 488 | |
| 489 | static int kodak8800_cmdline_arg(void *vctx, int argc, char **argv) |
| 490 | { |
| 491 | struct kodak8800_ctx *ctx = vctx; |
| 492 | int i, j = 0; |
| 493 | |
| 494 | if (!ctx) |
| 495 | return -1; |
| 496 | |
| 497 | while ((i = getopt(argc, argv, GETOPT_LIST_GLOBAL "e:imnX:")) >= 0) { |
| 498 | switch(i) { |
| 499 | GETOPT_PROCESS_GLOBAL |
| 500 | case 'e': |
| 501 | j = kodak8800_geterrorlog(ctx, atoi(optarg)); |
| 502 | break; |
| 503 | case 'i': |
| 504 | j = kodak8800_getinfo(ctx); |
| 505 | break; |
| 506 | case 'm': |
| 507 | j = kodak8800_getmedia(ctx); |
| 508 | break; |
| 509 | case 'n': |
| 510 | j = kodak8800_getcounters(ctx); |
| 511 | break; |
| 512 | case 'X': |
| 513 | j = kodak8800_canceljob(ctx, atoi(optarg)); |
| 514 | break; |
| 515 | |
| 516 | default: |
| 517 | break; /* Ignore completely */ |
| 518 | } |
| 519 | |
| 520 | if (j) return j; |
| 521 | } |
| 522 | |
| 523 | return CUPS_BACKEND_OK; |
| 524 | } |
| 525 | |
| 526 | static void *kodak8800_init(void) |
| 527 | { |
| 528 | struct kodak8800_ctx *ctx = malloc(sizeof(struct kodak8800_ctx)); |
| 529 | if (!ctx) { |
| 530 | ERROR("Memory Allocation Failure\n"); |
| 531 | return NULL; |
| 532 | } |
| 533 | memset(ctx, 0, sizeof(struct kodak8800_ctx)); |
| 534 | |
| 535 | return ctx; |
| 536 | } |
| 537 | |
| 538 | static int kodak8800_query_mfgmodel(struct kodak8800_ctx *ctx); |
| 539 | |
| 540 | static int kodak8800_attach(void *vctx, struct dyesub_connection *conn, uint8_t jobid) |
| 541 | { |
| 542 | struct kodak8800_ctx *ctx = vctx; |
| 543 | int ret; |
| 544 | struct rtp1_mediastatus media; |
| 545 | |
| 546 | ctx->conn = conn; |
| 547 | |
| 548 | /* Ensure jobid is sane */ |
| 549 | ctx->jobid = jobid & 0x7f; |
| 550 | if (!ctx->jobid) |
| 551 | ctx->jobid++; |
| 552 | |
| 553 | if (test_mode < TEST_MODE_NOATTACH) { |
| 554 | ret = kodak8800_query_mfgmodel(ctx); |
| 555 | if (ret) |
| 556 | return CUPS_BACKEND_FAILED; |
| 557 | ret = rtp1_docmd(ctx, rtp_getmedia, NULL, 0, sizeof(media), (uint8_t*)&media, NULL); |
| 558 | if (ret) |
| 559 | return CUPS_BACKEND_FAILED; |
| 560 | |
| 561 | media.ribbon_remain = be32_to_cpu(media.ribbon_remain); |
| 562 | media.paper_remain = be32_to_cpu(media.paper_remain); |
| 563 | media.media_type = be16_to_cpu(media.media_type); |
| 564 | } else { |
| 565 | strcpy(ctx->fwver, "0.0"); |
| 566 | strcpy(ctx->serial, "12345"); |
| 567 | media.ribbon_remain = 92; |
| 568 | media.paper_remain = 24; |
| 569 | media.media_type = MEDIA_TYPE_8x10_G; |
| 570 | // XXX media.unk[0..4]? |
| 571 | } |
| 572 | |
| 573 | media.ribbon_remain /= 4; |
| 574 | if (media.ribbon_remain < media.paper_remain) |
| 575 | ctx->marker.levelnow = media.ribbon_remain; |
| 576 | else |
| 577 | ctx->marker.levelnow = media.paper_remain; |
| 578 | ctx->marker.levelnow /= 12; |
| 579 | |
| 580 | ctx->marker.color = "#00FFFF#FF00FF#FFFF00"; |
| 581 | ctx->marker.numtype = media.media_type; |
| 582 | |
| 583 | if (media.media_type == MEDIA_TYPE_8x10_G) { |
| 584 | ctx->marker.name = "8810S (8x10)"; |
| 585 | ctx->marker.levelmax = 300; |
| 586 | } else { |
| 587 | ctx->marker.name = "8810L (8x12)"; |
| 588 | ctx->marker.levelmax = 250; |
| 589 | } |
| 590 | |
| 591 | return CUPS_BACKEND_OK; |
| 592 | } |
| 593 | |
| 594 | static void kodak8800_cleanup_job(const void *vjob) |
| 595 | { |
| 596 | const struct kodak8800_printjob *job = vjob; |
| 597 | |
| 598 | if (job->databuf) |
| 599 | free(job->databuf); |
| 600 | |
| 601 | free((void*)job); |
| 602 | } |
| 603 | |
| 604 | static int kodak8800_read_parse(void *vctx, const void **vjob, int data_fd, int copies) { |
| 605 | struct kodak8800_ctx *ctx = vctx; |
| 606 | int ret; |
| 607 | |
| 608 | struct kodak8800_printjob *job = NULL; |
| 609 | |
| 610 | if (!ctx) |
| 611 | return CUPS_BACKEND_FAILED; |
| 612 | |
| 613 | job = malloc(sizeof(*job)); |
| 614 | if (!job) { |
| 615 | ERROR("Memory allocation failure!\n"); |
| 616 | return CUPS_BACKEND_RETRY_CURRENT; |
| 617 | } |
| 618 | memset(job, 0, sizeof(*job)); |
| 619 | |
| 620 | /* Read Rosetta data */ |
| 621 | job->databuf = malloc(sizeof(struct rosetta_header)); |
| 622 | if (!job->databuf) { |
| 623 | ERROR("Memmory allocation failure!\n"); |
| 624 | kodak8800_cleanup_job(job); |
| 625 | return CUPS_BACKEND_RETRY; |
| 626 | } |
| 627 | |
| 628 | /* Read rosetta header */ |
| 629 | ret = read(data_fd, job->databuf, sizeof(struct rosetta_header)); |
| 630 | if (ret < 0 || ret != sizeof(struct rosetta_header)) { |
| 631 | if (ret != 0) { |
| 632 | perror("ERROR: read failed"); |
| 633 | } |
| 634 | kodak8800_cleanup_job(job); |
| 635 | return CUPS_BACKEND_CANCEL; |
| 636 | } |
| 637 | job->common.jobsize += sizeof(struct rosetta_header); |
| 638 | |
| 639 | /* Sanity check header */ |
| 640 | if (memcmp(job->databuf, "\x1bMndROSETTA V001", 16)) { |
| 641 | ERROR("Invalid ROSETTA header\n"); |
| 642 | kodak8800_cleanup_job(job); |
| 643 | return CUPS_BACKEND_CANCEL; |
| 644 | } |
| 645 | |
| 646 | /* Reallocate databuf */ |
| 647 | job->databuf = realloc(job->databuf, 2624*3624*3+4*1024); // XXX better solution here? |
| 648 | if (!job->databuf) { |
| 649 | ERROR("Memmory allocation failure!\n"); |
| 650 | kodak8800_cleanup_job(job); |
| 651 | return CUPS_BACKEND_RETRY; |
| 652 | } |
| 653 | /* Read in the data blocks */ |
| 654 | while (1) { |
| 655 | struct rosetta_block *block = (struct rosetta_block *)(job->databuf + job->common.jobsize); |
| 656 | uint32_t payload_len = 0; |
| 657 | |
| 658 | /* Read in block header */ |
| 659 | ret = read(data_fd, block, sizeof(struct rosetta_block)); |
| 660 | if (ret < 0 || ret != sizeof(struct rosetta_block)) { |
| 661 | if (ret != 0) { |
| 662 | perror("ERROR: read failed"); |
| 663 | } |
| 664 | kodak8800_cleanup_job(job); |
| 665 | return CUPS_BACKEND_CANCEL; |
| 666 | } |
| 667 | payload_len = be32_to_cpu(block->payload_len); |
| 668 | // INFO("block %d @ %d \n", payload_len + sizeof(struct rosetta_block), job->common.jobsize); |
| 669 | |
| 670 | /* Read in block payload */ |
| 671 | ret = read(data_fd, block->payload, payload_len); |
| 672 | if (ret < 0 || ret != (int) payload_len) { |
| 673 | if (ret != 0) { |
| 674 | perror("ERROR: read failed"); |
| 675 | } |
| 676 | kodak8800_cleanup_job(job); |
| 677 | return CUPS_BACKEND_CANCEL; |
| 678 | } |
| 679 | job->common.jobsize += sizeof(struct rosetta_block); |
| 680 | job->common.jobsize += payload_len; |
| 681 | |
| 682 | /* Work out our copies offset */ |
| 683 | if (!memcmp(block->cmd, "FlsPgCopies", 11)) { |
| 684 | job->copies_offset = job->common.jobsize - payload_len; |
| 685 | } |
| 686 | /* If this is the last block, we're done! */ |
| 687 | if (!memcmp(block->cmd, "MndEndJob", 9)) |
| 688 | break; |
| 689 | } |
| 690 | |
| 691 | /* Handle copies */ |
| 692 | if (job->copies_offset) { |
| 693 | uint32_t tmp = 0; |
| 694 | memcpy(&tmp, job->databuf + job->copies_offset, sizeof(tmp)); |
| 695 | tmp = be32_to_cpu(tmp); |
| 696 | /* Use larger of our copy counts */ |
| 697 | if ((int)tmp > copies) { |
| 698 | tmp = be32_to_cpu(copies); |
| 699 | memcpy(job->databuf + job->copies_offset, &tmp, sizeof(tmp)); |
| 700 | } else { |
| 701 | copies = tmp; |
| 702 | } |
| 703 | } |
| 704 | |
| 705 | job->common.copies = copies; |
| 706 | *vjob = job; |
| 707 | |
| 708 | return CUPS_BACKEND_OK; |
| 709 | } |
| 710 | |
| 711 | static int kodak8800_main_loop(void *vctx, const void *vjob, int wait_for_return) { |
| 712 | struct kodak8800_ctx *ctx = vctx; |
| 713 | |
| 714 | int ret; |
| 715 | struct rtp1_sts sts; |
| 716 | |
| 717 | const struct kodak8800_printjob *job = vjob; |
| 718 | |
| 719 | if (!ctx) |
| 720 | return CUPS_BACKEND_FAILED; |
| 721 | if (!job) |
| 722 | return CUPS_BACKEND_FAILED; |
| 723 | |
| 724 | INFO("Waiting for printer idle\n"); |
| 725 | |
| 726 | /* Query status */ |
| 727 | do { |
| 728 | ret = rtp1_docmd(ctx, rtp_getstatus, NULL, 0, 0, NULL, &sts); |
| 729 | if (ret) |
| 730 | return ret; |
| 731 | if (sts.err) { |
| 732 | ERROR("Printer reports error: %s (%04x)\n", |
| 733 | kodak8800_errorstrs(sts.err), sts.err); |
| 734 | return CUPS_BACKEND_FAILED; |
| 735 | } |
| 736 | if (sts.sts[0] == STATE_IDLE) { |
| 737 | break; |
| 738 | } |
| 739 | sleep(1); |
| 740 | } while (1); |
| 741 | |
| 742 | INFO("Sending image data\n"); |
| 743 | |
| 744 | uint32_t jobid; |
| 745 | ret = rtp1_docmd(ctx, rtp_openjob, NULL, 0, 4, (uint8_t*)&jobid, &sts); |
| 746 | if (ret) |
| 747 | return ret; |
| 748 | |
| 749 | jobid = be32_to_cpu(jobid); |
| 750 | if (sts.err) { |
| 751 | ERROR("Printer reports error: %04x\n", sts.err); |
| 752 | return CUPS_BACKEND_FAILED; |
| 753 | } |
| 754 | INFO("Printer assigned Job ID: %d\n", (int) jobid); |
| 755 | |
| 756 | /* Sent over data blocks */ |
| 757 | uint32_t offset = 0; |
| 758 | while (offset < job->common.jobsize) { |
| 759 | uint32_t max_blocksize; |
| 760 | ret = rtp1_getmaxxfer(ctx, &max_blocksize); |
| 761 | if (ret) |
| 762 | return ret; |
| 763 | |
| 764 | if (job->common.jobsize - offset < max_blocksize) |
| 765 | max_blocksize = job->common.jobsize - offset; |
| 766 | |
| 767 | ret = rtp1_docmd(ctx, rtp_sendimagedata, |
| 768 | job->databuf + offset, max_blocksize, |
| 769 | 0, NULL, &sts); |
| 770 | if (ret) |
| 771 | return ret; |
| 772 | if (sts.err) { |
| 773 | ERROR("Printer reports error: %s (%04x)\n", |
| 774 | kodak8800_errorstrs(sts.err), sts.err); |
| 775 | return CUPS_BACKEND_FAILED; |
| 776 | } |
| 777 | |
| 778 | offset += max_blocksize; |
| 779 | } |
| 780 | /* Send payload footer */ |
| 781 | ret = rtp1_docmd(ctx, rtp_closejob, |
| 782 | NULL, 0, 0, NULL, &sts); |
| 783 | if (ret) |
| 784 | return ret; |
| 785 | |
| 786 | INFO("Waiting for printer to acknowledge completion\n"); |
| 787 | |
| 788 | do { |
| 789 | sleep(1); |
| 790 | |
| 791 | ret = rtp1_docmd(ctx, rtp_getstatus, NULL, 0, 0, NULL, &sts); |
| 792 | if (ret) |
| 793 | return ret; |
| 794 | if (sts.err) { |
| 795 | ERROR("Printer reports error: %s (%04x)\n", |
| 796 | kodak8800_errorstrs(sts.err), sts.err); |
| 797 | return CUPS_BACKEND_FAILED; |
| 798 | } |
| 799 | if (sts.sts[0] == STATE_IDLE) { |
| 800 | break; |
| 801 | } |
| 802 | if (!wait_for_return) { |
| 803 | INFO("Fast return mode enabled.\n"); |
| 804 | break; |
| 805 | } |
| 806 | sleep(1); |
| 807 | } while (1); |
| 808 | |
| 809 | INFO("Print complete\n"); |
| 810 | |
| 811 | return CUPS_BACKEND_OK; |
| 812 | } |
| 813 | |
| 814 | static int kodak8800_query_serno(struct dyesub_connection *conn, char *respbuf, int buf_len) |
| 815 | { |
| 816 | uint8_t buf[64]; |
| 817 | int ret; |
| 818 | |
| 819 | struct kodak8800_ctx ctx = { |
| 820 | .conn = conn, |
| 821 | }; |
| 822 | |
| 823 | ret = rtp1_docmd(&ctx, rtp_getserial, NULL, 0, sizeof(buf), buf, NULL); |
| 824 | |
| 825 | if (!ret) |
| 826 | memcpy(respbuf, buf, buf_len); |
| 827 | |
| 828 | return ret; |
| 829 | } |
| 830 | |
| 831 | static int kodak8800_query_mfgmodel(struct kodak8800_ctx *ctx) |
| 832 | { |
| 833 | uint8_t buf[256]; |
| 834 | int ret; |
| 835 | |
| 836 | ret = rtp1_docmd(ctx, rtp_getmfgmodel, NULL, 0, sizeof(buf), buf, NULL); |
| 837 | |
| 838 | if (!ret) { |
| 839 | memcpy(ctx->serial, buf + 64*2, sizeof(ctx->serial)); |
| 840 | memcpy(ctx->fwver, buf + 64*3, sizeof(ctx->fwver)); |
| 841 | } |
| 842 | |
| 843 | return ret; |
| 844 | } |
| 845 | |
| 846 | static int kodak8800_query_markers(void *vctx, struct marker **markers, int *count) |
| 847 | { struct kodak8800_ctx *ctx = vctx; |
| 848 | struct rtp1_mediastatus media; |
| 849 | int ret; |
| 850 | |
| 851 | ret = rtp1_docmd(ctx, rtp_getmedia, NULL, 0, sizeof(media), (uint8_t*)&media, NULL); |
| 852 | if (ret) |
| 853 | return CUPS_BACKEND_FAILED; |
| 854 | |
| 855 | media.ribbon_remain = be32_to_cpu(media.ribbon_remain); |
| 856 | media.paper_remain = be32_to_cpu(media.paper_remain); |
| 857 | |
| 858 | media.ribbon_remain /= 4; |
| 859 | if (media.ribbon_remain < media.paper_remain) |
| 860 | ctx->marker.levelnow = media.ribbon_remain; |
| 861 | else |
| 862 | ctx->marker.levelnow = media.paper_remain; |
| 863 | ctx->marker.levelnow /= 12; |
| 864 | |
| 865 | *markers = &ctx->marker; |
| 866 | *count = 1; |
| 867 | |
| 868 | return CUPS_BACKEND_OK; |
| 869 | } |
| 870 | |
| 871 | static int kodak8800_query_stats(void *vctx, struct printerstats *stats) |
| 872 | { |
| 873 | struct kodak8800_ctx *ctx= vctx; |
| 874 | struct rtp1_counters counters; |
| 875 | struct rtp1_sts sts; |
| 876 | |
| 877 | int ret; |
| 878 | |
| 879 | stats->mfg = "Kodak"; |
| 880 | stats->model = "8800/9810"; |
| 881 | |
| 882 | ret = kodak8800_query_mfgmodel(ctx); |
| 883 | if (ret) |
| 884 | return ret; |
| 885 | |
| 886 | stats->serial = ctx->serial; |
| 887 | stats->fwver = ctx->fwver; |
| 888 | |
| 889 | stats->decks = 1; |
| 890 | stats->mediatype[0] = ctx->marker.name; |
| 891 | stats->levelmax[0] = ctx->marker.levelmax; |
| 892 | stats->levelnow[0] = ctx->marker.levelnow; |
| 893 | stats->name[0] = "Roll"; |
| 894 | |
| 895 | ret = rtp1_docmd(ctx, rtp_getcounters, NULL, 0, sizeof(counters), (uint8_t*) &counters, &sts); |
| 896 | if (ret) |
| 897 | return ret; |
| 898 | |
| 899 | stats->cnt_life[0] = be32_to_cpu(counters.prints_finished); |
| 900 | |
| 901 | const char *status; |
| 902 | if (sts.err) |
| 903 | status = "Error"; |
| 904 | else if (sts.sts[0] == STATE_IDLE) |
| 905 | status = "Idle"; |
| 906 | else if (sts.sts[0] == STATE_PRINT) |
| 907 | status = "Printing"; |
| 908 | else |
| 909 | status = "Unknown"; |
| 910 | |
| 911 | stats->status[0] = strdup(status); // XXX |
| 912 | |
| 913 | return CUPS_BACKEND_OK; |
| 914 | } |
| 915 | |
| 916 | |
| 917 | static const char *kodak8800_prefixes[] = { |
| 918 | "kodak8800", // Family driver, do NOT nuke! |
| 919 | NULL |
| 920 | }; |
| 921 | |
| 922 | static const struct device_id kodak8800_devices[] = { |
| 923 | { 0x040a, 0x4023, P_KODAK_8800, "Kodak", "kodak-8800"}, |
| 924 | { 0x040a, 0x4023, P_KODAK_8800, "Kodak", "kodak-9810"}, // duplicate |
| 925 | { 0, 0, 0, NULL, NULL} |
| 926 | }; |
| 927 | |
| 928 | /* Exported */ |
| 929 | const struct dyesub_backend kodak8800_backend = { |
| 930 | .name = "Kodak 8800/9810", |
| 931 | .version = "0.08", |
| 932 | .uri_prefixes = kodak8800_prefixes, |
| 933 | .devices = kodak8800_devices, |
| 934 | .cmdline_usage = kodak8800_cmdline, |
| 935 | .cmdline_arg = kodak8800_cmdline_arg, |
| 936 | .init = kodak8800_init, |
| 937 | .attach = kodak8800_attach, |
| 938 | .cleanup_job = kodak8800_cleanup_job, |
| 939 | .read_parse = kodak8800_read_parse, |
| 940 | .main_loop = kodak8800_main_loop, |
| 941 | .query_serno = kodak8800_query_serno, |
| 942 | .query_markers = kodak8800_query_markers, |
| 943 | .query_stats = kodak8800_query_stats, |
| 944 | }; |
| 945 | |
| 946 | /* |
| 947 | |
| 948 | ************* Kodak 8800/9810 Spool format |
| 949 | |
| 950 | General format for blocks (except initial header) |
| 951 | All multi-byte fields are BIG ENDIAN |
| 952 | |
| 953 | 1b xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx |
| 954 | xx xx xx xx 00 00 00 00 NN NN NN NN |
| 955 | |
| 956 | [ followed by NN bytes of payload ] |
| 957 | [ xx is ASCII field name, space (0x20) padded ] |
| 958 | |
| 959 | File header (fixed) |
| 960 | |
| 961 | 1b 4d 6e 64 52 4f 53 45 54 54 41 20 56 30 30 31 'MndROSETTA V001' |
| 962 | 2e 30 30 31 30 30 30 30 30 30 32 30 35 32 35 30 |
| 963 | 37 32 36 39 36 45 37 34 36 35 37 32 34 32 36 39 |
| 964 | 36 45 34 44 36 46 37 34 37 32 36 43 |
| 965 | |
| 966 | Job header (fixed) |
| 967 | |
| 968 | 1b 4d 6e 64 42 67 6e 4a 6f 62 20 20 50 72 69 6e 'MndBgnJob Print ' |
| 969 | 74 20 20 20 00 00 00 00 00 00 00 08 56 30 30 31 |
| 970 | 2e 30 30 30 |
| 971 | |
| 972 | Job Settings start (fixed) |
| 973 | |
| 974 | 1b 46 6c 73 53 72 74 4a 62 44 65 66 53 65 74 75 'FlsSrtJbDefSetup ' |
| 975 | 70 20 20 20 00 00 00 00 00 00 00 00 |
| 976 | |
| 977 | Job Media selection |
| 978 | |
| 979 | 1b 46 6c 73 4a 62 4d 6b 4d 65 64 20 4e 61 6d 65 'FlsJbMkMed Name ' |
| 980 | 20 20 20 20 00 00 00 00 00 00 00 40 59 4d 43 58 |
| 981 | 20 38 78 31 32 20 47 6c 6f 73 73 79 00 00 00 00 |
| 982 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 :: @YMCX 8x12 Glossy |
| 983 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |
| 984 | 00 00 00 00 00 00 00 00 00 00 00 00 |
| 985 | |
| 986 | ~~ or: |
| 987 | |
| 988 | 1b 46 6c 73 4a 62 4d 6b 4d 65 64 20 4e 61 6d 65 |
| 989 | 20 20 20 20 00 00 00 00 00 00 00 40 59 4d 43 58 |
| 990 | 20 38 78 31 30 20 47 6c 6f 73 73 79 00 00 00 00 :: @YMCX 8x10 Glossy |
| 991 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |
| 992 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |
| 993 | 00 00 00 00 00 00 00 00 00 00 00 00 |
| 994 | |
| 995 | Page Media Selection (fixed at 8") |
| 996 | |
| 997 | 1b 46 6c 73 50 67 4d 65 64 69 61 20 4e 61 6d 65 'FlsPgMedia Name ' |
| 998 | 20 20 20 20 00 00 00 00 00 00 00 40 XX XX XX XX '7"' '8"' '8.5"' 'A4' |
| 999 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |
| 1000 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |
| 1001 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |
| 1002 | 00 00 00 00 00 00 00 00 00 00 00 00 |
| 1003 | |
| 1004 | Lamination |
| 1005 | |
| 1006 | 1b 46 6c 73 4a 62 4c 61 6d 20 20 20 XX XX XX 20 'FlsJbLam ??? ' |
| 1007 | 20 20 20 20 00 00 00 00 00 00 00 00 |
| 1008 | |
| 1009 | XX XX XX is '4f 66 66' (Off) or '4f 6e 20' (On) |
| 1010 | |
| 1011 | Job Settings end (fixed) |
| 1012 | |
| 1013 | 1b 46 6c 73 53 74 70 4a 62 44 65 66 20 20 20 20 'FlsStpJbDef ' |
| 1014 | 20 20 20 20 00 00 00 00 00 00 00 00 |
| 1015 | |
| 1016 | Page start (fixed) |
| 1017 | |
| 1018 | 1b 4d 6e 64 42 67 6e 4c 50 61 67 65 4e 6f 72 6d 'MndBgnLPageNormal ' |
| 1019 | 61 6c 20 20 00 00 00 00 00 00 00 04 00 00 00 01 |
| 1020 | |
| 1021 | Page parameters |
| 1022 | |
| 1023 | 1b 4d 6e 64 53 65 74 4c 50 61 67 65 20 20 20 20 'MdnSetLPage ' |
| 1024 | 20 20 20 20 00 00 00 00 00 00 00 08 00 00 XX XX XX XX == 09 A0 (2464) |
| 1025 | 00 00 YY YY YY YY == 0E 28 (3624) 8x12 |
| 1026 | == 0B D0 (3024) 8x10 |
| 1027 | |
| 1028 | Image size |
| 1029 | |
| 1030 | 1b 4d 6e 64 49 6d 53 70 65 63 20 20 53 69 7a 65 'MndImSpec Size ' |
| 1031 | 20 20 20 20 00 00 00 00 00 00 00 10 00 00 09 a0 XX XX, YY YY (see above) |
| 1032 | 00 00 YY YY 00 00 XX XX 00 00 00 00 |
| 1033 | |
| 1034 | Image Position on page (fixed @ 0x0) |
| 1035 | |
| 1036 | 1b 46 6c 73 49 6d 50 6f 73 69 74 6e 53 70 65 63 'FlsImPositnSpecify ' |
| 1037 | 69 66 79 20 00 00 00 00 00 00 00 08 00 00 00 00 |
| 1038 | 00 00 00 00 |
| 1039 | |
| 1040 | Image Sharpening: |
| 1041 | |
| 1042 | 1b 46 6c 73 49 6d 53 68 61 72 70 20 53 65 74 4c 'FlsImSharp SetLevel' |
| 1043 | 65 76 65 6c 00 00 00 00 00 00 00 02 ff SS SS == 12 (Normal) |
| 1044 | == 0 (None) |
| 1045 | == 19 (High) |
| 1046 | Page Copies: |
| 1047 | |
| 1048 | 1b 46 6c 73 50 67 43 6f 70 69 65 73 20 20 20 20 'FlsPgCopies ' |
| 1049 | 20 20 20 20 00 00 00 00 00 00 00 04 00 00 00 NN NN == Copies (01+) |
| 1050 | |
| 1051 | Other settings (fixed for now) |
| 1052 | |
| 1053 | 1b 46 6c 73 50 67 4d 69 72 72 6f 72 4e 6f 6e 65 'FlsPgMirrorNone ' |
| 1054 | 20 20 20 20 00 00 00 00 00 00 00 00 |
| 1055 | |
| 1056 | 1b 46 6c 73 50 67 52 6f 74 61 74 65 4e 6f 6e 65 'FlsPgRotateNone ' |
| 1057 | 20 20 20 20 00 00 00 00 00 00 00 00 |
| 1058 | |
| 1059 | Cut list |
| 1060 | |
| 1061 | 1b 46 6c 73 43 75 74 4c 69 73 74 20 20 20 20 20 'FlsCutList ' |
| 1062 | 20 20 20 20 00 00 00 00 00 00 NN NN [ NN * 2 ] |
| 1063 | |
| 1064 | 8x10: 00 04 00 0c 0b c4 |
| 1065 | 8x10div2: 00 06 00 0c 05 e8 0b c4 |
| 1066 | 8x10div2slug2: 00 06 00 0c 05 d5 05 fb 0b c4 |
| 1067 | 8x12: 00 04 00 0c 0e 1c |
| 1068 | 8x12div2: 00 06 00 0c 07 14 0e 1c |
| 1069 | 8x12div2slug2: 00 06 00 0c 07 01 07 27 0e 1c |
| 1070 | |
| 1071 | Image Plane data block |
| 1072 | |
| 1073 | 1b 46 6c 73 44 61 74 61 20 20 20 20 42 6c 6f 63 'FlsData Block ' |
| 1074 | 6b 20 20 20 00 00 00 00 LL LL LL LL LL LL LL LL == plane len 32BE |
| 1075 | 49 6d 61 67 65 20 20 20 'Image ' |
| 1076 | |
| 1077 | [[[ plane data, LLLLLLLL - 8 bytes ]]] |
| 1078 | |
| 1079 | 1b 46 6c 73 44 61 74 61 20 20 20 20 42 6c 6f 63 'FlsData Block ' |
| 1080 | 6b 20 20 20 00 00 00 00 LL LL LL LL |
| 1081 | 49 6d 61 67 65 20 20 20 'Image ' |
| 1082 | |
| 1083 | [[[ plane data, LLLLLLLL - 8 bytes ]]] |
| 1084 | |
| 1085 | 1b 46 6c 73 44 61 74 61 20 20 20 20 42 6c 6f 63 'FlsData Block ' |
| 1086 | 6b 20 20 20 00 00 00 00 LL LL LL LL |
| 1087 | 49 6d 61 67 65 20 20 20 'Image ' |
| 1088 | |
| 1089 | [[[ plane data, LLLLLLLL -8 bytes ]]] |
| 1090 | |
| 1091 | End Page (fixed) |
| 1092 | |
| 1093 | 1b 4d 6e 64 45 6e 64 4c 50 61 67 65 20 20 20 20 'MndEndLPage ' |
| 1094 | 20 20 20 20 00 00 00 00 00 00 00 00 |
| 1095 | |
| 1096 | End Job (fixed) |
| 1097 | |
| 1098 | 1b 4d 6e 64 45 6e 64 4a 6f 62 20 20 20 20 20 20 'MndEndJob ' |
| 1099 | 20 20 20 20 00 00 00 00 00 00 00 00 |
| 1100 | |
| 1101 | *************** Basic command format: (all multi-bytes are BIG ENDIAN) |
| 1102 | |
| 1103 | > 52 54 50 31 xx xx xx xx yy yy yy yy l1 l1 l1 l1 |
| 1104 | >> [ l1l1l1l1 bytes of payload ] |
| 1105 | < 52 54 40 31 xx xx xx xx ss ss EE EE s2 00 00 00 l2 l2 l2 l2 |
| 1106 | << [ l2l2l2l2 bytes of payload ] |
| 1107 | |
| 1108 | xx xx xx xx == command |
| 1109 | yy yy yy yy == response buffer length (ie l2l2l2l2 must be <= yyyyyyyy) |
| 1110 | ss ss == status message (10 10 is ok, 10 12 error) |
| 1111 | EE EE == error code |
| 1112 | s2 == secondary status (seen 00, 01, 02) |
| 1113 | |
| 1114 | |
| 1115 | **************** TODO |
| 1116 | |
| 1117 | * Sensor reporting (and queries) |
| 1118 | * Job status / Job queue status |
| 1119 | * Print status & errors |
| 1120 | * 8x12 media crap |
| 1121 | |
| 1122 | */ |