From ea26351dc53a10af8ba2b79395525f8fc5c718d6 Mon Sep 17 00:00:00 2001 From: Solomon Peachy Date: Thu, 22 Nov 2012 07:40:32 -0500 Subject: [PATCH] [errors] Doubleread the readback, to clear initial state. --- README.TXT | 5 ++++- selphy_print.c | 10 +++++++++- selphy_print_linux.c | 1 + 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/README.TXT b/README.TXT index 2dd1efb..d83878a 100644 --- a/README.TXT +++ b/README.TXT @@ -278,7 +278,10 @@ [xx] is 0x01 on the CP780/CP800/CP900, 0x00 on all others. - [rr] is 0x00 normally, and 0x08 when ribbon is depleted. + [rr] is error code: + 0x00 no error + 0x01 paper out + 0x08 when ribbon is depleted [ss] is either 0x00 or 0x70. Unsure as to its significance; perhaps it means paper or ribbon is already set to go? diff --git a/selphy_print.c b/selphy_print.c index 15f08fc..d316bc1 100644 --- a/selphy_print.c +++ b/selphy_print.c @@ -410,13 +410,21 @@ int main (int argc, char **argv) } } -top: /* Read in the printer status */ ret = libusb_bulk_transfer(dev, endp_up, rdbuf, READBACK_LEN, &num, 2000); +top: + + /* Do it twice to clear initial state */ + ret = libusb_bulk_transfer(dev, endp_up, + rdbuf, + READBACK_LEN, + &num, + 2000); + if (ret < 0) { ERROR("libusb error %d: (%d/%d from 0x%02x)\n", ret, num, READBACK_LEN, endp_up); ret = 4; diff --git a/selphy_print_linux.c b/selphy_print_linux.c index fec1c30..eaf7dfb 100644 --- a/selphy_print_linux.c +++ b/selphy_print_linux.c @@ -154,6 +154,7 @@ int main(int argc, char **argv) if (paper_code_offset != -1) paper_code = printers[printer_type].paper_codes[buffer[printers[printer_type].pgcode_offset]]; + read(dev_fd, rdbuf, READBACK_LEN); /* Read the status from printer */ top: read(dev_fd, rdbuf, READBACK_LEN); /* Read the status from printer */