canonselphy: Send the error recovery/reset sequence after an error occurs.

And add error recovery code for the CP-10.

(I wonder if the ES series uses the same reset sequence?)
This commit is contained in:
Solomon Peachy 2014-02-03 20:12:00 -05:00
parent a9cbbbae5e
commit edbad88f05
1 changed files with 12 additions and 14 deletions

View File

@ -284,8 +284,9 @@ static struct printer_data selphy_printers[] = {
.ready_m_readback = { 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
.ready_c_readback = { 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
.done_c_readback = { 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
.clear_error = { 0x40, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
.clear_error_len = 12,
// .paper_codes
// .clear_error + clear_error_len
.pgcode_offset = -1,
.paper_code_offset = -1,
.error_detect = cp10_error_detect,
@ -642,16 +643,6 @@ static int canonselphy_main_loop(void *vctx, int copies) {
if (ret < 0)
return ret;
#if 0 /* This doesn't work yet */
/* Error detection & (possible) recovery */
if (ctx->printer->error_detect(rdbuf)) {
if (ctx->printer->clear_error_len)
/* Try to clear error state */
if ((ret = send_data(ctx->dev, ctx->endp_down, ctx->printer->clear_error, ctx->printer->clear_error_len)))
return ret;
}
#endif
top:
if (state != last_state) {
@ -671,8 +662,13 @@ top:
}
/* Error detection */
if (ctx->printer->error_detect(rdbuf))
if (ctx->printer->error_detect(rdbuf)) {
if (ctx->printer->clear_error_len)
/* Try to clear error state */
if ((ret = send_data(ctx->dev, ctx->endp_down, ctx->printer->clear_error, ctx->printer->clear_error_len)))
return ret;
return 4;
}
if (memcmp(rdbuf, rdbuf2, READBACK_LEN)) {
memcpy(rdbuf2, rdbuf, READBACK_LEN);
@ -859,7 +855,7 @@ top:
struct dyesub_backend canonselphy_backend = {
.name = "Canon SELPHY CP/ES",
.version = "0.75",
.version = "0.76",
.uri_prefix = "canonselphy",
.init = canonselphy_init,
.attach = canonselphy_attach,
@ -1133,6 +1129,8 @@ struct dyesub_backend canonselphy_backend = {
length is always '00 60 81 0a' which is 688480 bytes.
Error clear: 40 10 00 00 00 00 00 00 00 00 00 00
Known readback values:
01 00 00 00 00 00 00 00 00 00 00 00 [idle, waiting for init]
@ -1160,7 +1158,7 @@ struct dyesub_backend canonselphy_backend = {
Plane func: 40 01 00 [plane] [length, 32-bit LE] 00 00 00 00
End func: 00 00 00 00 # NOTE: CP900 only, and not necessary!
Error clear: 40 10 00 00 00 00 00 00 00 00 00 00 # CP800. Others?
Error clear: 40 10 00 00 00 00 00 00 00 00 00 00
plane codes are 0x00, 0x01, 0x02 for Y, M, and C, respectively.