diff --git a/README.TXT b/README.TXT index 8b59bf2..a610732 100644 --- a/README.TXT +++ b/README.TXT @@ -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 diff --git a/selphy_print.c b/selphy_print.c index 06f7a8d..aa330cb 100644 --- a/selphy_print.c +++ b/selphy_print.c @@ -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; } diff --git a/selphy_print_common.h b/selphy_print_common.h index c2ef71a..3a66cf2 100644 --- a/selphy_print_common.h +++ b/selphy_print_common.h @@ -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, }, }; diff --git a/selphy_print_linux.c b/selphy_print_linux.c index 5ac5d94..5b48d20 100644 --- a/selphy_print_linux.c +++ b/selphy_print_linux.c @@ -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; }