shinko: Extract more common code.
This commit is contained in:
parent
89f6a834d2
commit
f8122b0236
|
@ -77,15 +77,6 @@ struct kodak605_sts_hdr {
|
|||
#define RESULT_FAIL 0x02
|
||||
|
||||
/* ERROR_* and STATUS_* are all guesses */
|
||||
#define ERROR_NONE 0x00
|
||||
#define ERROR_INVALID_PARAM 0x01
|
||||
#define ERROR_MAIN_APP_INACTIVE 0x02
|
||||
#define ERROR_COMMS_TIMEOUT 0x03
|
||||
#define ERROR_MAINT_NEEDED 0x04
|
||||
#define ERROR_BAD_COMMAND 0x05
|
||||
#define ERROR_PRINTER 0x11
|
||||
#define ERROR_BUFFER_FULL 0x21
|
||||
|
||||
#define STATUS_INIT_CPU 0x31
|
||||
#define STATUS_INIT_RIBBON 0x32
|
||||
#define STATUS_INIT_PAPER 0x33
|
||||
|
@ -164,16 +155,10 @@ struct kodak605_status {
|
|||
} __attribute__((packed));
|
||||
|
||||
/* Error logs are guesses */
|
||||
struct kodak605_error_item {
|
||||
uint8_t major;
|
||||
uint8_t minor;
|
||||
uint32_t print_counter;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct kodak605_errorlog_resp {
|
||||
struct kodak605_sts_hdr hdr;
|
||||
uint8_t count;
|
||||
struct kodak605_error_item items[10]; /* Not all necessarily used */
|
||||
struct sinfonia_error_item items[10]; /* Not all necessarily used */
|
||||
} __attribute__((packed));
|
||||
|
||||
/* File header */
|
||||
|
@ -470,8 +455,9 @@ static int kodak605_main_loop(void *vctx, const void *vjob) {
|
|||
|
||||
if (sts.hdr.result != RESULT_SUCCESS) {
|
||||
ERROR("Printer Status: %02x\n", sts.hdr.status);
|
||||
ERROR("Result: %02x Error: %02x (%02x %02x)\n",
|
||||
ERROR("Result: %02x Error: %02x (%s) %02x/%02x\n",
|
||||
sts.hdr.result, sts.hdr.error,
|
||||
sinfonia_error_str(sts.hdr.error),
|
||||
sts.hdr.printer_major, sts.hdr.printer_minor);
|
||||
return CUPS_BACKEND_FAILED;
|
||||
}
|
||||
|
@ -552,8 +538,9 @@ static int kodak605_main_loop(void *vctx, const void *vjob) {
|
|||
if (sts.hdr.result != RESULT_SUCCESS ||
|
||||
sts.hdr.error == ERROR_PRINTER) {
|
||||
INFO("Printer Status: %02x\n", sts.hdr.status);
|
||||
INFO("Result: %02x Error: %02x (%02x %02x)\n",
|
||||
INFO("Result: %02x Error: %02x (%s) %02x/%02x\n",
|
||||
sts.hdr.result, sts.hdr.error,
|
||||
sinfonia_error_str(sts.hdr.error),
|
||||
sts.hdr.printer_major, sts.hdr.printer_minor);
|
||||
return CUPS_BACKEND_STOP;
|
||||
}
|
||||
|
@ -580,8 +567,9 @@ static int kodak605_main_loop(void *vctx, const void *vjob) {
|
|||
|
||||
static void kodak605_dump_status(struct kodak605_ctx *ctx, struct kodak605_status *sts)
|
||||
{
|
||||
INFO("Status: %02x Error: %02x %02x/%02x\n",
|
||||
INFO("Status: %02x Error: %02x (%s) %02x/%02x\n",
|
||||
sts->hdr.status, sts->hdr.error,
|
||||
sinfonia_error_str(sts->hdr.error),
|
||||
sts->hdr.printer_major, sts->hdr.printer_minor);
|
||||
|
||||
INFO("Bank 1: %s Job %03u @ %03u/%03u\n",
|
||||
|
|
|
@ -146,7 +146,7 @@ int sinfonia_read_parse(int data_fd, uint32_t model,
|
|||
jp->rows = hdr[14];
|
||||
jp->copies = hdr[15];
|
||||
|
||||
if (hdr[1] == 6145)
|
||||
if (hdr[1] == 2245 || hdr[1] == 6145)
|
||||
jp->ext_flags = hdr[28];
|
||||
}
|
||||
|
||||
|
@ -193,3 +193,26 @@ char *sinfonia_bank_statuses(uint8_t v)
|
|||
return "Unknown";
|
||||
}
|
||||
}
|
||||
|
||||
char *sinfonia_error_str(uint8_t v) {
|
||||
switch (v) {
|
||||
case ERROR_NONE:
|
||||
return "None";
|
||||
case ERROR_INVALID_PARAM:
|
||||
return "Invalid Command Parameter";
|
||||
case ERROR_MAIN_APP_INACTIVE:
|
||||
return "Main App Inactive";
|
||||
case ERROR_COMMS_TIMEOUT:
|
||||
return "Main Communication Timeout";
|
||||
case ERROR_MAINT_NEEDED:
|
||||
return "Maintenance Needed";
|
||||
case ERROR_BAD_COMMAND:
|
||||
return "Inappropriate Command";
|
||||
case ERROR_PRINTER:
|
||||
return "Printer Error";
|
||||
case ERROR_BUFFER_FULL:
|
||||
return "Buffer Full";
|
||||
default:
|
||||
return "Unknown";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -85,3 +85,20 @@ char *sinfonia_update_targets (uint8_t v);
|
|||
#define TONECURVE_CURRENT 0x02
|
||||
|
||||
char *sinfonia_tonecurve_statuses (uint8_t v);
|
||||
|
||||
struct sinfonia_error_item {
|
||||
uint8_t major;
|
||||
uint8_t minor;
|
||||
uint32_t print_counter;
|
||||
} __attribute__((packed));
|
||||
|
||||
#define ERROR_NONE 0x00
|
||||
#define ERROR_INVALID_PARAM 0x01
|
||||
#define ERROR_MAIN_APP_INACTIVE 0x02
|
||||
#define ERROR_COMMS_TIMEOUT 0x03
|
||||
#define ERROR_MAINT_NEEDED 0x04
|
||||
#define ERROR_BAD_COMMAND 0x05
|
||||
#define ERROR_PRINTER 0x11
|
||||
#define ERROR_BUFFER_FULL 0x21
|
||||
|
||||
char *sinfonia_error_str(uint8_t v);
|
||||
|
|
|
@ -341,15 +341,6 @@ struct s2145_status_hdr {
|
|||
#define RESULT_SUCCESS 0x01
|
||||
#define RESULT_FAIL 0x02
|
||||
|
||||
#define ERROR_NONE 0x00
|
||||
#define ERROR_INVALID_PARAM 0x01
|
||||
#define ERROR_MAIN_APP_INACTIVE 0x02
|
||||
#define ERROR_COMMS_TIMEOUT 0x03
|
||||
#define ERROR_MAINT_NEEDED 0x04
|
||||
#define ERROR_BAD_COMMAND 0x05
|
||||
#define ERROR_PRINTER 0x11
|
||||
#define ERROR_BUFFER_FULL 0x21
|
||||
|
||||
static char *error_codes(uint8_t major, uint8_t minor)
|
||||
{
|
||||
switch(major) {
|
||||
|
@ -548,28 +539,6 @@ static char *error_codes(uint8_t major, uint8_t minor)
|
|||
}
|
||||
}
|
||||
|
||||
static char *error_str(uint8_t v) {
|
||||
switch (v) {
|
||||
case ERROR_NONE:
|
||||
return "None";
|
||||
case ERROR_INVALID_PARAM:
|
||||
return "Invalid Command Parameter";
|
||||
case ERROR_MAIN_APP_INACTIVE:
|
||||
return "Main App Inactive";
|
||||
case ERROR_COMMS_TIMEOUT:
|
||||
return "Main Communication Timeout";
|
||||
case ERROR_MAINT_NEEDED:
|
||||
return "Maintenance Needed";
|
||||
case ERROR_BAD_COMMAND:
|
||||
return "Inappropriate Command";
|
||||
case ERROR_PRINTER:
|
||||
return "Printer Error";
|
||||
case ERROR_BUFFER_FULL:
|
||||
return "Buffer Full";
|
||||
default:
|
||||
return "Unknown";
|
||||
}
|
||||
}
|
||||
|
||||
#define STATUS_READY 0x00
|
||||
#define STATUS_INIT_CPU 0x31
|
||||
|
@ -707,16 +676,10 @@ struct s2145_modelname_resp {
|
|||
uint8_t modelname[40];
|
||||
} __attribute__((packed));
|
||||
|
||||
struct s2145_error_item {
|
||||
uint8_t major;
|
||||
uint8_t minor;
|
||||
uint32_t print_counter;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct s2145_errorlog_resp {
|
||||
struct s2145_status_hdr hdr;
|
||||
uint8_t count;
|
||||
struct s2145_error_item items[10]; /* Not all necessarily used */
|
||||
struct sinfonia_error_item items[10]; /* Not all necessarily used */
|
||||
} __attribute__((packed));
|
||||
|
||||
struct s2145_fwinfo_resp {
|
||||
|
@ -815,7 +778,7 @@ static int get_status(struct shinkos2145_ctx *ctx)
|
|||
resp->hdr.error = resp->hdr.status;
|
||||
INFO(" Error 0x%02x (%s) 0x%02x/0x%02x (%s)\n",
|
||||
resp->hdr.error,
|
||||
error_str(resp->hdr.error),
|
||||
sinfonia_error_str(resp->hdr.error),
|
||||
resp->hdr.printer_major,
|
||||
resp->hdr.printer_minor, error_codes(resp->hdr.printer_major, resp->hdr.printer_minor));
|
||||
}
|
||||
|
@ -1596,7 +1559,7 @@ top:
|
|||
sts->hdr.error = sts->hdr.status;
|
||||
INFO(" Error 0x%02x (%s) 0x%02x/0x%02x (%s)\n",
|
||||
sts->hdr.error,
|
||||
error_str(sts->hdr.error),
|
||||
sinfonia_error_str(sts->hdr.error),
|
||||
sts->hdr.printer_major,
|
||||
sts->hdr.printer_minor, error_codes(sts->hdr.printer_major, sts->hdr.printer_minor));
|
||||
}
|
||||
|
@ -1608,7 +1571,7 @@ top:
|
|||
printer_error:
|
||||
ERROR("Printer reported error: %#x (%s) status: %#x (%s) -> %#x.%#x (%s)\n",
|
||||
sts->hdr.error,
|
||||
error_str(sts->hdr.error),
|
||||
sinfonia_error_str(sts->hdr.error),
|
||||
sts->hdr.status,
|
||||
status_str(sts->hdr.status),
|
||||
sts->hdr.printer_major, sts->hdr.printer_minor,
|
||||
|
|
|
@ -516,15 +516,6 @@ struct s6145_status_hdr {
|
|||
#define RESULT_SUCCESS 0x01
|
||||
#define RESULT_FAIL 0x02
|
||||
|
||||
#define ERROR_NONE 0x00
|
||||
#define ERROR_INVALID_PARAM 0x01
|
||||
#define ERROR_MAIN_APP_INACTIVE 0x02
|
||||
#define ERROR_COMMS_TIMEOUT 0x03
|
||||
#define ERROR_MAINT_NEEDED 0x04
|
||||
#define ERROR_BAD_COMMAND 0x05
|
||||
#define ERROR_PRINTER 0x11
|
||||
#define ERROR_BUFFER_FULL 0x21
|
||||
|
||||
static char *error_codes(uint8_t major, uint8_t minor)
|
||||
{
|
||||
switch(major) {
|
||||
|
@ -718,29 +709,6 @@ static char *error_codes(uint8_t major, uint8_t minor)
|
|||
}
|
||||
}
|
||||
|
||||
static char *error_str(uint8_t v) {
|
||||
switch (v) {
|
||||
case ERROR_NONE:
|
||||
return "None";
|
||||
case ERROR_INVALID_PARAM:
|
||||
return "Invalid Command Parameter";
|
||||
case ERROR_MAIN_APP_INACTIVE:
|
||||
return "Main App Inactive";
|
||||
case ERROR_COMMS_TIMEOUT:
|
||||
return "Main Communication Timeout";
|
||||
case ERROR_MAINT_NEEDED:
|
||||
return "Maintenance Needed";
|
||||
case ERROR_BAD_COMMAND:
|
||||
return "Inappropriate Command";
|
||||
case ERROR_PRINTER:
|
||||
return "Printer Error";
|
||||
case ERROR_BUFFER_FULL:
|
||||
return "Buffer Full";
|
||||
default:
|
||||
return "Unknown";
|
||||
}
|
||||
}
|
||||
|
||||
#define STATUS_READY 0x00
|
||||
#define STATUS_INIT_CPU 0x31
|
||||
#define STATUS_INIT_RIBBON 0x32
|
||||
|
@ -959,16 +927,10 @@ struct s6145_mediainfo_resp {
|
|||
struct s6145_mediainfo_item items[10]; /* Not all necessarily used */
|
||||
} __attribute__((packed));
|
||||
|
||||
struct s6145_error_item {
|
||||
uint8_t major;
|
||||
uint8_t minor;
|
||||
uint32_t print_counter;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct s6145_errorlog_resp {
|
||||
struct s6145_status_hdr hdr;
|
||||
uint8_t count;
|
||||
struct s6145_error_item items[10]; /* Not all necessarily used */
|
||||
struct sinfonia_error_item items[10]; /* Not all necessarily used */
|
||||
} __attribute__((packed));
|
||||
|
||||
struct s6145_getparam_resp {
|
||||
|
@ -1122,7 +1084,7 @@ static int get_status(struct shinkos6145_ctx *ctx)
|
|||
resp->hdr.error = resp->hdr.status;
|
||||
INFO(" Error 0x%02x (%s) 0x%02x/0x%02x (%s)\n",
|
||||
resp->hdr.error,
|
||||
error_str(resp->hdr.error),
|
||||
sinfonia_error_str(resp->hdr.error),
|
||||
resp->hdr.printer_major,
|
||||
resp->hdr.printer_minor, error_codes(resp->hdr.printer_major, resp->hdr.printer_minor));
|
||||
}
|
||||
|
@ -2342,7 +2304,7 @@ top:
|
|||
printer_error:
|
||||
ERROR("Printer reported error: %#x (%s) status: %#x (%s) -> %#x.%#x (%s)\n",
|
||||
sts->hdr.error,
|
||||
error_str(sts->hdr.error),
|
||||
sinfonia_error_str(sts->hdr.error),
|
||||
sts->hdr.status,
|
||||
status_str(sts->hdr.status),
|
||||
sts->hdr.printer_major, sts->hdr.printer_minor,
|
||||
|
|
|
@ -342,15 +342,6 @@ struct s6245_status_hdr {
|
|||
#define RESULT_SUCCESS 0x01
|
||||
#define RESULT_FAIL 0x02
|
||||
|
||||
#define ERROR_NONE 0x00
|
||||
#define ERROR_INVALID_PARAM 0x01
|
||||
#define ERROR_MAIN_APP_INACTIVE 0x02
|
||||
#define ERROR_COMMS_TIMEOUT 0x03
|
||||
#define ERROR_MAINT_NEEDED 0x04
|
||||
#define ERROR_BAD_COMMAND 0x05
|
||||
#define ERROR_PRINTER 0x11
|
||||
#define ERROR_BUFFER_FULL 0x21
|
||||
|
||||
static char *error_codes(uint8_t major, uint8_t minor)
|
||||
{
|
||||
switch(major) {
|
||||
|
@ -566,29 +557,6 @@ static char *error_codes(uint8_t major, uint8_t minor)
|
|||
}
|
||||
}
|
||||
|
||||
static char *error_str(uint8_t v) {
|
||||
switch (v) {
|
||||
case ERROR_NONE:
|
||||
return "None";
|
||||
case ERROR_INVALID_PARAM:
|
||||
return "Invalid Command Parameter";
|
||||
case ERROR_MAIN_APP_INACTIVE:
|
||||
return "Main App Inactive";
|
||||
case ERROR_COMMS_TIMEOUT:
|
||||
return "Main Communication Timeout";
|
||||
case ERROR_MAINT_NEEDED:
|
||||
return "Maintenance Needed";
|
||||
case ERROR_BAD_COMMAND:
|
||||
return "Inappropriate Command";
|
||||
case ERROR_PRINTER:
|
||||
return "Printer Error";
|
||||
case ERROR_BUFFER_FULL:
|
||||
return "Buffer Full";
|
||||
default:
|
||||
return "Unknown";
|
||||
}
|
||||
}
|
||||
|
||||
#define STATUS_READY 0x00
|
||||
#define STATUS_INIT_CPU 0x31
|
||||
#define STATUS_INIT_RIBBON 0x32
|
||||
|
@ -924,7 +892,7 @@ static int get_status(struct shinkos6245_ctx *ctx)
|
|||
resp.hdr.error = resp.hdr.status;
|
||||
INFO(" Error 0x%02x (%s) 0x%02x/0x%02x (%s)\n",
|
||||
resp.hdr.error,
|
||||
error_str(resp.hdr.error),
|
||||
sinfonia_error_str(resp.hdr.error),
|
||||
resp.hdr.printer_major,
|
||||
resp.hdr.printer_minor, error_codes(resp.hdr.printer_major, resp.hdr.printer_minor));
|
||||
}
|
||||
|
@ -1715,7 +1683,7 @@ top:
|
|||
printer_error:
|
||||
ERROR("Printer reported error: %#x (%s) status: %#x (%s) -> %#x.%#x (%s)\n",
|
||||
sts.hdr.error,
|
||||
error_str(sts.hdr.error),
|
||||
sinfonia_error_str(sts.hdr.error),
|
||||
sts.hdr.status,
|
||||
status_str(sts.hdr.status),
|
||||
sts.hdr.printer_major, sts.hdr.printer_minor,
|
||||
|
|
Loading…
Reference in New Issue