diff options
Diffstat (limited to 'backend_canonselphyneo.c')
-rw-r--r-- | backend_canonselphyneo.c | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/backend_canonselphyneo.c b/backend_canonselphyneo.c index 0068ba3..172ef3d 100644 --- a/backend_canonselphyneo.c +++ b/backend_canonselphyneo.c @@ -147,6 +147,34 @@ static int selphyneo_send_reset(struct selphyneo_ctx *ctx) return CUPS_BACKEND_OK; } +static int selphyneo_get_status(struct selphyneo_ctx *ctx) +{ + struct selphyneo_readback rdback; + int ret, num; + + /* Read in the printer status to clear last state */ + ret = read_data(ctx->dev, ctx->endp_up, + (uint8_t*) &rdback, sizeof(rdback), &num); + + if (ret < 0) + return CUPS_BACKEND_FAILED; + + /* And again, for the markers */ + ret = read_data(ctx->dev, ctx->endp_up, + (uint8_t*) &rdback, sizeof(rdback), &num); + + if (ret < 0) + return CUPS_BACKEND_FAILED; + + INFO("Printer state: %s\n", selphyneo_statuses(rdback.data[0])); + INFO("Media type: %s\n", selphynew_pgcodes(rdback.data[6])); + if (rdback.data[2]) { + INFO("Printer error: %s\n", selphyneo_errors(rdback.data[2])); + } + + return CUPS_BACKEND_OK; +} + static void *selphyneo_init(void) { struct selphyneo_ctx *ctx = malloc(sizeof(struct selphyneo_ctx)); @@ -376,12 +404,15 @@ static int selphyneo_cmdline_arg(void *vctx, int argc, char **argv) if (!ctx) return -1; - while ((i = getopt(argc, argv, GETOPT_LIST_GLOBAL "R")) >= 0) { + while ((i = getopt(argc, argv, GETOPT_LIST_GLOBAL "Rs")) >= 0) { switch(i) { GETOPT_PROCESS_GLOBAL case 'R': selphyneo_send_reset(ctx); break; + case 's': + selphyneo_get_status(ctx); + break; } if (j) return j; @@ -393,11 +424,12 @@ static int selphyneo_cmdline_arg(void *vctx, int argc, char **argv) static void selphyneo_cmdline(void) { DEBUG("\t\t[ -R ] # Reset printer\n"); + DEBUG("\t\t[ -s ] # Query printer status\n"); } struct dyesub_backend canonselphyneo_backend = { .name = "Canon SELPHY CPneo", - .version = "0.10", + .version = "0.11", .uri_prefix = "canonselphyneo", .cmdline_usage = selphyneo_cmdline, .cmdline_arg = selphyneo_cmdline_arg, |