Add printer reset support to Kodak 68xx and Shinko S1245.

This commit is contained in:
Solomon Peachy 2016-06-28 10:28:42 -04:00
parent 829570e2be
commit fba125714c
3 changed files with 68 additions and 4 deletions

2
README
View File

@ -247,6 +247,7 @@
-C filename Set tone curve [1]
-m Query supported media
-s Query printer status
-R Reset printer to factory defaults
-X id Cancel print job 'id' [2]
Notes:
@ -351,6 +352,7 @@
-u Query user string
-U somestring Set user string to 'somestring'
-X id Cancel print job 'id' [1]
-R Reset printer to factory defaults
-F Tone curve commands affect FINE table
-c filename Query User tone curve from flash [2]
-C filename Store User tone curve in flash [2]

View File

@ -353,6 +353,36 @@ static int kodak68x0_canceljob(struct kodak6800_ctx *ctx,
return 0;
}
static int kodak68x0_reset(struct kodak6800_ctx *ctx)
{
uint8_t req[16];
int ret, num;
struct kodak68x0_status_readback sts;
memset(req, 0, sizeof(req));
req[0] = 0x03;
req[1] = 0x1b;
req[2] = 0x43;
req[3] = 0x48;
req[4] = 0xc0;
/* Issue command and get response */
if ((ret = kodak6800_do_cmd(ctx, req, sizeof(req),
&sts, sizeof(sts),
&num)))
return ret;
/* Validate proper response */
if (sts.hdr != CMD_CODE_OK) {
ERROR("Unexpected response from job cancel!\n");
return -99;
}
return 0;
}
/* Structure dumps */
static char *kodak68x0_status_str(struct kodak68x0_status_readback *resp)
{
@ -892,6 +922,7 @@ static void kodak6800_cmdline(void)
DEBUG("\t\t[ -C filename ] # Set tone curve\n");
DEBUG("\t\t[ -m ] # Query media\n");
DEBUG("\t\t[ -s ] # Query status\n");
DEBUG("\t\t[ -R ] # Reset printer\n");
DEBUG("\t\t[ -X jobid ] # Cancel Job\n");
}
@ -903,7 +934,7 @@ static int kodak6800_cmdline_arg(void *vctx, int argc, char **argv)
if (!ctx)
return -1;
while ((i = getopt(argc, argv, GETOPT_LIST_GLOBAL "C:c:msX:")) >= 0) {
while ((i = getopt(argc, argv, GETOPT_LIST_GLOBAL "C:c:mRsX:")) >= 0) {
switch(i) {
GETOPT_PROCESS_GLOBAL
case 'c':
@ -915,6 +946,9 @@ static int kodak6800_cmdline_arg(void *vctx, int argc, char **argv)
case 'm':
kodak68x0_dump_mediainfo(ctx->media);
break;
case 'R':
kodak68x0_reset(ctx);
break;
case 's': {
struct kodak68x0_status_readback status;
j = kodak6800_get_status(ctx, &status);
@ -1178,7 +1212,7 @@ static int kodak6800_main_loop(void *vctx, int copies) {
/* Exported */
struct dyesub_backend kodak6800_backend = {
.name = "Kodak 6800/6850",
.version = "0.54",
.version = "0.55",
.uri_prefix = "kodak6800",
.cmdline_usage = kodak6800_cmdline,
.cmdline_arg = kodak6800_cmdline_arg,

View File

@ -606,6 +606,30 @@ static int shinkos1245_canceljob(struct shinkos1245_ctx *ctx,
return 0;
}
static int shinkos1245_reset(struct shinkos1245_ctx *ctx)
{
struct shinkos1245_cmd_reset cmd;
struct shinkos1245_resp_status sts;
int ret, num;
shinkos1245_fill_hdr(&cmd.hdr);
cmd.cmd[0] = 0xc0;
ret = shinkos1245_do_cmd(ctx, &cmd, sizeof(cmd),
&sts, sizeof(sts), &num);
if (ret < 0) {
ERROR("Failed to execute RESET command\n");
return ret;
}
if (sts.code != CMD_CODE_OK) {
ERROR("Bad return code on RESET command\n");
return -99;
}
return 0;
}
static int shinkos1245_set_matte(struct shinkos1245_ctx *ctx,
int intensity)
{
@ -1150,6 +1174,7 @@ static void shinkos1245_cmdline(void)
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[ -R ] # Reset printer\n");
DEBUG("\t\t[ -X jobid ] # Abort a printjob\n");
DEBUG("\t\t[ -F ] # Tone curve refers to FINE mode\n");
DEBUG("\t\t[ -c filename ] # Get user/NV tone curve\n");
@ -1166,7 +1191,7 @@ int shinkos1245_cmdline_arg(void *vctx, int argc, char **argv)
if (!ctx)
return -1;
while ((i = getopt(argc, argv, GETOPT_LIST_GLOBAL "c:C:l:L:FmsuU:X:")) >= 0) {
while ((i = getopt(argc, argv, GETOPT_LIST_GLOBAL "c:C:l:L:FmRsuU:X:")) >= 0) {
switch(i) {
GETOPT_PROCESS_GLOBAL
case 'F':
@ -1189,6 +1214,9 @@ int shinkos1245_cmdline_arg(void *vctx, int argc, char **argv)
if (!j)
shinkos1245_dump_media(ctx->medias, ctx->num_medias);
break;
case 'R':
j = shinkos1245_reset(ctx);
break;
case 's': {
struct shinkos1245_resp_status sts;
j = shinkos1245_get_status(ctx, &sts);
@ -1592,7 +1620,7 @@ static int shinkos1245_query_serno(struct libusb_device_handle *dev, uint8_t end
struct dyesub_backend shinkos1245_backend = {
.name = "Shinko/Sinfonia CHC-S1245",
.version = "0.08WIP",
.version = "0.09WIP",
.uri_prefix = "shinkos1245",
.cmdline_usage = shinkos1245_cmdline,
.cmdline_arg = shinkos1245_cmdline_arg,