I *really* care about reliability and error detection!

This commit is contained in:
XANTRONIX Development 2016-06-10 22:12:22 +00:00
parent 81ca7b7ac9
commit dcaf33ce01
2 changed files with 14 additions and 2 deletions

View file

@ -26,6 +26,9 @@ typedef enum {
TABBY_PRINTER_OK = 0
} tabby_printer_status;
#define TABBY_PRINTER_WAIT 0x0e
#define TABBY_PRINTER_ERROR 0xf0
typedef enum {
TABBY_PRINTER_PACKET_INIT = 0x01,
TABBY_PRINTER_PACKET_JOB = 0x02,

View file

@ -197,16 +197,25 @@ int tabby_printer_job_cancel(tabby_printer *printer) {
}
int tabby_printer_wait(tabby_printer *printer) {
do {
while (1) {
sleep(1);
if (tabby_printer_inquiry_send(printer) < 0) {
goto error_inquiry_send;
}
} while (printer->status);
if (printer->status & (TABBY_PRINTER_WAIT | TABBY_PRINTER_SUM)) {
continue;
} else if (printer->status & TABBY_PRINTER_ERROR) {
goto error_printer;
} else {
break;
}
}
return 0;
error_printer:
error_inquiry_send:
return -1;
}