s1245: Implement the canceljob command.

All that's left is the actual printing.  And testing all of this on a
real printer.
master
Solomon Peachy 8 years ago
parent 06320b61db
commit 4a34c4e740

@ -326,13 +326,18 @@
-m Query media information
-u Query user string
-U somestring Set user string to 'somestring'
-X id Cancel print job 'id' [2]
[1] This terminates the backend as soon as the printer has acknowledged
[1] This terminates the backend as soon as the printer has acknowledged
the print job, without waiting for the print job to complete.
This can also be enabled by setting the 'FAST_RETURN' environment
variable. This is the default behavior when using this backend
with CUPS.
[2] Job ID is the Internal Job ID (reported via status)
This cancels a multi-copy print job.
To see which jobs are active/pending, see the output of the
'-s' command, specifically the 'Bank' output.
***************************************************************************
BACKEND=sonyupdr150

@ -574,6 +574,30 @@ static int shinkos1245_set_printerid(struct shinkos1245_ctx *ctx,
return 0;
}
static int shinkos1245_canceljob(struct shinkos1245_ctx *ctx,
int id)
{
struct shinkos1245_cmd_canceljob cmd;
struct shinkos1245_resp_status sts;
int ret, num;
shinkos1245_fill_hdr(&cmd.hdr);
cmd.cmd[0] = 0x13;
cmd.id = id;
ret = shinkos1245_do_cmd(ctx, &cmd, sizeof(cmd),
&sts, sizeof(sts), &num);
if (ret < 0) {
ERROR("Failed to execute CANCELJOB command\n");
return ret;
}
if (sts.code != CMD_CODE_OK) {
ERROR("Bad return code on CANCELJOB command\n");
return -99;
}
return 0;
}
/* Structure dumps */
static void shinkos1245_dump_status(struct shinkos1245_resp_status *sts)
@ -721,7 +745,8 @@ static void shinkos1245_cmdline(void)
DEBUG("\t\t[ -m ] # Query media\n");
DEBUG("\t\t[ -s ] # Query status\n");
DEBUG("\t\t[ -u ] # Query user string\n");
DEBUG("\t\t[ -U sometext ] # Set user string\n");
DEBUG("\t\t[ -U sometext ] # Set user string\n");
DEBUG("\t\t[ -X jobid ] # Abort a printjob\n");
}
int shinkos1245_cmdline_arg(void *vctx, int argc, char **argv)
@ -732,7 +757,7 @@ int shinkos1245_cmdline_arg(void *vctx, int argc, char **argv)
/* Reset arg parsing */
optind = 1;
opterr = 0;
while ((i = getopt(argc, argv, "fmsuU:")) >= 0) {
while ((i = getopt(argc, argv, "fmsuU:X:")) >= 0) {
switch(i) {
case 'f':
if (!ctx)
@ -773,6 +798,11 @@ int shinkos1245_cmdline_arg(void *vctx, int argc, char **argv)
return 1;
j = shinkos1245_set_printerid(ctx, optarg);
break;
case 'X':
if (!ctx)
return 1;
j = shinkos1245_canceljob(ctx, atoi(optarg));
break;
default:
break; /* Ignore completely */
}

Loading…
Cancel
Save