diff --git a/README b/README index 1934af1..d274a2e 100644 --- a/README +++ b/README @@ -450,7 +450,8 @@ -N [ A | B | M ] Reset Counter A/B/M [2] -p num Set 'P' counter to 'num' -s Query printer status - -S num Specify standby delay (1-99 minutes, 0 disables) [1] + -k num Specify standby delay (1-99 minutes, 0 disables) [1] + -K num Keep Media Status Across Power Cycles (1 yes, 0 no) [1] Notes: diff --git a/backend_citizencw01.c b/backend_citizencw01.c index e40d189..9a1c00e 100644 --- a/backend_citizencw01.c +++ b/backend_citizencw01.c @@ -847,7 +847,7 @@ static int cw01_cmdline_arg(void *vctx, int argc, char **argv) j = cw01_clear_counter(ctx, optarg[0]); break; } - return 1; + return 2; case 's': if (ctx) { j = cw01_get_status(ctx); diff --git a/backend_common.c b/backend_common.c index ec2c857..b1c0373 100644 --- a/backend_common.c +++ b/backend_common.c @@ -27,7 +27,7 @@ #include "backend_common.h" -#define BACKEND_VERSION "0.54" +#define BACKEND_VERSION "0.55" #ifndef URI_PREFIX #error "Must Define URI_PREFIX" #endif @@ -799,7 +799,14 @@ int main (int argc, char **argv) /* Check to see if it is claimed by the backend */ if (backend && backend->cmdline_arg) { int keep = optind; - backend_cmd += backend->cmdline_arg(NULL, argc, argv); + int boo; + + boo = backend->cmdline_arg(NULL, argc, argv); + backend_cmd += boo; + + if (boo > 1) + keep++; + optind = keep; } break; diff --git a/backend_dnpds40.c b/backend_dnpds40.c index bfa01b0..588db91 100644 --- a/backend_dnpds40.c +++ b/backend_dnpds40.c @@ -1507,6 +1507,23 @@ static int dnpds620_standby_mode(struct dnpds40_ctx *ctx, int delay) return 0; } +static int dnpds620_media_keep_mode(struct dnpds40_ctx *ctx, int delay) +{ + struct dnpds40_cmd cmd; + char msg[9]; + int ret; + + /* Generate command */ + dnpds40_build_cmd(&cmd, "MNT_WT", "END_KEEP_MODE", 4); + snprintf(msg, sizeof(msg), "%02d\r", delay); + + if ((ret = dnpds40_do_cmd(ctx, &cmd, (uint8_t*)msg, 4))) + return ret; + + return 0; +} + + static int dnpds40_set_counter_p(struct dnpds40_ctx *ctx, char *arg) { struct dnpds40_cmd cmd; @@ -1531,8 +1548,8 @@ static void dnpds40_cmdline(void) DEBUG("\t\t[ -n ] # Query counters\n"); DEBUG("\t\t[ -N A|B|M ] # Clear counter A/B/M\n"); DEBUG("\t\t[ -p num ] # Set counter P\n"); - DEBUG("\t\t[ -S num ] # Set standby time (1-99 minutes, 0 disables)\n"); - + DEBUG("\t\t[ -S num ] # Set standby time (1-99 minutes, 0 disables)\n"); + DEBUG("\t\t[ -K num ] # Keep Media Status Across Power Cycles (1 on, 0 off)\n"); } static int dnpds40_cmdline_arg(void *vctx, int argc, char **argv) @@ -1543,7 +1560,7 @@ static int dnpds40_cmdline_arg(void *vctx, int argc, char **argv) /* Reset arg parsing */ optind = 1; opterr = 0; - while ((i = getopt(argc, argv, "iInN:p:sS:")) >= 0) { + while ((i = getopt(argc, argv, "iInN:p:sK:k:")) >= 0) { switch(i) { case 'i': if (ctx) { @@ -1556,6 +1573,7 @@ static int dnpds40_cmdline_arg(void *vctx, int argc, char **argv) j = dnpds40_get_sensors(ctx); break; } + return 1; case 'n': if (ctx) { j = dnpds40_get_counters(ctx); @@ -1575,20 +1593,20 @@ static int dnpds40_cmdline_arg(void *vctx, int argc, char **argv) j = dnpds40_clear_counter(ctx, optarg[0]); break; } - return 1; + return 2; case 'p': if (ctx) { j = dnpds40_set_counter_p(ctx, optarg); break; } - return 1; + return 2; case 's': if (ctx) { j = dnpds40_get_status(ctx); break; } return 1; - case 'S': + case 'k': if (ctx) { int time = atoi(optarg); if (!ctx->supports_standby) { @@ -1603,6 +1621,23 @@ static int dnpds40_cmdline_arg(void *vctx, int argc, char **argv) } j = dnpds620_standby_mode(ctx, time); } + return 2; + case 'K': + if (ctx) { + int keep = atoi(optarg); + if (!ctx->supports_standby) { + ERROR("Printer does not support media keep mode\n"); + j = -1; + break; + } + if (keep < 0 || keep > 1) { + ERROR("Value out of range (0-1)"); + j = -1; + break; + } + j = dnpds620_media_keep_mode(ctx, keep); + } + return 2; default: break; /* Ignore completely */ } diff --git a/backend_kodak1400.c b/backend_kodak1400.c index 6c187dc..228da58 100644 --- a/backend_kodak1400.c +++ b/backend_kodak1400.c @@ -268,7 +268,7 @@ int kodak1400_cmdline_arg(void *vctx, int argc, char **argv) j = kodak1400_set_tonecurve(ctx, optarg); break; } - return 1; + return 2; default: break; /* Ignore completely */ } diff --git a/backend_kodak605.c b/backend_kodak605.c index 78c5150..7d6a4b0 100644 --- a/backend_kodak605.c +++ b/backend_kodak605.c @@ -517,7 +517,7 @@ static int kodak605_cmdline_arg(void *vctx, int argc, char **argv) j = kodak605_set_tonecurve(ctx, optarg); break; } - return 1; + return 2; case 'm': if (ctx) { j = kodak605_get_media(ctx); diff --git a/backend_kodak6800.c b/backend_kodak6800.c index f1e27d7..7a32a04 100644 --- a/backend_kodak6800.c +++ b/backend_kodak6800.c @@ -592,13 +592,13 @@ static int kodak6800_cmdline_arg(void *vctx, int argc, char **argv) j = kodak6800_get_tonecurve(ctx, optarg); break; } - return 1; + return 2; case 'C': if (ctx) { j = kodak6800_set_tonecurve(ctx, optarg); break; } - return 1; + return 2; case 'm': if (ctx) { uint8_t mediabuf[MAX_MEDIA_LEN]; diff --git a/backend_shinkos1245.c b/backend_shinkos1245.c index cf62859..357be2e 100644 --- a/backend_shinkos1245.c +++ b/backend_shinkos1245.c @@ -1148,75 +1148,83 @@ int shinkos1245_cmdline_arg(void *vctx, int argc, char **argv) while ((i = getopt(argc, argv, "c:C:l:L:FfmsuU:X:")) >= 0) { switch(i) { case 'F': - if (!ctx) - return 1; - ctx->tonecurve = PARAM_TABLE_FINE; - break; - case 'c': - if (!ctx) - return 1; - - j = get_tonecurve(ctx, TONE_TABLE_USER, ctx->tonecurve, optarg); - break; - case 'C': - if (!ctx) - return 1; - j = set_tonecurve(ctx, TONE_TABLE_USER, ctx->tonecurve, optarg); - break; - case 'l': - if (!ctx) - return 1; - j = get_tonecurve(ctx, TONE_TABLE_CURRENT, ctx->tonecurve, optarg); - break; - case 'L': - if (!ctx) - return 1; - j = set_tonecurve(ctx, TONE_TABLE_CURRENT, ctx->tonecurve, optarg); - break; - case 'f': - if (!ctx) - return 1; - ctx->fast_return = 1; - break; - case 'm': - if (!ctx) - return 1; - j = shinkos1245_get_media(ctx); - if (!j) - shinkos1245_dump_media(ctx->medias, ctx->num_medias); - break; - case 's': { - if (!ctx) - return 1; - struct shinkos1245_resp_status sts; - j = shinkos1245_get_status(ctx, &sts); - if (!j) - shinkos1245_dump_status(&sts); - break; - } - case 'u': { - if (!ctx) - return 1; - struct shinkos1245_resp_getid resp; - j = shinkos1245_get_printerid(ctx, &resp); - if (!j) { - char buffer[sizeof(resp.data)+1]; - memcpy(buffer, resp.data, sizeof(resp.data)); - buffer[sizeof(resp.data)] = 0; - INFO("Printer ID: %02x '%s'\n", resp.id, buffer); + if (ctx) { + ctx->tonecurve = PARAM_TABLE_FINE; + break; } - break; - } + return 1; + case 'c': + if (ctx) { + j = get_tonecurve(ctx, TONE_TABLE_USER, ctx->tonecurve, optarg); + break; + } + return 2; + case 'C': + if (ctx) { + j = set_tonecurve(ctx, TONE_TABLE_USER, ctx->tonecurve, optarg); + break; + } + return 2; + case 'l': + if (ctx) { + j = get_tonecurve(ctx, TONE_TABLE_CURRENT, ctx->tonecurve, optarg); + break; + } + return 2; + case 'L': + if (ctx) { + j = set_tonecurve(ctx, TONE_TABLE_CURRENT, ctx->tonecurve, optarg); + break; + } + return 2; + case 'f': + if (!ctx) { + ctx->fast_return = 1; + break; + } + return 1; + case 'm': + if (ctx) { + j = shinkos1245_get_media(ctx); + if (!j) + shinkos1245_dump_media(ctx->medias, ctx->num_medias); + break; + } + return 1; + case 's': + if (ctx) { + struct shinkos1245_resp_status sts; + j = shinkos1245_get_status(ctx, &sts); + if (!j) + shinkos1245_dump_status(&sts); + break; + } + return 1; + case 'u': + if (ctx) { + struct shinkos1245_resp_getid resp; + j = shinkos1245_get_printerid(ctx, &resp); + if (!j) { + char buffer[sizeof(resp.data)+1]; + memcpy(buffer, resp.data, sizeof(resp.data)); + buffer[sizeof(resp.data)] = 0; + INFO("Printer ID: %02x '%s'\n", resp.id, buffer); + break; + } + } + return 1; case 'U': - if (!ctx) - return 1; - j = shinkos1245_set_printerid(ctx, optarg); - break; + if (ctx) { + j = shinkos1245_set_printerid(ctx, optarg); + break; + } + return 1; case 'X': - if (!ctx) - return 1; - j = shinkos1245_canceljob(ctx, atoi(optarg)); - break; + if (ctx) { + j = shinkos1245_canceljob(ctx, atoi(optarg)); + break; + } + return 1; default: break; /* Ignore completely */ } @@ -1607,7 +1615,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.02WIP", + .version = "0.03WIP", .uri_prefix = "shinkos1245", .cmdline_usage = shinkos1245_cmdline, .cmdline_arg = shinkos1245_cmdline_arg, diff --git a/backend_shinkos2145.c b/backend_shinkos2145.c index 338a77b..8570d33 100644 --- a/backend_shinkos2145.c +++ b/backend_shinkos2145.c @@ -1306,19 +1306,19 @@ int shinkos2145_cmdline_arg(void *vctx, int argc, char **argv) return -1; break; } - return 1; + return 2; case 'c': if (ctx) { j = get_tonecurve(ctx, TONECURVE_USER, optarg); break; } - return 1; + return 2; case 'C': if (ctx) { j = set_tonecurve(ctx, TONECURVE_USER, optarg); break; } - return 1; + return 2; case 'e': if (ctx) { j = get_errorlog(ctx); @@ -1348,13 +1348,13 @@ int shinkos2145_cmdline_arg(void *vctx, int argc, char **argv) j = get_tonecurve(ctx, TONECURVE_CURRENT, optarg); break; } - return 1; + return 2; case 'L': if (ctx) { j = set_tonecurve(ctx, TONECURVE_CURRENT, optarg); break; } - return 1; + return 2; case 'm': if (ctx) { j = get_mediainfo(ctx); @@ -1390,13 +1390,13 @@ int shinkos2145_cmdline_arg(void *vctx, int argc, char **argv) j = set_user_string(ctx, optarg); break; } - return 1; + return 2; case 'X': if (ctx) { j = cancel_job(ctx, optarg); break; } - return 1; + return 2; default: break; /* Ignore completely */ }