canonselphy/selphyneo: Add support for querying printer status.

It's full-featured on the selphyneo, but on the older ones it's dumber.
This commit is contained in:
Solomon Peachy 2018-01-04 10:00:57 -05:00
parent 33278db787
commit 6f704c3b94
3 changed files with 60 additions and 4 deletions

2
README
View File

@ -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

View File

@ -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,

View File

@ -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,