[all] Rework how printer errors are detected.

All known errors from all supported printers are detected, except for
the ES2, which requires more investigation.
This commit is contained in:
Solomon Peachy 2012-11-21 23:18:56 -05:00
parent f65740bdab
commit 3a0ac481cb
4 changed files with 14 additions and 12 deletions

View File

@ -217,7 +217,7 @@
00 0e ff 00 00 00 00 00 00 00 00 [pg] [transitions to this]
00 00 10 00 00 00 00 00 00 00 00 [pg] [ready for footer]
00 00 00 [xx] 00 00 00 00 00 00 00 [pg] [error]
00 ** ** [xx] 00 00 00 00 00 00 00 [pg] [error]
[xx]:
01: Generic communication error

View File

@ -438,8 +438,9 @@ top:
}
fflush(stderr);
if (!memcmp(rdbuf, printers[printer_type].error_readback, READBACK_LEN)) {
DEBUG("error condition; aborting. (Out of ribbon/paper?)\n");
if (printers[printer_type].error_offset != -1 &&
rdbuf[printers[printer_type].error_offset]) {
ERROR("error condition; aborting. (Out of ribbon/paper?)\n");
ret = 4;
goto done_claimed;
}

View File

@ -25,7 +25,7 @@
*
*/
#define VERSION "0.39"
#define VERSION "0.40"
#define DEBUG( ... ) fprintf(stderr, "DEBUG: " __VA_ARGS__ )
#define ERROR( ... ) fprintf(stderr, "ERROR: " __VA_ARGS__ )
@ -56,10 +56,10 @@ struct printer_data {
int16_t ready_m_readback[READBACK_LEN];
int16_t ready_c_readback[READBACK_LEN];
int16_t done_c_readback[READBACK_LEN];
int16_t error_readback[READBACK_LEN];
int16_t paper_codes[256];
int16_t pgcode_offset; /* Offset into printjob for paper type */
int16_t paper_code_offset; /* Offset in readback for paper type */
int16_t error_offset;
};
/* printer types */
@ -82,10 +82,10 @@ struct printer_data printers[P_END] = {
.ready_m_readback = { 0x04, 0x00, 0x03, 0x00, 0x02, 0x01, -1, 0x01, 0x00, 0x00, 0x00, 0x00 },
.ready_c_readback = { 0x04, 0x00, 0x07, 0x00, 0x02, 0x01, -1, 0x01, 0x00, 0x00, 0x00, 0x00 },
.done_c_readback = { 0x04, 0x00, 0x00, 0x00, 0x02, 0x01, -1, 0x01, 0x00, 0x00, 0x00, 0x00 },
.error_readback = { -1, 0x01, 0x00, 0x00, 0x01, 0xff, 0xff, 0xff, 0x00, -1, 0x00, 0x00 },
// .paper_codes
.pgcode_offset = 3,
.paper_code_offset = 6,
.error_offset = 1,
},
{ .type = P_ES2_20,
.model = "SELPHY ES2/ES20",
@ -96,10 +96,10 @@ struct printer_data printers[P_END] = {
.ready_m_readback = { 0x06, 0x00, 0x03, 0x00, -1, 0x00, -1, -1, 0x00, 0x00, 0x00, 0x00 },
.ready_c_readback = { 0x09, 0x00, 0x07, 0x00, -1, 0x00, -1, -1, 0x00, 0x00, 0x00, 0x00 },
.done_c_readback = { 0x09, 0x00, 0x00, 0x00, -1, 0x00, -1, -1, 0x00, 0x00, 0x00, 0x00 },
.error_readback = { 0x14, 0x00, -1, 0x00, -1, 0x00, -1, 0x00, -1, 0x00, 0x00, 0x00 }, // XXX insufficient
// .paper_codes
.pgcode_offset = 2,
.paper_code_offset = 4,
.error_offset = 1, // XXX insufficient
},
{ .type = P_ES3_30,
.model = "SELPHY ES3/ES30",
@ -110,10 +110,10 @@ struct printer_data printers[P_END] = {
.ready_m_readback = { 0x03, 0xff, 0x02, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00 },
.ready_c_readback = { 0x05, 0xff, 0x03, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00 },
.done_c_readback = { 0x00, 0xff, 0x10, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00 },
.error_readback = { 0x00, 0xff, 0x01, 0x00, 0xff, 0xff, 0xff, 0xff, -1, 0x00, -1, 0x00 },
// .paper_codes
.pgcode_offset = 2,
.paper_code_offset = -1,
.error_offset = 8, // or 10
},
{ .type = P_ES40_CP790,
.model = "SELPHY ES40/CP790",
@ -124,10 +124,10 @@ struct printer_data printers[P_END] = {
.ready_m_readback = { 0x00, 0x03, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -1 },
.ready_c_readback = { 0x00, 0x05, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -1 },
.done_c_readback = { 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -1 },
.error_readback = { 0x00, -1, -1, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -1 },
// .paper_codes
.pgcode_offset = 2,
.paper_code_offset = 11,
.error_offset = 3,
},
{ .type = P_CP_XXX,
.model = "SELPHY CP Series (!CP790)",
@ -138,10 +138,10 @@ struct printer_data printers[P_END] = {
.ready_m_readback = { 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, -1, 0x00, 0x00, 0x00, 0x00, -1 },
.ready_c_readback = { 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, -1, 0x00, 0x00, 0x00, 0x00, -1 },
.done_c_readback = { 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, -1, 0x00, 0x00, 0x00, 0x00, -1 },
.error_readback = { 0x02, 0x00, 0x08, 0x00, 0x70, 0x00, -1, 0x00, 0x00, 0x00, 0x00, -1 },
// .paper_codes
.pgcode_offset = 3,
.paper_code_offset = 6,
.error_offset = 2,
},
};

View File

@ -172,8 +172,9 @@ top:
}
fflush(stderr);
if (!memcmp(rdbuf, printers[printer_type].error_readback, READBACK_LEN)) {
DEBUG("error condition; aborting. (Out of ribbon/paper?)\n");
if (printers[printer_type].error_offset != -1 &&
rdbuf[printers[printer_type].error_offset]) {
ERROR("error condition; aborting. (Out of ribbon/paper?)\n");
return 4;
}