summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README2
-rw-r--r--backend_canonselphy.c26
-rw-r--r--backend_canonselphyneo.c36
3 files changed, 60 insertions, 4 deletions
diff --git a/README b/README
index 108cd28..6c8d14e 100644
--- a/README
+++ b/README
@@ -251,6 +251,7 @@
Valid commands:
-R Reset printer to factory defaults
+ -s Query printer status
***************************************************************************
BACKEND=canonselphyneo
@@ -270,6 +271,7 @@
Valid commands:
-R Reset printer to factory defaults
+ -s Query printer status
***************************************************************************
BACKEND=kodak1400
diff --git a/backend_canonselphy.c b/backend_canonselphy.c
index 9c87d08..fb0ca77 100644
--- a/backend_canonselphy.c
+++ b/backend_canonselphy.c
@@ -563,6 +563,24 @@ struct canonselphy_ctx {
uint8_t cp900;
};
+static int canonselphy_get_status(struct canonselphy_ctx *ctx)
+{
+ uint8_t rdbuf[READBACK_LEN];
+ int ret, num;
+
+ /* Read in the printer status */
+ ret = read_data(ctx->dev, ctx->endp_up,
+ (uint8_t*) rdbuf, READBACK_LEN, &num);
+
+ if (ret < 0)
+ return CUPS_BACKEND_FAILED;
+
+ INFO("Media type: %s\n", ctx->printer->pgcode_names? ctx->printer->pgcode_names(rdbuf[ctx->printer->paper_code_offset]) : "Unknown");
+ ctx->printer->error_detect(rdbuf);
+
+ return CUPS_BACKEND_OK;
+}
+
static int canonselphy_send_reset(struct canonselphy_ctx *ctx)
{
uint8_t rstcmd[12] = { 0x40, 0x10, 0x00, 0x00,
@@ -1032,12 +1050,15 @@ static int canonselphy_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':
canonselphy_send_reset(ctx);
break;
+ case 's':
+ canonselphy_get_status(ctx);
+ break;
}
if (j) return j;
@@ -1049,11 +1070,12 @@ static int canonselphy_cmdline_arg(void *vctx, int argc, char **argv)
static void canonselphy_cmdline(void)
{
DEBUG("\t\t[ -R ] # Reset printer\n");
+ DEBUG("\t\t[ -s ] # Query printer status\n");
}
struct dyesub_backend canonselphy_backend = {
.name = "Canon SELPHY CP/ES",
- .version = "0.94",
+ .version = "0.95",
.uri_prefix = "canonselphy",
.cmdline_usage = canonselphy_cmdline,
.cmdline_arg = canonselphy_cmdline_arg,
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,