| 1 | /* |
| 2 | * Sony UP-D series (new) Photo Printer CUPS backend |
| 3 | * |
| 4 | * (c) 2019-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 BACKENDcxx . . $ `src/cups/backend_sonyupdneo.c:27:9`! sonyupdneo_backend |
| 28 | |
| 29 | #include "backend_common.h"cxx . . $ `<file>/src/cups/backend_common.h`/ |
| 30 | |
| 31 | /* Private data structures */ |
| 32 | struct updneo_printjobcxx . . $ updneo_printjob# { |
| 33 | struct dyesub_job_commoncxx . . $ dyesub_job_common# commoncxx . . $ updneo_printjob#common.; |
| 34 | |
| 35 | uint8_tcxx . . $ uint8_t# *databufcxx . . $ updneo_printjob#databuf.; |
| 36 | int datalencxx . . $ updneo_printjob#datalen.; |
| 37 | uint8_tcxx . . $ uint8_t# *hdrbufcxx . . $ updneo_printjob#hdrbuf.; |
| 38 | int hdrlencxx . . $ updneo_printjob#hdrlen.; |
| 39 | uint8_tcxx . . $ uint8_t# *ftrbufcxx . . $ updneo_printjob#ftrbuf.; |
| 40 | int ftrlencxx . . $ updneo_printjob#ftrlen.; |
| 41 | |
| 42 | uint16_tcxx . . $ uint16_t# rowscxx . . $ updneo_printjob#rows.; |
| 43 | uint16_tcxx . . $ uint16_t# colscxx . . $ updneo_printjob#cols.; |
| 44 | }; |
| 45 | |
| 46 | struct updneo_stscxx . . $ updneo_sts# { |
| 47 | uint16_tcxx . . $ uint16_t# scdivcxx . . $ updneo_sts#scdiv.; |
| 48 | uint32_tcxx . . $ uint32_t# scsyvcxx . . $ updneo_sts#scsyv.; |
| 49 | char scsnocxx . . $ updneo_sts#scsno.[17]; /* 16 char string, leading 0s, possibly trailing -- */ |
| 50 | char scsyscxx . . $ updneo_sts#scsys.[23]; /* 22 char string, mostly unknown */ |
| 51 | uint16_tcxx . . $ uint16_t# scmdscxx . . $ updneo_sts#scmds.[5]; |
| 52 | uint16_tcxx . . $ uint16_t# scprscxx . . $ updneo_sts#scprs.; |
| 53 | uint16_tcxx . . $ uint16_t# scsescxx . . $ updneo_sts#scses.; |
| 54 | uint16_tcxx . . $ uint16_t# scwtscxx . . $ updneo_sts#scwts.; |
| 55 | uint16_tcxx . . $ uint16_t# scjbscxx . . $ updneo_sts#scjbs.; |
| 56 | uint8_tcxx . . $ uint8_t# scsyecxx . . $ updneo_sts#scsye.; |
| 57 | uint16_tcxx . . $ uint16_t# scmdecxx . . $ updneo_sts#scmde.; |
| 58 | uint8_tcxx . . $ uint8_t# scmcecxx . . $ updneo_sts#scmce.; |
| 59 | char scjbicxx . . $ updneo_sts#scjbi.[17]; /* 16 char string, unknown */ |
| 60 | char scsyicxx . . $ updneo_sts#scsyi.[31]; /* 30 char string, max resolutions * 3, one more 6-char field */ |
| 61 | uint32_tcxx . . $ uint32_t# scsvicxx . . $ updneo_sts#scsvi.[2]; /* 2* 6char numbers */ |
| 62 | uint32_tcxx . . $ uint32_t# scmnicxx . . $ updneo_sts#scmni.[2]; /* 2* 6char numbers */ |
| 63 | char sccaicxx . . $ updneo_sts#sccai.[15]; /* 14 char string, unknown */ |
| 64 | uint16_tcxx . . $ uint16_t# scgaicxx . . $ updneo_sts#scgai.; |
| 65 | uint8_tcxx . . $ uint8_t# scgsicxx . . $ updneo_sts#scgsi.; |
| 66 | uint32_tcxx . . $ uint32_t# scmdicxx . . $ updneo_sts#scmdi.; /* xxxyyy : xxx is ribbon type, yyy is paper type? */ |
| 67 | uint32_tcxx . . $ uint32_t# scqticxx . . $ updneo_sts#scqti.; |
| 68 | uint32_tcxx . . $ uint32_t# spuqicxx . . $ updneo_sts#spuqi.; |
| 69 | }; |
| 70 | |
| 71 | struct updneo_ctxcxx . . $ updneo_ctx# { |
| 72 | struct dyesub_connectioncxx . . $ dyesub_connection# *conncxx . . $ updneo_ctx#conn.; |
| 73 | |
| 74 | int native_bppcxx . . $ updneo_ctx#native_bpp.; |
| 75 | |
| 76 | struct updneo_stscxx . . $ updneo_sts# stscxx . . $ updneo_ctx#sts.; |
| 77 | |
| 78 | struct markercxx . . $ marker# markercxx . . $ updneo_ctx#marker.; |
| 79 | }; |
| 80 | |
| 81 | /* Forward declaration */ |
| 82 | static int updneo_get_statuscxx . . $ updneo_get_status(e4141a2cf98b3e47).(struct updneo_ctxcxx . . $ updneo_ctx# *ctx); |
| 83 | |
| 84 | /* Now for the code */ |
| 85 | static const char* updneo_decode_errorscxx . . $ updneo_decode_errors(365a12950b6bb1a8).(uint16_tcxx . . $ uint16_t# mde, uint8_tcxx . . $ uint8_t# mce, uint8_tcxx . . $ uint8_t# sye) |
| 86 | { |
| 87 | if (!mde && !mce && sye) |
| 88 | return "None"; |
| 89 | if (mde == 0x0800 || mce == 0x1) |
| 90 | return "Cover open"; |
| 91 | if (mce == 0x08) |
| 92 | return "Paper feed error"; |
| 93 | if (mde == 0x0a00) |
| 94 | return "No paper loaded"; |
| 95 | if (mde == 0x0002) |
| 96 | return "No ribbon loaded"; |
| 97 | if (mde == 0x0300) |
| 98 | return "No media loaded"; |
| 99 | if (mde == 0x2000) |
| 100 | return "Job does not match installed media"; |
| 101 | |
| 102 | return "Unknown"; |
| 103 | } |
| 104 | |
| 105 | static void* updneo_initcxx . . $ updneo_init(50c7df7de5344ebb).(void) |
| 106 | { |
| 107 | struct updneo_ctxcxx . . $ updneo_ctx# *ctx = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(sizeof(struct updneo_ctxcxx . . $ updneo_ctx#)); |
| 108 | if (!ctx) { |
| 109 | ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Memory Allocation Failure!\n"); |
| 110 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 111 | } |
| 112 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(ctx, 0, sizeof(struct updneo_ctxcxx . . $ updneo_ctx#)); |
| 113 | return ctx; |
| 114 | } |
| 115 | |
| 116 | static const char *updneo_mediascxx . . $ updneo_medias(81a3ae90da26a711).(uint32_tcxx . . $ uint32_t# mdi) |
| 117 | { |
| 118 | uint32_tcxx . . $ uint32_t# mdi2 = mdi >> 12; |
| 119 | mdi2 &= 0xfff; |
| 120 | |
| 121 | switch(mdi2) { |
| 122 | case 0x110: return "UPC-R81MD (Letter)"; |
| 123 | // unknown: UPC-R80MD (A4) |
| 124 | case 0x200: |
| 125 | if ((mdi & 0xfff) == 0x404) { |
| 126 | return "UPP-110 Roll"; // UPP-110HD, UPP-110HG, UPP-110S |
| 127 | } else if ((mdi & 0xfff) == 0x406) { |
| 128 | return "UPP-210 Roll"; // UPP-210HD, UPP-210SE, UPT-210BL |
| 129 | } else { |
| 130 | return "Unknown thermal roll"; |
| 131 | } |
| 132 | break; |
| 133 | default: return "Unknown"; |
| 134 | } |
| 135 | } |
| 136 | |
| 137 | static int updneo_attachcxx . . $ updneo_attach(65a6cf861cd15f84).(void *vctx, struct dyesub_connectioncxx . . $ dyesub_connection# *conn, uint8_tcxx . . $ uint8_t# jobid) |
| 138 | { |
| 139 | struct updneo_ctxcxx . . $ updneo_ctx# *ctx = vctx; |
| 140 | int ret; |
| 141 | |
| 142 | UNUSEDcxx . . $ `src/cups/backend_common.h:84:9`!(jobid); |
| 143 | |
| 144 | ctx->conncxx . . $ updneo_ctx#conn. = conn; |
| 145 | |
| 146 | if (test_modecxx . . $ test_mode. < TEST_MODE_NOATTACHcxx . . $ TEST_MODE_NOATTACH.) { |
| 147 | if ((ret = updneo_get_statuscxx . . $ updneo_get_status(e4141a2cf98b3e47).(ctx))) { |
| 148 | return ret; |
| 149 | } |
| 150 | |
| 151 | if (ctx->native_bppcxx . . $ updneo_ctx#native_bpp. == 1) /* Necessary for UP-D898 and 9x1 */ |
| 152 | libusb_reset_devicecxx . . $ libusb_reset_device(dd77b85f23bd2c47).(ctx->conncxx . . $ updneo_ctx#conn.->devcxx . . $ dyesub_connection#dev.); |
| 153 | } else { |
| 154 | if (ctx->conncxx . . $ updneo_ctx#conn.->typecxx . . $ dyesub_connection#type. == P_SONY_UPD898cxx . . $ P_SONY_UPD898.) { |
| 155 | strcpycxx . . $ strcpy(b7b3a83273496486).(ctx->stscxx . . $ updneo_ctx#sts..scsyicxx . . $ updneo_sts#scsyi., "100005001000050000000000014500"); |
| 156 | } else if (ctx->conncxx . . $ updneo_ctx#conn.->typecxx . . $ dyesub_connection#type. == P_SONY_UP9x1cxx . . $ P_SONY_UP9x1.) { |
| 157 | strcpycxx . . $ strcpy(b7b3a83273496486).(ctx->stscxx . . $ updneo_ctx#sts..scsyicxx . . $ updneo_sts#scsyi., "1E000A001E000A0000000000014500"); |
| 158 | } else if (ctx->conncxx . . $ updneo_ctx#conn.->typecxx . . $ dyesub_connection#type. == P_SONY_UPDR80cxx . . $ P_SONY_UPDR80.) { |
| 159 | strcpycxx . . $ strcpy(b7b3a83273496486).(ctx->stscxx . . $ updneo_ctx#sts..scsyicxx . . $ updneo_sts#scsyi., "0A300E5609A00C7809A00C78012D00"); |
| 160 | } |
| 161 | // XXX don't forget cr20l here! |
| 162 | } |
| 163 | |
| 164 | if (test_modecxx . . $ test_mode. >= TEST_MODE_NOATTACHcxx . . $ TEST_MODE_NOATTACH. && getenvcxx . . $ getenv(a8b8e32347182212).("MEDIA_CODE")) |
| 165 | ctx->markercxx . . $ updneo_ctx#marker..numtypecxx . . $ marker#numtype. = strtolcxx . . $ strtol(44bbb87609b212fc).(getenvcxx . . $ getenv(a8b8e32347182212).("MEDIA_CODE"), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 16); |
| 166 | else |
| 167 | ctx->markercxx . . $ updneo_ctx#marker..numtypecxx . . $ marker#numtype. = (ctx->stscxx . . $ updneo_ctx#sts..scmdicxx . . $ updneo_sts#scmdi. >> 12) & 0xfff; |
| 168 | |
| 169 | ctx->markercxx . . $ updneo_ctx#marker..namecxx . . $ marker#name. = updneo_mediascxx . . $ updneo_medias(81a3ae90da26a711).(ctx->stscxx . . $ updneo_ctx#sts..scmdicxx . . $ updneo_sts#scmdi.); |
| 170 | |
| 171 | if (ctx->conncxx . . $ updneo_ctx#conn.->typecxx . . $ dyesub_connection#type. == P_SONY_UPD898cxx . . $ P_SONY_UPD898. || ctx->conncxx . . $ updneo_ctx#conn.->typecxx . . $ dyesub_connection#type. == P_SONY_UP9x1cxx . . $ P_SONY_UP9x1.) { |
| 172 | ctx->markercxx . . $ updneo_ctx#marker..colorcxx . . $ marker#color. = "#000000"; /* Ie black! */ |
| 173 | ctx->native_bppcxx . . $ updneo_ctx#native_bpp. = 1; |
| 174 | ctx->markercxx . . $ updneo_ctx#marker..levelmaxcxx . . $ marker#levelmax. = CUPS_MARKER_UNAVAILABLEcxx . . $ `src/cups/backend_common.h:376:9`!; |
| 175 | ctx->markercxx . . $ updneo_ctx#marker..levelnowcxx . . $ marker#levelnow. = CUPS_MARKER_UNKNOWNcxx . . $ `src/cups/backend_common.h:377:9`!; |
| 176 | } else { |
| 177 | ctx->markercxx . . $ updneo_ctx#marker..colorcxx . . $ marker#color. = "#00FFFF#FF00FF#FFFF00"; |
| 178 | ctx->native_bppcxx . . $ updneo_ctx#native_bpp. = 3; |
| 179 | ctx->markercxx . . $ updneo_ctx#marker..levelmaxcxx . . $ marker#levelmax. = 50; |
| 180 | ctx->markercxx . . $ updneo_ctx#marker..numtypecxx . . $ marker#numtype. = (ctx->stscxx . . $ updneo_ctx#sts..scmdicxx . . $ updneo_sts#scmdi. >> 12) & 0xfff; |
| 181 | ctx->markercxx . . $ updneo_ctx#marker..levelnowcxx . . $ marker#levelnow. = ctx->stscxx . . $ updneo_ctx#sts..scmdscxx . . $ updneo_sts#scmds.[4]; |
| 182 | } |
| 183 | |
| 184 | return CUPS_BACKEND_OKcxx . . $ `src/cups/backend_common.h:367:9`!; |
| 185 | } |
| 186 | |
| 187 | static void updneo_cleanup_jobcxx . . $ updneo_cleanup_job(e4289f82fef2c2f9).(const void *vjob) |
| 188 | { |
| 189 | const struct updneo_printjobcxx . . $ updneo_printjob# *job = vjob; |
| 190 | |
| 191 | if (job->databufcxx . . $ updneo_printjob#databuf.) |
| 192 | freecxx . . $ free(5d22bdacc48458e8).(job->databufcxx . . $ updneo_printjob#databuf.); |
| 193 | if (job->hdrbufcxx . . $ updneo_printjob#hdrbuf.) |
| 194 | freecxx . . $ free(5d22bdacc48458e8).(job->hdrbufcxx . . $ updneo_printjob#hdrbuf.); |
| 195 | if (job->ftrbufcxx . . $ updneo_printjob#ftrbuf.) |
| 196 | freecxx . . $ free(5d22bdacc48458e8).(job->ftrbufcxx . . $ updneo_printjob#ftrbuf.); |
| 197 | |
| 198 | freecxx . . $ free(5d22bdacc48458e8).((void*)job); |
| 199 | } |
| 200 | |
| 201 | #define MAX_PRINTJOB_LENcxx . . $ `src/cups/backend_sonyupdneo.c:201:9`! (3400*2392*3 + 2048) |
| 202 | |
| 203 | static int updneo_read_parsecxx . . $ updneo_read_parse(296a7ce9eef68a26).(void *vctx, const void **vjob, int data_fd, int copies) { |
| 204 | struct updneo_ctxcxx . . $ updneo_ctx# *ctx = vctx; |
| 205 | int run = 1; |
| 206 | |
| 207 | uint8_tcxx . . $ uint8_t# tmpbuf[257]; |
| 208 | |
| 209 | struct updneo_printjobcxx . . $ updneo_printjob# *job = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 210 | |
| 211 | if (!ctx) |
| 212 | return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!; |
| 213 | |
| 214 | /* Allocate job */ |
| 215 | job = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(sizeof(*job)); |
| 216 | if (!job) { |
| 217 | ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Memory allocation failure!\n"); |
| 218 | return CUPS_BACKEND_RETRY_CURRENTcxx . . $ `src/cups/backend_common.h:374:9`!; |
| 219 | } |
| 220 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(job, 0, sizeof(*job)); |
| 221 | |
| 222 | /* Read in data chunks. */ |
| 223 | while(run) { |
| 224 | uint8_tcxx . . $ uint8_t# *ptr = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 225 | int i, len, *lenptr; |
| 226 | |
| 227 | /* Read in data block header (256 bytes) */ |
| 228 | i = readcxx . . $ read(7e34d0a36f355389).(data_fd, tmpbuf, 256); |
| 229 | if (i < 0) { |
| 230 | ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Read failed (%d)\n", i); |
| 231 | updneo_cleanup_jobcxx . . $ updneo_cleanup_job(e4289f82fef2c2f9).(job); |
| 232 | return CUPS_BACKEND_CANCELcxx . . $ `src/cups/backend_common.h:372:9`!; |
| 233 | } |
| 234 | if (i == 0) |
| 235 | break; |
| 236 | |
| 237 | /* Explicitly null terminate just in case */ |
| 238 | tmpbuf[256] = 0; |
| 239 | |
| 240 | /* Parse header. Format: |
| 241 | |
| 242 | JOBSIZE=pdlname,blocklen,printsize,arg1,..,argN<NULL> |
| 243 | |
| 244 | */ |
| 245 | |
| 246 | if (strncmpcxx . . $ strncmp(fd278af2f295fa2e).("JOBSIZE=", (char*) tmpbuf, 8)) { |
| 247 | updneo_cleanup_jobcxx . . $ updneo_cleanup_job(e4289f82fef2c2f9).(job); |
| 248 | ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Invalid spool format!\n"); |
| 249 | return CUPS_BACKEND_CANCELcxx . . $ `src/cups/backend_common.h:372:9`!; |
| 250 | } |
| 251 | |
| 252 | /* PDL type */ |
| 253 | char *tok = strtokcxx . . $ strtok(b7b3a83273496486).((char*)&tmpbuf[8], "\r\n,"); |
| 254 | if (!tok) { |
| 255 | updneo_cleanup_jobcxx . . $ updneo_cleanup_job(e4289f82fef2c2f9).(job); |
| 256 | ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Invalid spool format (PDL)!\n"); |
| 257 | return CUPS_BACKEND_CANCELcxx . . $ `src/cups/backend_common.h:372:9`!; |
| 258 | } |
| 259 | |
| 260 | /* Payload length */ |
| 261 | const char *tokl = strtokcxx . . $ strtok(b7b3a83273496486).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, "\r\n,"); |
| 262 | if (!tokl) { |
| 263 | updneo_cleanup_jobcxx . . $ updneo_cleanup_job(e4289f82fef2c2f9).(job); |
| 264 | ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Invalid spool format (block length missing)!\n"); |
| 265 | return CUPS_BACKEND_CANCELcxx . . $ `src/cups/backend_common.h:372:9`!; |
| 266 | } |
| 267 | len = atoicxx . . $ atoi(5c4306d8553b3696).(tokl); |
| 268 | if (len == 0 || len > MAX_PRINTJOB_LENcxx . . $ `src/cups/backend_sonyupdneo.c:201:9`!) { |
| 269 | updneo_cleanup_jobcxx . . $ updneo_cleanup_job(e4289f82fef2c2f9).(job); |
| 270 | ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Invalid spool format (block length %d)!\n", len); |
| 271 | return CUPS_BACKEND_CANCELcxx . . $ `src/cups/backend_common.h:372:9`!; |
| 272 | } |
| 273 | |
| 274 | /* Behavior based on the various PDL blocks */ |
| 275 | if (!strncmpcxx . . $ strncmp(fd278af2f295fa2e).("PJL-H", tok, 5)) { |
| 276 | job->hdrbufcxx . . $ updneo_printjob#hdrbuf. = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(len); |
| 277 | if (!job->hdrbufcxx . . $ updneo_printjob#hdrbuf.) { |
| 278 | ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Memory allocation failure!\n"); |
| 279 | updneo_cleanup_jobcxx . . $ updneo_cleanup_job(e4289f82fef2c2f9).(job); |
| 280 | return CUPS_BACKEND_RETRY_CURRENTcxx . . $ `src/cups/backend_common.h:374:9`!; |
| 281 | } |
| 282 | ptr = job->hdrbufcxx . . $ updneo_printjob#hdrbuf.; |
| 283 | lenptr = &job->hdrlencxx . . $ updneo_printjob#hdrlen.; |
| 284 | } else if (!strncmpcxx . . $ strncmp(fd278af2f295fa2e).("PJL-T", tok, 5)) { |
| 285 | job->ftrbufcxx . . $ updneo_printjob#ftrbuf. = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(len); |
| 286 | if (!job->ftrbufcxx . . $ updneo_printjob#ftrbuf.) { |
| 287 | ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Memory allocation failure!\n"); |
| 288 | updneo_cleanup_jobcxx . . $ updneo_cleanup_job(e4289f82fef2c2f9).(job); |
| 289 | return CUPS_BACKEND_RETRY_CURRENTcxx . . $ `src/cups/backend_common.h:374:9`!; |
| 290 | } |
| 291 | ptr = job->ftrbufcxx . . $ updneo_printjob#ftrbuf.; |
| 292 | lenptr = &job->ftrlencxx . . $ updneo_printjob#ftrlen.; |
| 293 | run = 0; |
| 294 | } else if (!strncmpcxx . . $ strncmp(fd278af2f295fa2e).("PDL", tok, 3)) { |
| 295 | job->databufcxx . . $ updneo_printjob#databuf. = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(len); |
| 296 | if (!job->databufcxx . . $ updneo_printjob#databuf.) { |
| 297 | ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Memory allocation failure!\n"); |
| 298 | updneo_cleanup_jobcxx . . $ updneo_cleanup_job(e4289f82fef2c2f9).(job); |
| 299 | return CUPS_BACKEND_RETRY_CURRENTcxx . . $ `src/cups/backend_common.h:374:9`!; |
| 300 | } |
| 301 | ptr = job->databufcxx . . $ updneo_printjob#databuf.; |
| 302 | lenptr = &job->datalencxx . . $ updneo_printjob#datalen.; |
| 303 | } else { |
| 304 | ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Unrecognized PDL type '%s'\n", tok); |
| 305 | updneo_cleanup_jobcxx . . $ updneo_cleanup_job(e4289f82fef2c2f9).(job); |
| 306 | return CUPS_BACKEND_CANCELcxx . . $ `src/cups/backend_common.h:372:9`!; |
| 307 | } |
| 308 | |
| 309 | // DEBUG("Read block '%s' @ %d ...\n", tok, job->datalen); |
| 310 | |
| 311 | // DEBUG("...len '%d'\n", len); |
| 312 | |
| 313 | // parse the rest? |
| 314 | // 898MD: 6,0,0,0 |
| 315 | // D80MD: 4 |
| 316 | // CR20L: 64,0,0,0 |
| 317 | |
| 318 | /* Read in the data chunk */ |
| 319 | while(len > 0) { |
| 320 | i = readcxx . . $ read(7e34d0a36f355389).(data_fd, ptr + *lenptr, len); |
| 321 | if (i < 0) { |
| 322 | updneo_cleanup_jobcxx . . $ updneo_cleanup_job(e4289f82fef2c2f9).(job); |
| 323 | return CUPS_BACKEND_CANCELcxx . . $ `src/cups/backend_common.h:372:9`!; |
| 324 | } |
| 325 | if (i == 0) |
| 326 | break; |
| 327 | |
| 328 | *lenptr += i; |
| 329 | len -= i; |
| 330 | } |
| 331 | } |
| 332 | |
| 333 | if (!job->datalencxx . . $ updneo_printjob#datalen. || !job->hdrlencxx . . $ updneo_printjob#hdrlen. || !job->ftrlencxx . . $ updneo_printjob#ftrlen.) { |
| 334 | if (job->datalencxx . . $ updneo_printjob#datalen. + job->hdrlencxx . . $ updneo_printjob#hdrlen. + job->ftrlencxx . . $ updneo_printjob#ftrlen.) { |
| 335 | ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Necessary block missing!\n"); |
| 336 | } |
| 337 | updneo_cleanup_jobcxx . . $ updneo_cleanup_job(e4289f82fef2c2f9).(job); |
| 338 | return CUPS_BACKEND_CANCELcxx . . $ `src/cups/backend_common.h:372:9`!; |
| 339 | } |
| 340 | |
| 341 | /* Sanity check job parameters */ |
| 342 | |
| 343 | /* Validate against max print size in SCSYI */ |
| 344 | { |
| 345 | char w[5], h[5]; |
| 346 | uint16_tcxx . . $ uint16_t# mw, mh; |
| 347 | uint16_tcxx . . $ uint16_t# jw, jh; |
| 348 | memcpycxx . . $ memcpy(cc817cb175f282d).(w, ctx->stscxx . . $ updneo_ctx#sts..scsyicxx . . $ updneo_sts#scsyi., 4); |
| 349 | h[4] = 0; |
| 350 | memcpycxx . . $ memcpy(cc817cb175f282d).(h, ctx->stscxx . . $ updneo_ctx#sts..scsyicxx . . $ updneo_sts#scsyi. + 4, 4); |
| 351 | w[4] = 0; |
| 352 | |
| 353 | if (ctx->conncxx . . $ updneo_ctx#conn.->typecxx . . $ dyesub_connection#type. == P_SONY_UPD898cxx . . $ P_SONY_UPD898. || ctx->conncxx . . $ updneo_ctx#conn.->typecxx . . $ dyesub_connection#type. == P_SONY_UP9x1cxx . . $ P_SONY_UP9x1.) { |
| 354 | mw = strtolcxx . . $ strtol(44bbb87609b212fc).(h, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 16); |
| 355 | mh = strtolcxx . . $ strtol(44bbb87609b212fc).(w, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 16); |
| 356 | } else { |
| 357 | mw = strtolcxx . . $ strtol(44bbb87609b212fc).(w, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 16); |
| 358 | mh = strtolcxx . . $ strtol(44bbb87609b212fc).(h, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 16); |
| 359 | } |
| 360 | |
| 361 | if (ctx->conncxx . . $ updneo_ctx#conn.->typecxx . . $ dyesub_connection#type. == P_SONY_UPDR80cxx . . $ P_SONY_UPDR80.) { |
| 362 | memcpycxx . . $ memcpy(cc817cb175f282d).(&jw, job->databufcxx . . $ updneo_printjob#databuf. + 84, 2); |
| 363 | memcpycxx . . $ memcpy(cc817cb175f282d).(&jh, job->databufcxx . . $ updneo_printjob#databuf. + 84 + 2, 2); |
| 364 | } else { |
| 365 | memcpycxx . . $ memcpy(cc817cb175f282d).(&jw, job->databufcxx . . $ updneo_printjob#databuf. + 40, 2); |
| 366 | memcpycxx . . $ memcpy(cc817cb175f282d).(&jh, job->databufcxx . . $ updneo_printjob#databuf. + 40 + 2, 2); |
| 367 | } |
| 368 | |
| 369 | jw = be16_to_cpucxx . . $ `src/cups/backend_common.h:69:9`!(jw); |
| 370 | jh = be16_to_cpucxx . . $ `src/cups/backend_common.h:69:9`!(jh); |
| 371 | |
| 372 | if (mw && mh && (jw > mw || jh > mh)) { |
| 373 | ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Job (%d/%d) exceeds max dimensions(%d/%d)\n", |
| 374 | jw,jh,mw,mh); |
| 375 | updneo_cleanup_jobcxx . . $ updneo_cleanup_job(e4289f82fef2c2f9).(job); |
| 376 | return CUPS_BACKEND_CANCELcxx . . $ `src/cups/backend_common.h:372:9`!; |
| 377 | } |
| 378 | } |
| 379 | |
| 380 | // XXX Check vs loaded media type (ctx->marker.numtype?) |
| 381 | |
| 382 | // XXX set job copies to max(job, parameter)? |
| 383 | /* Find copy offset */ |
| 384 | for (int i = 0 ; i < 312 ; i++ ) { |
| 385 | if (job->databufcxx . . $ updneo_printjob#databuf.[i] == 0x02 && |
| 386 | job->databufcxx . . $ updneo_printjob#databuf.[i+1] == 0x00 && |
| 387 | job->databufcxx . . $ updneo_printjob#databuf.[i+2] == 0x09) { |
| 388 | if (job->databufcxx . . $ updneo_printjob#databuf.[i+4] < copies) |
| 389 | job->databufcxx . . $ updneo_printjob#databuf.[i+4] = copies; |
| 390 | else |
| 391 | copies = job->databufcxx . . $ updneo_printjob#databuf.[i+4]; |
| 392 | break; |
| 393 | } |
| 394 | } |
| 395 | job->commoncxx . . $ updneo_printjob#common..copiescxx . . $ dyesub_job_common#copies. = copies; |
| 396 | |
| 397 | *vjob = job; |
| 398 | |
| 399 | return CUPS_BACKEND_OKcxx . . $ `src/cups/backend_common.h:367:9`!; |
| 400 | } |
| 401 | |
| 402 | static int dlencxx . . $ dlen.; |
| 403 | static struct deviceid_dictcxx . . $ deviceid_dict# dictcxx . . $ dict.[MAX_DICTcxx . . $ `src/cups/backend_common.h:94:9`!]; |
| 404 | |
| 405 | static int updneo_get_statuscxx . . $ updneo_get_status(e4141a2cf98b3e47).(struct updneo_ctxcxx . . $ updneo_ctx# *ctx) |
| 406 | { |
| 407 | char *ieee_id = get_device_idcxx . . $ get_device_id(d6081702c9abc218).(ctx->conncxx . . $ updneo_ctx#conn.->devcxx . . $ dyesub_connection#dev., ctx->conncxx . . $ updneo_ctx#conn.->ifacecxx . . $ dyesub_connection#iface.); |
| 408 | int i; |
| 409 | |
| 410 | if (!ieee_id) |
| 411 | return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!; |
| 412 | |
| 413 | dlencxx . . $ dlen. = parse1284_datacxx . . $ parse1284_data(70f86c7be5cd5865).(ieee_id, dictcxx . . $ dict.); |
| 414 | |
| 415 | /* Don't forget to log! */ |
| 416 | if (dyesub_debugcxx . . $ dyesub_debug. >= 1) { |
| 417 | DEBUGcxx . . $ `src/cups/backend_common.h:59:9`!("IEEE1284: (%d) %s\n", dlen, ieee_id); |
| 418 | } |
| 419 | |
| 420 | /* Parse out data */ |
| 421 | for (i = 0; i < dlencxx . . $ dlen. ; i++) { |
| 422 | if(!dictcxx . . $ dict.[i].keycxx . . $ deviceid_dict#key. || !dictcxx . . $ dict.[i].valcxx . . $ deviceid_dict#val.) |
| 423 | continue; |
| 424 | if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).("SCDIV", dictcxx . . $ dict.[i].keycxx . . $ deviceid_dict#key.)) { |
| 425 | ctx->stscxx . . $ updneo_ctx#sts..scdivcxx . . $ updneo_sts#scdiv. = strtolcxx . . $ strtol(44bbb87609b212fc).(dictcxx . . $ dict.[i].valcxx . . $ deviceid_dict#val., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 16); |
| 426 | } else if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).("SCSYV", dictcxx . . $ dict.[i].keycxx . . $ deviceid_dict#key.)) { |
| 427 | ctx->stscxx . . $ updneo_ctx#sts..scsyvcxx . . $ updneo_sts#scsyv. = strtolcxx . . $ strtol(44bbb87609b212fc).(dictcxx . . $ dict.[i].valcxx . . $ deviceid_dict#val., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 16); |
| 428 | } else if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).("SCSNO", dictcxx . . $ dict.[i].keycxx . . $ deviceid_dict#key.)) { |
| 429 | strncpycxx . . $ strncpy(255158a415b673b0).(ctx->stscxx . . $ updneo_ctx#sts..scsnocxx . . $ updneo_sts#scsno., dictcxx . . $ dict.[i].valcxx . . $ deviceid_dict#val., sizeof(ctx->stscxx . . $ updneo_ctx#sts..scsnocxx . . $ updneo_sts#scsno.) - 1); |
| 430 | |
| 431 | /* Trim trailing '-'s off of serial number (UP-D898, UP-9x1), UP-DR80MD, etc */ |
| 432 | for (int j = 0; j < (int) sizeof(ctx->stscxx . . $ updneo_ctx#sts..scsnocxx . . $ updneo_sts#scsno.); j++) { |
| 433 | if (ctx->stscxx . . $ updneo_ctx#sts..scsnocxx . . $ updneo_sts#scsno.[j] == '-') { |
| 434 | ctx->stscxx . . $ updneo_ctx#sts..scsnocxx . . $ updneo_sts#scsno.[j] = 0; |
| 435 | break; |
| 436 | } |
| 437 | } |
| 438 | } else if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).("SCSYS", dictcxx . . $ dict.[i].keycxx . . $ deviceid_dict#key.)) { |
| 439 | strncpycxx . . $ strncpy(255158a415b673b0).(ctx->stscxx . . $ updneo_ctx#sts..scsyscxx . . $ updneo_sts#scsys., dictcxx . . $ dict.[i].valcxx . . $ deviceid_dict#val., sizeof(ctx->stscxx . . $ updneo_ctx#sts..scsyscxx . . $ updneo_sts#scsys.) - 1); |
| 440 | } else if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).("SCMDS", dictcxx . . $ dict.[i].keycxx . . $ deviceid_dict#key.)) { |
| 441 | int j; |
| 442 | char buf[5]; |
| 443 | buf[4] = 0; |
| 444 | for (j = 0 ; j < 5 ; j++) { |
| 445 | memcpycxx . . $ memcpy(cc817cb175f282d).(buf, dictcxx . . $ dict.[i].valcxx . . $ deviceid_dict#val. + (4*j), 4); |
| 446 | ctx->stscxx . . $ updneo_ctx#sts..scmdscxx . . $ updneo_sts#scmds.[j] = strtolcxx . . $ strtol(44bbb87609b212fc).(buf, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 16); |
| 447 | } |
| 448 | } else if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).("SCPRS", dictcxx . . $ dict.[i].keycxx . . $ deviceid_dict#key.)) { |
| 449 | ctx->stscxx . . $ updneo_ctx#sts..scprscxx . . $ updneo_sts#scprs. = strtolcxx . . $ strtol(44bbb87609b212fc).(dictcxx . . $ dict.[i].valcxx . . $ deviceid_dict#val., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 16); |
| 450 | } else if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).("SCSES", dictcxx . . $ dict.[i].keycxx . . $ deviceid_dict#key.)) { |
| 451 | ctx->stscxx . . $ updneo_ctx#sts..scsescxx . . $ updneo_sts#scses. = strtolcxx . . $ strtol(44bbb87609b212fc).(dictcxx . . $ dict.[i].valcxx . . $ deviceid_dict#val., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 16); |
| 452 | } else if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).("SCWTS", dictcxx . . $ dict.[i].keycxx . . $ deviceid_dict#key.)) { |
| 453 | ctx->stscxx . . $ updneo_ctx#sts..scwtscxx . . $ updneo_sts#scwts. = strtolcxx . . $ strtol(44bbb87609b212fc).(dictcxx . . $ dict.[i].valcxx . . $ deviceid_dict#val., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 16); |
| 454 | } else if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).("SCJBS", dictcxx . . $ dict.[i].keycxx . . $ deviceid_dict#key.)) { |
| 455 | ctx->stscxx . . $ updneo_ctx#sts..scjbscxx . . $ updneo_sts#scjbs. = strtolcxx . . $ strtol(44bbb87609b212fc).(dictcxx . . $ dict.[i].valcxx . . $ deviceid_dict#val., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 16); |
| 456 | } else if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).("SCSYE", dictcxx . . $ dict.[i].keycxx . . $ deviceid_dict#key.)) { |
| 457 | ctx->stscxx . . $ updneo_ctx#sts..scsyecxx . . $ updneo_sts#scsye. = strtolcxx . . $ strtol(44bbb87609b212fc).(dictcxx . . $ dict.[i].valcxx . . $ deviceid_dict#val., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 16); |
| 458 | } else if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).("SCMDE", dictcxx . . $ dict.[i].keycxx . . $ deviceid_dict#key.)) { |
| 459 | ctx->stscxx . . $ updneo_ctx#sts..scmdecxx . . $ updneo_sts#scmde. = strtolcxx . . $ strtol(44bbb87609b212fc).(dictcxx . . $ dict.[i].valcxx . . $ deviceid_dict#val., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 16); |
| 460 | } else if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).("SCMCE", dictcxx . . $ dict.[i].keycxx . . $ deviceid_dict#key.)) { |
| 461 | ctx->stscxx . . $ updneo_ctx#sts..scmcecxx . . $ updneo_sts#scmce. = strtolcxx . . $ strtol(44bbb87609b212fc).(dictcxx . . $ dict.[i].valcxx . . $ deviceid_dict#val., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 16); |
| 462 | } else if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).("SCJBI", dictcxx . . $ dict.[i].keycxx . . $ deviceid_dict#key.)) { |
| 463 | strncpycxx . . $ strncpy(255158a415b673b0).(ctx->stscxx . . $ updneo_ctx#sts..scjbicxx . . $ updneo_sts#scjbi., dictcxx . . $ dict.[i].valcxx . . $ deviceid_dict#val., sizeof(ctx->stscxx . . $ updneo_ctx#sts..scjbicxx . . $ updneo_sts#scjbi.) - 1); |
| 464 | } else if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).("SCSYI", dictcxx . . $ dict.[i].keycxx . . $ deviceid_dict#key.)) { |
| 465 | strncpycxx . . $ strncpy(255158a415b673b0).(ctx->stscxx . . $ updneo_ctx#sts..scsyicxx . . $ updneo_sts#scsyi., dictcxx . . $ dict.[i].valcxx . . $ deviceid_dict#val., sizeof(ctx->stscxx . . $ updneo_ctx#sts..scsyicxx . . $ updneo_sts#scsyi.) - 1); |
| 466 | } else if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).("SCSVI", dictcxx . . $ dict.[i].keycxx . . $ deviceid_dict#key.)) { |
| 467 | int j; |
| 468 | char buf[7]; |
| 469 | buf[6] = 0; |
| 470 | for (j = 0 ; j < 2 ; j++) { |
| 471 | memcpycxx . . $ memcpy(cc817cb175f282d).(buf, dictcxx . . $ dict.[i].valcxx . . $ deviceid_dict#val. + (6*j), 6); |
| 472 | ctx->stscxx . . $ updneo_ctx#sts..scsvicxx . . $ updneo_sts#scsvi.[j] = strtolcxx . . $ strtol(44bbb87609b212fc).(buf, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 16); |
| 473 | } |
| 474 | } else if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).("SCMNI", dictcxx . . $ dict.[i].keycxx . . $ deviceid_dict#key.)) { |
| 475 | int j; |
| 476 | char buf[7]; |
| 477 | buf[6] = 0; |
| 478 | for (j = 0 ; j < 2 ; j++) { |
| 479 | memcpycxx . . $ memcpy(cc817cb175f282d).(buf, dictcxx . . $ dict.[i].valcxx . . $ deviceid_dict#val. + (6*j), 6); |
| 480 | ctx->stscxx . . $ updneo_ctx#sts..scmnicxx . . $ updneo_sts#scmni.[j] = strtolcxx . . $ strtol(44bbb87609b212fc).(buf, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 16); |
| 481 | } |
| 482 | } else if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).("SCCAI", dictcxx . . $ dict.[i].keycxx . . $ deviceid_dict#key.)) { |
| 483 | strncpycxx . . $ strncpy(255158a415b673b0).(ctx->stscxx . . $ updneo_ctx#sts..sccaicxx . . $ updneo_sts#sccai., dictcxx . . $ dict.[i].valcxx . . $ deviceid_dict#val., sizeof(ctx->stscxx . . $ updneo_ctx#sts..sccaicxx . . $ updneo_sts#sccai.) - 1); |
| 484 | } else if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).("SCGAI", dictcxx . . $ dict.[i].keycxx . . $ deviceid_dict#key.)) { |
| 485 | ctx->stscxx . . $ updneo_ctx#sts..scgaicxx . . $ updneo_sts#scgai. = strtolcxx . . $ strtol(44bbb87609b212fc).(dictcxx . . $ dict.[i].valcxx . . $ deviceid_dict#val., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 16); |
| 486 | } else if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).("SCGSI", dictcxx . . $ dict.[i].keycxx . . $ deviceid_dict#key.)) { |
| 487 | ctx->stscxx . . $ updneo_ctx#sts..scgsicxx . . $ updneo_sts#scgsi. = strtolcxx . . $ strtol(44bbb87609b212fc).(dictcxx . . $ dict.[i].valcxx . . $ deviceid_dict#val., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 16); |
| 488 | } else if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).("SCMDI", dictcxx . . $ dict.[i].keycxx . . $ deviceid_dict#key.)) { |
| 489 | ctx->stscxx . . $ updneo_ctx#sts..scmdicxx . . $ updneo_sts#scmdi. = strtolcxx . . $ strtol(44bbb87609b212fc).(dictcxx . . $ dict.[i].valcxx . . $ deviceid_dict#val., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 16); |
| 490 | } else if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).("SCQTI", dictcxx . . $ dict.[i].keycxx . . $ deviceid_dict#key.)) { |
| 491 | ctx->stscxx . . $ updneo_ctx#sts..scqticxx . . $ updneo_sts#scqti. = strtolcxx . . $ strtol(44bbb87609b212fc).(dictcxx . . $ dict.[i].valcxx . . $ deviceid_dict#val., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 16); |
| 492 | } else if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).("SPUQI", dictcxx . . $ dict.[i].keycxx . . $ deviceid_dict#key.)) { |
| 493 | ctx->stscxx . . $ updneo_ctx#sts..spuqicxx . . $ updneo_sts#spuqi. = strtolcxx . . $ strtol(44bbb87609b212fc).(dictcxx . . $ dict.[i].valcxx . . $ deviceid_dict#val., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 16); |
| 494 | } else if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).("MFG", dictcxx . . $ dict.[i].keycxx . . $ deviceid_dict#key.) || |
| 495 | !strcmpcxx . . $ strcmp(5ae29d726ae57f88).("MDL", dictcxx . . $ dict.[i].keycxx . . $ deviceid_dict#key.) || |
| 496 | !strcmpcxx . . $ strcmp(5ae29d726ae57f88).("DES", dictcxx . . $ dict.[i].keycxx . . $ deviceid_dict#key.) || |
| 497 | !strcmpcxx . . $ strcmp(5ae29d726ae57f88).("CMD", dictcxx . . $ dict.[i].keycxx . . $ deviceid_dict#key.) || |
| 498 | !strcmpcxx . . $ strcmp(5ae29d726ae57f88).("CLS", dictcxx . . $ dict.[i].keycxx . . $ deviceid_dict#key.)) { |
| 499 | /* Ignore standard IEEE1284 attributes! */ |
| 500 | } else { |
| 501 | if (!strncmpcxx . . $ strncmp(fd278af2f295fa2e).("SC", dictcxx . . $ dict.[i].keycxx . . $ deviceid_dict#key., 2) || !strncmpcxx . . $ strncmp(fd278af2f295fa2e).("SP", dictcxx . . $ dict.[i].keycxx . . $ deviceid_dict#key., 2)) |
| 502 | DEBUGcxx . . $ `src/cups/backend_common.h:59:9`!("Extra/Unknown IEEE1284 field '%s' = '%s'\n", |
| 503 | dict[i].key, dict[i].val); |
| 504 | } |
| 505 | |
| 506 | }; |
| 507 | |
| 508 | /* Clean up */ |
| 509 | if (ieee_id) freecxx . . $ free(5d22bdacc48458e8).(ieee_id); |
| 510 | while (dlencxx . . $ dlen.--) { |
| 511 | freecxx . . $ free(5d22bdacc48458e8). (dictcxx . . $ dict.[dlencxx . . $ dlen.].keycxx . . $ deviceid_dict#key.); |
| 512 | freecxx . . $ free(5d22bdacc48458e8). (dictcxx . . $ dict.[dlencxx . . $ dlen.].valcxx . . $ deviceid_dict#val.); |
| 513 | } |
| 514 | |
| 515 | return CUPS_BACKEND_OKcxx . . $ `src/cups/backend_common.h:367:9`!; |
| 516 | } |
| 517 | |
| 518 | static void updneo_dump_statuscxx . . $ updneo_dump_status(a717171ab62eb1dc).(struct updneo_ctxcxx . . $ updneo_ctx# *ctx, struct updneo_stscxx . . $ updneo_sts# *sts) |
| 519 | { |
| 520 | /* Dump status */ |
| 521 | INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Serial Number: %s\n", sts->scsno); |
| 522 | INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Firmware Version: %02x.%02x.%02x.%02x\n", |
| 523 | (sts->scsyv >> 24) & 0xff, |
| 524 | (sts->scsyv >> 16) & 0xff, |
| 525 | (sts->scsyv >> 8) & 0xff, |
| 526 | (sts->scsyv >> 0) & 0xff); |
| 527 | INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Media type: %s\n", updneo_medias(sts->scmdi)); |
| 528 | |
| 529 | if (ctx->conncxx . . $ updneo_ctx#conn.->typecxx . . $ dyesub_connection#type. == P_SONY_UPDR80cxx . . $ P_SONY_UPDR80.) |
| 530 | INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Remaining prints: %u/50\n", sts->scmds[4]); |
| 531 | |
| 532 | INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Print count: %u\n", sts->scsvi[0]); |
| 533 | |
| 534 | /* If the printer reports an error, pass it on */ |
| 535 | if (sts->scmdecxx . . $ updneo_sts#scmde. || sts->scmcecxx . . $ updneo_sts#scmce. || sts->scsyecxx . . $ updneo_sts#scsye.) { |
| 536 | ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Printer error: %s (MD=%04x, MC=%02x, SY=%02x)\n", |
| 537 | updneo_decode_errors(sts->scmde, sts->scmce, sts->scsye), |
| 538 | sts->scmde, sts->scmce, sts->scsye); |
| 539 | } |
| 540 | } |
| 541 | |
| 542 | static int updneo_main_loopcxx . . $ updneo_main_loop(91e54fd90adbb21).(void *vctx, const void *vjob, int wait_for_return) { |
| 543 | struct updneo_ctxcxx . . $ updneo_ctx# *ctx = vctx; |
| 544 | int ret; |
| 545 | |
| 546 | const struct updneo_printjobcxx . . $ updneo_printjob# *job = vjob; |
| 547 | |
| 548 | if (!ctx) |
| 549 | return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!; |
| 550 | if (!job) |
| 551 | return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!; |
| 552 | |
| 553 | // XXX update/insert stream to include job->common.copies parameter |
| 554 | top: |
| 555 | |
| 556 | /* Query printer status */ |
| 557 | if ((ret = updneo_get_statuscxx . . $ updneo_get_status(e4141a2cf98b3e47).(ctx))) { |
| 558 | return ret; |
| 559 | } |
| 560 | |
| 561 | /* If the printer reports an error, bail */ |
| 562 | if (ctx->stscxx . . $ updneo_ctx#sts..scmdecxx . . $ updneo_sts#scmde. || ctx->stscxx . . $ updneo_ctx#sts..scmcecxx . . $ updneo_sts#scmce. || ctx->stscxx . . $ updneo_ctx#sts..scsyecxx . . $ updneo_sts#scsye.) { |
| 563 | ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Printer error: %s (MD=%04x, MC=%02x, SY=%02x)\n", |
| 564 | updneo_decode_errors(ctx->sts.scmde, ctx->sts.scmce, ctx->sts.scsye), |
| 565 | ctx->sts.scmde, ctx->sts.scmce, ctx->sts.scsye); |
| 566 | return CUPS_BACKEND_STOPcxx . . $ `src/cups/backend_common.h:371:9`!; |
| 567 | } |
| 568 | /* Wait for the printer to become idle */ |
| 569 | if (ctx->stscxx . . $ updneo_ctx#sts..scprscxx . . $ updneo_sts#scprs.) { |
| 570 | sleepcxx . . $ sleep(2141b656ce2cc063).(1); |
| 571 | goto top; |
| 572 | } |
| 573 | |
| 574 | /* Send over header */ |
| 575 | if ((ret = send_datacxx . . $ send_data(b2b51896d93e30f1).(ctx->conncxx . . $ updneo_ctx#conn., |
| 576 | job->hdrbufcxx . . $ updneo_printjob#hdrbuf., job->hdrlencxx . . $ updneo_printjob#hdrlen.))) |
| 577 | return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!; |
| 578 | |
| 579 | /* Send over data */ |
| 580 | if ((ret = send_datacxx . . $ send_data(b2b51896d93e30f1).(ctx->conncxx . . $ updneo_ctx#conn., |
| 581 | job->databufcxx . . $ updneo_printjob#databuf., job->datalencxx . . $ updneo_printjob#datalen.))) |
| 582 | return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!; |
| 583 | |
| 584 | /* Send over footer */ |
| 585 | if ((ret = send_datacxx . . $ send_data(b2b51896d93e30f1).(ctx->conncxx . . $ updneo_ctx#conn., |
| 586 | job->ftrbufcxx . . $ updneo_printjob#ftrbuf., job->ftrlencxx . . $ updneo_printjob#ftrlen.))) |
| 587 | return CUPS_BACKEND_FAILEDcxx . . $ `src/cups/backend_common.h:368:9`!; |
| 588 | |
| 589 | /* Wait for completion! */ |
| 590 | retry: |
| 591 | sleepcxx . . $ sleep(2141b656ce2cc063).(1); |
| 592 | |
| 593 | if ((ret = updneo_get_statuscxx . . $ updneo_get_status(e4141a2cf98b3e47).(ctx))) { |
| 594 | return ret; |
| 595 | } |
| 596 | |
| 597 | /* If the printer reports an error, bail */ |
| 598 | if (ctx->stscxx . . $ updneo_ctx#sts..scmdecxx . . $ updneo_sts#scmde. || ctx->stscxx . . $ updneo_ctx#sts..scmcecxx . . $ updneo_sts#scmce. || ctx->stscxx . . $ updneo_ctx#sts..scsyecxx . . $ updneo_sts#scsye.) { |
| 599 | ERRORcxx . . $ `src/cups/backend_common.h:63:9`!("Printer error: %s (MD=%04x, MC=%02x, SY=%02x)\n", |
| 600 | updneo_decode_errors(ctx->sts.scmde, ctx->sts.scmce, ctx->sts.scsye), |
| 601 | ctx->sts.scmde, ctx->sts.scmce, ctx->sts.scsye); |
| 602 | return CUPS_BACKEND_STOPcxx . . $ `src/cups/backend_common.h:371:9`!; |
| 603 | } |
| 604 | |
| 605 | /* See if we're busy... */ |
| 606 | if (ctx->stscxx . . $ updneo_ctx#sts..scprscxx . . $ updneo_sts#scprs. != 0) { |
| 607 | if (!wait_for_return) { |
| 608 | INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Fast return mode enabled.\n"); |
| 609 | } else { |
| 610 | goto retry; |
| 611 | } |
| 612 | } |
| 613 | |
| 614 | INFOcxx . . $ `src/cups/backend_common.h:61:9`!("Print complete\n"); |
| 615 | |
| 616 | if (ctx->native_bppcxx . . $ updneo_ctx#native_bpp. == 1) /* Necessary for UP-D898 and 9x1 */ |
| 617 | libusb_reset_devicecxx . . $ libusb_reset_device(dd77b85f23bd2c47).(ctx->conncxx . . $ updneo_ctx#conn.->devcxx . . $ dyesub_connection#dev.); |
| 618 | |
| 619 | return CUPS_BACKEND_OKcxx . . $ `src/cups/backend_common.h:367:9`!; |
| 620 | } |
| 621 | |
| 622 | static void updneo_cmdlinecxx . . $ updneo_cmdline(49f6e7a06ebc5aa8).(void) |
| 623 | { |
| 624 | DEBUGcxx . . $ `src/cups/backend_common.h:59:9`!("\t\t[ -s ] # Query status\n"); |
| 625 | } |
| 626 | |
| 627 | static int updneo_cmdline_argcxx . . $ updneo_cmdline_arg(bd8af97f5fa850e1).(void *vctx, int argc, char **argv) |
| 628 | { |
| 629 | struct updneo_ctxcxx . . $ updneo_ctx# *ctx = vctx; |
| 630 | int i, j = 0; |
| 631 | |
| 632 | if (!ctx) |
| 633 | return -1; |
| 634 | |
| 635 | while ((i = getoptcxx . . $ getopt(2483c31ff9bab884).(argc, argv, GETOPT_LIST_GLOBALcxx . . $ `src/cups/backend_common.h:381:9`! "s")) >= 0) { |
| 636 | switch(i) { |
| 637 | GETOPT_PROCESS_GLOBALcxx . . $ `src/cups/backend_common.h:382:9`! |
| 638 | case 's': |
| 639 | j = updneo_get_statuscxx . . $ updneo_get_status(e4141a2cf98b3e47).(ctx); |
| 640 | if (!j) |
| 641 | updneo_dump_statuscxx . . $ updneo_dump_status(a717171ab62eb1dc).(ctx, &ctx->stscxx . . $ updneo_ctx#sts.); |
| 642 | break; |
| 643 | } |
| 644 | |
| 645 | if (j) return j; |
| 646 | } |
| 647 | |
| 648 | return CUPS_BACKEND_OKcxx . . $ `src/cups/backend_common.h:367:9`!; |
| 649 | } |
| 650 | |
| 651 | static int updneo_query_sernocxx . . $ updneo_query_serno(a3ebabf18f8093e8).(struct dyesub_connectioncxx . . $ dyesub_connection# *conn, char *buf, int buf_len) |
| 652 | { |
| 653 | int ret; |
| 654 | char *ptr; |
| 655 | struct updneo_ctxcxx . . $ updneo_ctx# ctx = { |
| 656 | .conn = conn, |
| 657 | }; |
| 658 | if ((ret = updneo_get_statuscxx . . $ updneo_get_status(e4141a2cf98b3e47).(&ctx))) { |
| 659 | return ret; |
| 660 | } |
| 661 | ptr = ctx.stscxx . . $ updneo_ctx#sts..scsnocxx . . $ updneo_sts#scsno.; |
| 662 | while (*ptr == 0x30) ptr++; |
| 663 | strncpycxx . . $ strncpy(255158a415b673b0).(buf, ptr, buf_len); |
| 664 | buf[buf_len-1] = 0; |
| 665 | return CUPS_BACKEND_OKcxx . . $ `src/cups/backend_common.h:367:9`!; |
| 666 | } |
| 667 | |
| 668 | static int updneo_query_markerscxx . . $ updneo_query_markers(5f0c51117cc67eb5).(void *vctx, struct markercxx . . $ marker# **markers, int *count) |
| 669 | { |
| 670 | struct updneo_ctxcxx . . $ updneo_ctx# *ctx = vctx; |
| 671 | int ret; |
| 672 | |
| 673 | *markers = &ctx->markercxx . . $ updneo_ctx#marker.; |
| 674 | *count = 1; |
| 675 | |
| 676 | /* Query printer status */ |
| 677 | if ((ret = updneo_get_statuscxx . . $ updneo_get_status(e4141a2cf98b3e47).(ctx))) { |
| 678 | return ret; |
| 679 | } |
| 680 | |
| 681 | if (ctx->conncxx . . $ updneo_ctx#conn.->typecxx . . $ dyesub_connection#type. != P_SONY_UPD898cxx . . $ P_SONY_UPD898. && ctx->conncxx . . $ updneo_ctx#conn.->typecxx . . $ dyesub_connection#type. != P_SONY_UP9x1cxx . . $ P_SONY_UP9x1.) { |
| 682 | ctx->markercxx . . $ updneo_ctx#marker..levelnowcxx . . $ marker#levelnow. = ctx->stscxx . . $ updneo_ctx#sts..scmdscxx . . $ updneo_sts#scmds.[4]; |
| 683 | } |
| 684 | |
| 685 | return CUPS_BACKEND_OKcxx . . $ `src/cups/backend_common.h:367:9`!; |
| 686 | } |
| 687 | |
| 688 | static const char *sonyupdneo_prefixescxx . . $ sonyupdneo_prefixes.[] = { |
| 689 | "sonyupdneo", /* Family Name */ |
| 690 | "dnp-sl20", // extra, unknown if shared with CR20L |
| 691 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! |
| 692 | }; |
| 693 | |
| 694 | static const struct device_idcxx . . $ device_id# sonyupdneo_devicescxx . . $ sonyupdneo_devices.[] = { |
| 695 | { 0x054c, 0x0877, P_SONY_UPD898cxx . . $ P_SONY_UPD898., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, "sony-upd898"}, |
| 696 | // { 0x054c, 0x589a, P_SONY_UPD898, NULL, "sony-upd898"}, // ??? |
| 697 | { 0x054c, 0xbcde, P_SONY_UPCR20Lcxx . . $ P_SONY_UPCR20L., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, "sony-upcr20l"}, // XXXX |
| 698 | { 0x054c, 0x03c5, P_SONY_UPDR80cxx . . $ P_SONY_UPDR80., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, "sony-updr80"}, |
| 699 | { 0x054c, 0x03c3, P_SONY_UPDR80cxx . . $ P_SONY_UPDR80., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, "sony-updr80md"}, |
| 700 | { 0x054c, 0x03c4, P_SONY_UPDR80cxx . . $ P_SONY_UPDR80., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, "stryker-sdp1000"}, |
| 701 | { 0x054c, 0x0873, P_SONY_UP9x1cxx . . $ P_SONY_UP9x1., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, "sony-up971ad"}, |
| 702 | // { 0x054c, 0x0873, P_SONY_UP9x1, NULL, "sony-up991ad"}, // Dupe ? |
| 703 | { 0, 0, 0, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!} |
| 704 | }; |
| 705 | |
| 706 | const struct dyesub_backendcxx . . $ dyesub_backend# sonyupdneo_backendcxx . . $ sonyupdneo_backend. = { |
| 707 | .name = "Sony UP-D Neo", |
| 708 | .version = "0.23", |
| 709 | .flags = BACKEND_FLAG_BADISERIALcxx . . $ `src/cups/backend_common.h:302:9`!, /* UP-D898MD at least */ |
| 710 | .uri_prefixes = sonyupdneo_prefixescxx . . $ sonyupdneo_prefixes., |
| 711 | .devices = sonyupdneo_devicescxx . . $ sonyupdneo_devices., |
| 712 | .cmdline_arg = updneo_cmdline_argcxx . . $ updneo_cmdline_arg(bd8af97f5fa850e1)., |
| 713 | .cmdline_usage = updneo_cmdlinecxx . . $ updneo_cmdline(49f6e7a06ebc5aa8)., |
| 714 | .init = updneo_initcxx . . $ updneo_init(50c7df7de5344ebb)., |
| 715 | .attach = updneo_attachcxx . . $ updneo_attach(65a6cf861cd15f84)., |
| 716 | .cleanup_job = updneo_cleanup_jobcxx . . $ updneo_cleanup_job(e4289f82fef2c2f9)., |
| 717 | .read_parse = updneo_read_parsecxx . . $ updneo_read_parse(296a7ce9eef68a26)., |
| 718 | .main_loop = updneo_main_loopcxx . . $ updneo_main_loop(91e54fd90adbb21)., |
| 719 | .query_markers = updneo_query_markerscxx . . $ updneo_query_markers(5f0c51117cc67eb5)., |
| 720 | .query_serno = updneo_query_sernocxx . . $ updneo_query_serno(a3ebabf18f8093e8)., |
| 721 | }; |
| 722 | |
| 723 | /* Sony UP-D (new) printer spool format |
| 724 | |
| 725 | Covers UP-CR20L, UP-DR80/DR80MD, UP-D898/UP-X898 |
| 726 | |
| 727 | HP-PJL wrapper around custom Sony PDL: |
| 728 | |
| 729 | JOBSIZE=PJL-H,size,arg1,arg2,etc [null terminated, padded to 256 bytes] |
| 730 | [ size bytes of PJL header! ] |
| 731 | JOBSIZE=PDL,size,args [null terminated, padded to 256 bytes] |
| 732 | [ size bytes of PDL data! ] |
| 733 | JOBSIZE=PJL-T,size,args [null terminated, padded to 256 bytes] |
| 734 | [ size bytes of PJL trailer! ] |
| 735 | |
| 736 | PJL header: |
| 737 | |
| 738 | <ESC>%-12345X<CR><LF> |
| 739 | @PJL COMMENT free form text here <CR><LF> |
| 740 | @PJL JOB NAME="name me" ID="someid"<CR><LF> |
| 741 | @PJL .... <CR><LF> |
| 742 | @PJL ENTER LANGUAGE=SONY-PDL-DS2<CR><LF> |
| 743 | |
| 744 | PJL footer: |
| 745 | |
| 746 | @PJL EOJ<CR><LF> |
| 747 | <ESC>%-12345X<CR><LF> |
| 748 | |
| 749 | PDL notes: |
| 750 | |
| 751 | size is the length mentioned in the payload (ie rows * cols * planes) |
| 752 | plus the PDL header (varies) and PDL footer (7 bytes) |
| 753 | |
| 754 | Note: All multi-byte values are BIG ENDIAN |
| 755 | |
| 756 | UP-D898MD: 18*16+2 == 290 byte header |
| 757 | |
| 758 | 00000250 00 00 YY YY = rows |
| 759 | 00000260 01 00 00 10 0f 00 1c 00 00 00 00 00 00 00 00 00 XX XX = columns (fixed at 05 00) |
| 760 | 00000270 00 00 00 00 00 01 02 00 09 00 NN 01 00 11 01 08 NN = Copies (01..?) <-- GUESS |
| 761 | 00000280 00 1a 00 00 00 00 XX XX YY YY 09 00 28 01 00 d4 |
| 762 | 00000290 00 00 03 58 YY YY 00 00 13 01 00 04 00 80 00 23 |
| 763 | 000002a0 00 0c 01 09 XX XX YY YY 00 00 00 00 08 ff 08 00 |
| 764 | 000002b0 19 00 00 00 00 XX XX YY YY 00 00 81 80 00 8f 00 |
| 765 | 000002c0 b8 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |
| 766 | 000002d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |
| 767 | 000002f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |
| 768 | 00000300 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |
| 769 | 00000310 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |
| 770 | 00000320 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |
| 771 | 00000330 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |
| 772 | 00000340 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |
| 773 | 00000350 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |
| 774 | 00000360 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |
| 775 | 00000370 00 00 00 00 00 00 00 00 00 c0 00 82 LL LL LL LL LL == payload bytes, BE (== XX * YY * 1) |
| 776 | |
| 777 | [payload of LL bytes follows] |
| 778 | |
| 779 | UP-971/991AD 18*16+2 == 290 byte header |
| 780 | |
| 781 | 00000250 00 00 XX XX = columns (fixed at 0a 00) |
| 782 | 00000260 01 00 00 10 0f 00 1c 00 00 00 00 00 00 00 00 00 YY YY = rows (varies) |
| 783 | 00000270 00 00 SS TT TT GG 02 00 09 00 NN 01 00 11 01 08 SS == sharpening (00-0e) |
| 784 | 00000280 00 1a 00 00 00 00 XX XX YY YY 09 00 28 01 01 26 GG == gamma (00/01/02 == 1/2/3) |
| 785 | 00000290 00 00 07 b3 YY YY 00 00 13 01 00 04 00 80 00 23 TT TT == tone, +-32 (signed, BE) |
| 786 | 000002a0 00 0c 01 09 XX XX YY YY 00 00 00 00 08 ff 08 00 NN == copies (00 for printer, 01-???) |
| 787 | 000002b0 19 00 00 00 00 XX XX YY YY 00 00 81 80 00 8f 00 |
| 788 | 000002c0 b8 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |
| 789 | 000002d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |
| 790 | 000002e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |
| 791 | 000002f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |
| 792 | 00000300 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |
| 793 | 00000310 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |
| 794 | 00000320 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |
| 795 | 00000330 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |
| 796 | 00000340 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |
| 797 | 00000350 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |
| 798 | 00000360 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |
| 799 | 00000370 00 00 00 00 00 00 00 00 00 c0 00 82 LL LL LL LL LL == payload bytes, BE (== XX * YY * 1) |
| 800 | |
| 801 | UP-CR20L: 290 byte header, 330 dpi, 1210x1728/1382x2048/1728*2380/2724*2048 (L/PC/2L/2PC) |
| 802 | |
| 803 | 00000250 00 00 |
| 804 | 00000260 01 00 00 10 0f 00 1c 00 00 00 00 00 00 00 00 00 |
| 805 | 00000270 00 00 01 00 00 00 02 00 16 00 00 02 00 09 00 NN NN = Copies (01..??) |
| 806 | 00000280 02 00 06 01 01 03 00 1d 00 00 00 01 00 20 01 01 |
| 807 | 00000290 00 27 40 01 00 11 01 08 00 1a 00 00 00 00 RR RR |
| 808 | 000002a0 CC CC 00 00 13 01 00 04 00 80 00 23 00 10 03 00 CC CC == Columns (BE) |
| 809 | 000002b0 RR RR CC CC 00 00 00 00 08 08 08 ff ff ff 01 00 RR RR == Rows (BE) |
| 810 | 000002c0 17 00 08 00 19 00 00 00 00 RR RR CC CC 00 00 81 |
| 811 | 000002d0 80 00 8f 00 a4 00 00 00 00 00 00 00 00 00 00 00 |
| 812 | 000002e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |
| 813 | 000002f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |
| 814 | 00000300 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |
| 815 | 00000310 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |
| 816 | 00000320 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |
| 817 | 00000330 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |
| 818 | 00000340 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |
| 819 | 00000350 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |
| 820 | 00000360 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |
| 821 | 00000370 00 00 00 00 00 00 00 00 00 c0 00 82 LL LL LL LL LL == payload bytes, BE (== RR * CC * 3) |
| 822 | |
| 823 | [payload of LL bytes follows] |
| 824 | |
| 825 | UP-DR80MD: (19*16+8) = 312 byte header (A4 = 3400x2392, Letter = 3192*2464) |
| 826 | |
| 827 | 00000240 00 00 01 00 00 10 0f 00 |
| 828 | 00000250 1c 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ZZ ZZ = 0x00 (Letter) 0x56 (A4) |
| 829 | 00000260 02 00 16 00 01 80 00 15 00 12 55 50 44 52 38 30 SS = 0x00 (LUT0) 0xff (No LUT) |
| 830 | 00000270 00 00 4c 55 54 QQ 00 00 00 00 00 SS 02 00 09 00 QQ = 0x30 (LUT0) 0x2f (No LUT) |
| 831 | 00000280 NN 02 00 06 01 03 04 00 1d 01 00 00 05 01 00 20 NN = Copies (01...??) |
| 832 | 00000290 00 01 00 11 01 08 00 1a 00 00 00 00 CC CC RR RR RR RR = Rows (BE) |
| 833 | 000002a0 00 00 13 01 00 04 00 80 00 23 00 10 03 00 CC CC CC CC = Cols (BE) |
| 834 | 000002b0 RR RR 00 00 00 00 08 08 08 ff ff ff 01 00 17 00 |
| 835 | 000002c0 08 00 19 00 00 00 00 CC CC RR RR 00 00 81 80 00 |
| 836 | 000002d0 8f 00 a6 00 00 00 00 00 00 00 00 00 00 00 00 00 |
| 837 | 000002e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |
| 838 | 000002f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |
| 839 | 00000300 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |
| 840 | 00000310 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |
| 841 | 00000320 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |
| 842 | 00000330 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |
| 843 | 00000340 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |
| 844 | 00000350 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |
| 845 | 00000360 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |
| 846 | 00000370 00 00 00 00 00 00 00 00 00 c0 00 82 LL LL LL LL LL == payload, BE (== RR * CC * 3) |
| 847 | |
| 848 | [payload of LL bytes follows] |
| 849 | |
| 850 | ********* |
| 851 | |
| 852 | 898 Format: |
| 853 | |
| 854 | 00 00 01 |
| 855 | 00 00 10 |
| 856 | 0f 00 1c 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 |
| 857 | 02 00 09 00 NN |
| 858 | 01 00 11 01 |
| 859 | 08 00 1a 00 00 00 00 XX XX YY YY |
| 860 | 09 00 28 01 00 d4 00 00 03 58 YY YY |
| 861 | 00 00 13 |
| 862 | 01 00 04 00 |
| 863 | 80 00 23 00 0c 01 09 XX XX YY YY 00 00 00 00 08 ff |
| 864 | 08 00 19 00 00 00 00 XX XX YY YY |
| 865 | 00 00 81 |
| 866 | 80 00 8f ## ## [ follwed by ## zeros ] [ b8 on 898 ] |
| 867 | c0 00 82 LL LL LL LL |
| 868 | |
| 869 | DR80MD format: |
| 870 | |
| 871 | 00 00 01 |
| 872 | 00 00 10 |
| 873 | 0f 00 1c 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ZZ |
| 874 | 02 00 16 00 01 |
| 875 | 80 00 15 00 12 55 50 44 52 38 30 00 00 4c 55 54 QQ 00 00 |
| 876 | 00 00 00 SS |
| 877 | 02 00 09 00 NN |
| 878 | 02 00 06 01 03 |
| 879 | 04 00 1d 01 00 00 05 |
| 880 | 01 00 20 00 |
| 881 | 01 00 11 01 |
| 882 | 08 00 1a 00 00 00 00 CC CC RR RR |
| 883 | 00 00 13 |
| 884 | 01 00 04 00 |
| 885 | 80 00 23 00 10 03 00 CC CC RR RR 00 00 00 00 08 08 08 ff |
| 886 | ff ff 01 00 17 00 |
| 887 | 08 00 19 00 00 00 00 CC CC RR RR |
| 888 | 00 00 81 |
| 889 | 80 00 8f ## ## [ followed by ## zeros ] [ a6 on dr80md ] |
| 890 | c0 00 82 LL LL LL LL |
| 891 | |
| 892 | CR20L format: |
| 893 | |
| 894 | 00 00 01 |
| 895 | 00 00 10 |
| 896 | 0f 00 1c 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 |
| 897 | 02 00 16 00 00 |
| 898 | 02 00 09 00 NN |
| 899 | 02 00 06 01 01 |
| 900 | 03 00 1d 00 00 00 |
| 901 | 03 00 13 00 01 02 [ only when multicut is on ] |
| 902 | 01 00 20 01 |
| 903 | 01 00 27 40 |
| 904 | 01 00 11 01 |
| 905 | 08 00 1a 00 00 00 00 RR RR CC CC |
| 906 | 00 00 13 |
| 907 | 01 00 04 00 |
| 908 | 80 00 23 00 10 03 00 RR RR CC CC 00 00 00 00 08 08 08 ff |
| 909 | ff ff 01 00 17 00 |
| 910 | 08 00 19 00 00 00 00 RR RR CC CC |
| 911 | 00 00 81 |
| 912 | 80 00 8f ## ## [ followed by ## zeros ] [ a4/9d if mcut is off/on ] |
| 913 | c0 00 82 LL LL LL LL |
| 914 | |
| 915 | *** COMBINED / COMMON : |
| 916 | |
| 917 | XX ZZ ZZ [ XX = length, ZZ = code, followed by XX bytes ] |
| 918 | |
| 919 | 00 00 01 |
| 920 | 00 00 10 |
| 921 | 0f 00 1c 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ZZ [ ZZ = pagecode; 01 for 898, 00 for CR20L, 00/56 for Letter/A4 on DR80MD ] |
| 922 | 02 00 09 00 NN [ NN = copies ] |
| 923 | 01 00 11 01 |
| 924 | 08 00 1a 00 00 00 00 CC CC RR RR [ CC = cols, RR = rows ] |
| 925 | 00 00 13 |
| 926 | 01 00 04 00 |
| 927 | [ more/unique stuff in here ] |
| 928 | [ always ends with these ] |
| 929 | 08 00 19 00 00 00 00 RR RR CC CC |
| 930 | 00 00 81 |
| 931 | 80 00 8f ## ## [ follwed by ## zeros, pad to fill out header ] |
| 932 | c0 00 82 LL LL LL LL |
| 933 | |
| 934 | *** 898 unique [ 290 byte header ] |
| 935 | |
| 936 | 09 00 28 01 00 d4 00 00 03 58 CC CC |
| 937 | 80 00 23 00 0c 01 09 RR RR CC CC 00 00 00 00 08 ff |
| 938 | ^^ ^^ |
| 939 | length of data to follow |
| 940 | |
| 941 | ** CR20L unique [ 290 byte header ] |
| 942 | |
| 943 | 03 00 1d 00 00 00 |
| 944 | 03 00 13 00 01 02 [ only when multicut is on ] |
| 945 | 01 00 27 40 |
| 946 | |
| 947 | 02 00 16 00 00 |
| 948 | 02 00 06 01 01 |
| 949 | 01 00 20 01 |
| 950 | |
| 951 | 80 00 23 00 10 03 00 RR RR CC CC 00 00 00 00 08 08 08 ff ff ff |
| 952 | 01 00 17 00 |
| 953 | |
| 954 | ** DR80MD unique [ 312 byte header ] |
| 955 | |
| 956 | 80 00 15 00 12 55 50 44 52 38 30 00 00 4c 55 54 QQ 00 00 |
| 957 | 00 00 00 SS [ SS/QQ = LUT (See above) ] |
| 958 | 04 00 1d 01 00 00 05 |
| 959 | |
| 960 | 02 00 16 00 01 |
| 961 | 02 00 06 01 03 |
| 962 | 01 00 20 00 |
| 963 | |
| 964 | 80 00 23 00 10 03 00 RR RR CC CC 00 00 00 00 08 08 08 ff ff ff |
| 965 | 01 00 17 00 |
| 966 | |
| 967 | ***************** |
| 968 | |
| 969 | PRINTER COMMS: |
| 970 | |
| 971 | * Strip out "JOBSIZE=" headers |
| 972 | * Send PJL header |
| 973 | * Send PDL payload (every 9*256KB, do a status query..) |
| 974 | * Send PJL footer |
| 975 | |
| 976 | PJL header and footer need to be sent separately. |
| 977 | the PJL wrapper around the PDL block needs to be |
| 978 | stripped. |
| 979 | |
| 980 | *********** |
| 981 | |
| 982 | It appears that the printer status is tacked onto the IEEE1284 string: Examples: |
| 983 | |
| 984 | IDLE |
| 985 | MFG:SONY;MDL:UP-DR80MD;DES:Sony UP-DR80MD;CMD:SPJL-DS,SPDL-DS;CLS:PRINTER;SCDIV:0100;SCSYV:01060000;SCSNO:0000000000089864;SCSYS:0000001000010001000100;SCMDS:00000000002C002C002C;SCPRS:0000;SCSES:0000;SCWTS:0000;SCJBS:0000;SCSYE:00;SCMDE:0000;SCMCE:00;SCJBI:0000000000000000;SCSYI:0A300E5609A00C7809A00C78012D00;SCSVI:000342000342;SCMNI:000342000342;SCCAI:00000000000000;SCGAI:0000;SCGSI:00;SCMDI:110154 |
| 986 | |
| 987 | DATA XFER: |
| 988 | MFG:SONY;MDL:UP-DR80MD;DES:Sony UP-DR80MD;CMD:SPJL-DS,SPDL-DS;CLS:PRINTER;SCDIV:0100;SCSYV:01060000;SCSNO:0000000000089864;SCSYS:0000011000010001000000;SCMDS:00000000002C002C002C;SCPRS:0005;SCSES:0000;SCWTS:0000;SCJBS:0000;SCSYE:00;SCMDE:0000;SCMCE:00;SCJBI:0000000000000000;SCSYI:0A300E5609A00C7809A00C78012D00;SCSVI:000342000342;SCMNI:000342000342;SCCAI:00000000000000;SCGAI:0000;SCGSI:00;SCMDI:110154 |
| 989 | |
| 990 | NO PAPER: |
| 991 | MFG:SONY;MDL:UP-DR80MD;DES:Sony UP-DR80MD;CMD:SPJL-DS,SPDL-DS;CLS:PRINTER;SCDIV:0100;SCSYV:01060000;SCSNO:0000000000089864;SCSYS:0000003800010000000100;SCMDS:00000000000000000000;SCPRS:0000;SCSES:0000;SCWTS:0000;SCJBS:0000;SCSYE:00;SCMDE:0A00;SCMCE:00;SCJBI:0000000000000000;SCSYI:0A300E560000000000000000012D00;SCSVI:000345000345;SCMNI:000345000345;SCCAI:00000000000000;SCGAI:0000;SCGSI:00;SCMDI:1100FF |
| 992 | |
| 993 | NO RIBBON: |
| 994 | MFG:SONY;MDL:UP-DR80MD;DES:Sony UP-DR80MD;CMD:SPJL-DS,SPDL-DS;CLS:PRINTER;SCDIV:0100;SCSYV:01060000;SCSNO:0000000000089864;SCSYS:0000003800010000000100;SCMDS:00000000000000000000;SCPRS:0000;SCSES:0000;SCWTS:0000;SCJBS:0000;SCSYE:00;SCMDE:0002;SCMCE:00;SCJBI:0000000000000000;SCSYI:0A300E5609A00C7809A00C78012D00;SCSVI:000345000345;SCMNI:000345000345;SCCAI:00000000000000;SCGAI:0000;SCGSI:00;SCMDI:000154 |
| 995 | |
| 996 | COVER OPEN: |
| 997 | MFG:SONY;MDL:UP-DR80MD;DES:Sony UP-DR80MD;CMD:SPJL-DS,SPDL-DS;CLS:PRINTER;SCDIV:0100;SCSYV:01060000;SCSNO:0000000000089864;SCSYS:0000001800010000000100;SCMDS:00000000000000000000;SCPRS:0000;SCSES:0000;SCWTS:0000;SCJBS:0000;SCSYE:00;SCMDE:0800;SCMCE:01;SCJBI:0000000000000000;SCSYI:0A300E560000000000000000012D00;SCSVI:000345000345;SCMNI:000345000345;SCCAI:00000000000000;SCGAI:0000;SCGSI:00;SCMDI:1100FF |
| 998 | |
| 999 | Stryker SDP1000 |
| 1000 | |
| 1001 | MFG:Stryker;MDL:SDP1000;DES:Stryker SDP1000;CMD:SPJL-DS,SPDL-DS2;CLS:PRINTER;SCDIV:0100;SCSYV:01010000;SCSNO:0000000000083389;SCSYS:0000001000010000000100;SCMDS:00000000002D002D002D;SCPRS:0000;SCSES:0000;SCWTS:0000;SCJBS:0000;SCSYE:00;SCMDE:0000;SCMCE:00;SCJBI:0000000000000000;SCSYI:0A300E5609A00C7809A00C78012D00;SCSVI:000047000047;SCMNI:000047000047;SCCAI:00000000000000;SCGAI:0000;SCGSI:00;SCMDI:110154; |
| 1002 | |
| 1003 | [ Notable difference is SCSYI ] |
| 1004 | |
| 1005 | UP-DR898MD |
| 1006 | |
| 1007 | MFG:Sony;MDL:UP-D898MD_X898MD;DES:Sony UP-D898MD_X898MD;CMD:SPJL-DS,SPDL-DS2;CLS:PRINTER;SCDIV:0100;SCSYV:01010000;SCSYS:0000001000010000000000;SCMDS:00000500000100000000;SCSYE:00;SCMDE:0000;SCMCE:00;SCSYI:100005001000050000000000014500;SCSVI:000204000204;SCMDI:200406;SCSNO:7100886---------;SCJBS:0000;SCCAI:00000000000000;SCGSI:01;SCQTI:0001;SPUQI:0000 |
| 1008 | |
| 1009 | [ This adds SCQTI; SCSNO is formatted differently, no SCPRS/SCJBI ] |
| 1010 | |
| 1011 | UP-971AD / UP-991AD |
| 1012 | |
| 1013 | MFG:Sony;MDL:UP-991AD_971AD;DES:Sony UP-991AD_971AD;CMD:SPJL-DS,SPDL-DS2;CLS:PRINTER;SCDIV:0100;SCSYV:01050000;SCSYS:0000001000010000000000;SCMDS:00000500000100000000;SCSYE:00;SCMDE:0000;SCMCE:00;SCSYI:1E000A001E000A0000000000014500;SCSVI:000002000002;SCMDI:200404;SCSNO:0739166---------;SCJBS:0000;SCCAI:00000000000000;SCGSI:00;SCQTI:0001;SPUQI:0000 |
| 1014 | |
| 1015 | [ Appears to be largely similar to 898 series ] |
| 1016 | |
| 1017 | Breakdown: |
| 1018 | |
| 1019 | (+) means referenced by their Windows driver |
| 1020 | |
| 1021 | SCDIV # Data Info Version (?) Always seems to be 0100 |
| 1022 | +SCSYV # SYstemVersion (?) (01.06.00.00) ?? |
| 1023 | SCSNO # SerialNO |
| 1024 | +SCSYS # SystemStatus (?) some sort of state array? 22 fields. b19 is 1 when data can be sent?, b5 is 1 when printer busy?, b20:21 is 64 sometimes, maybe paper or ribbon feed. b6:7 is 38 with no paper&|ribbon, or 18 with cover open |
| 1025 | +SCMDS # MeDiaStatus: five 4-value hex numbers, last three decrease in unison (remaining prints). second one is 0000/0100/0200/0300/0600, maybe Y/M/C/O? |
| 1026 | SCPRS # PRinterStatus: (0000 = idle, 0002 = printing, 0005 = data xfer?) |
| 1027 | +SCSES # "SE" Status |
| 1028 | +SCWTS # "WT" Status |
| 1029 | +SCJBS # JoBStatus (?) |
| 1030 | SCSYE # SYstemError (?) |
| 1031 | +SCMDE # MeDiaError: 2000 media mismatch, 0A00 no paper, 0800 cover open, 0002 no ribbon |
| 1032 | +SCMCE # MediaCoverError: 01 cover open, 08 jam/feed problem? |
| 1033 | SCJBI # JoBInfo (?) |
| 1034 | SCSYI # SYstemInfo (?) Includes legal job max dimensions/parameters; up to three dimension sets and a fourth unknown field |
| 1035 | +SCSVI # print counter(s)? (XXXXXXYYYYYY, and X = Y so far. SCSVI and SCMNI are identical so far) |
| 1036 | SCMNI # print counter(s)? (see SCSVI) |
| 1037 | SCCAI # "CA" Info (?) |
| 1038 | SCGAI # "GA" Info (?) |
| 1039 | SCGSI # "GS" Info (?) |
| 1040 | +SCMDI # MeDiaInfo: 110154 OK w/UPD-R81MD(Letter), 1100FF with no paper, 000154 with no ribbon, 200404 on A4 thermal printers, 2000406 on A6 thermal printers? |
| 1041 | SCQTI # "QT" Info (?) (898MD, UP9x1) |
| 1042 | SPUQI # "UQ" Info (?) (898MD, UP9x1) |
| 1043 | |
| 1044 | Guess: |
| 1045 | |
| 1046 | SCxxy SC = Sony Corp |
| 1047 | xx = class/field (eg MD = media) |
| 1048 | y = var type (S = status, I = info, E = error V = version, O |
| 1049 | |
| 1050 | */ |