s2145: Enable a 'fast return' mode

This terminates the backend as soon as the printer acks the print job,
allowing the use of both printer bufers.
This commit is contained in:
Solomon Peachy 2013-09-30 13:07:35 +01:00
parent ca0f241e52
commit 140f9ecf42
2 changed files with 20 additions and 3 deletions

8
README
View File

@ -214,6 +214,7 @@
-rp Reset printer to factory defaults -rp Reset printer to factory defaults
-b1 Enable printer control panel buttons -b1 Enable printer control panel buttons
-b0 Disable printer control panel buttons -b0 Disable printer control panel buttons
-f Enable fast return [4]
Notes: Notes:
@ -224,12 +225,17 @@
[2] Format of curvedata file: [2] Format of curvedata file:
256 entries each of Yellow, Magenta, Cyan mappings: 256 entries each of Yellow, Magenta, Cyan mappings:
Values are unsigned 16-bit big endian, between 0 and 2047 Values are unsigned 16-bit big endian, between 0 and 2047
(ie only 11 bits used) (ie only 11 bits used)
[3] Default printer tone curve is a linear 'val << 3' [3] Default printer tone curve is a linear 'val << 3'
[4] 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.
*************************************************************************** ***************************************************************************
BACKEND=sonyupdr150 BACKEND=sonyupdr150

View File

@ -95,6 +95,7 @@ struct shinkos2145_ctx {
uint8_t endp_up; uint8_t endp_up;
uint8_t endp_down; uint8_t endp_down;
uint8_t jobid; uint8_t jobid;
uint8_t fast_return;
struct s2145_printjob_hdr hdr; struct s2145_printjob_hdr hdr;
@ -1302,6 +1303,7 @@ static void shinkos2145_cmdline(char *caller)
DEBUG("\t\t%s [ -qtu filename | -qtc filename ]\n", caller); DEBUG("\t\t%s [ -qtu filename | -qtc filename ]\n", caller);
DEBUG("\t\t%s [ -su somestring | -stu filename | -stc filename ]\n", caller); DEBUG("\t\t%s [ -su somestring | -stu filename | -stc filename ]\n", caller);
DEBUG("\t\t%s [ -pc id | -fl | -ru | -rp | -b1 | -b0 ]\n", caller); DEBUG("\t\t%s [ -pc id | -fl | -ru | -rp | -b1 | -b0 ]\n", caller);
DEBUG("\t\t%s [ -f ]\n", caller);
} }
int shinkos2145_cmdline_arg(void *vctx, int run, char *arg1, char *arg2) int shinkos2145_cmdline_arg(void *vctx, int run, char *arg1, char *arg2)
@ -1324,8 +1326,12 @@ int shinkos2145_cmdline_arg(void *vctx, int run, char *arg1, char *arg2)
!strcmp("-b0", arg1) || !strcmp("-b0", arg1) ||
!strcmp("-stc", arg1) || !strcmp("-stc", arg1) ||
!strcmp("-stu", arg1) || !strcmp("-stu", arg1) ||
!strcmp("-f", arg1) ||
!strcmp("-su", arg1)); !strcmp("-su", arg1));
if (!strcmp("-f", arg1))
ctx->fast_return = 1;
if (!strcmp("-qs", arg1)) if (!strcmp("-qs", arg1))
get_status(ctx); get_status(ctx);
else if (!strcmp("-qf", arg1)) else if (!strcmp("-qf", arg1))
@ -1407,6 +1413,9 @@ static int shinkos2145_read_parse(void *vctx, int data_fd) {
if (!ctx) if (!ctx)
return 1; return 1;
if (getenv("FAST_RETURN"))
ctx->fast_return = 1;
/* Read in then validate header */ /* Read in then validate header */
read(data_fd, &ctx->hdr, sizeof(ctx->hdr)); read(data_fd, &ctx->hdr, sizeof(ctx->hdr));
if (le32_to_cpu(ctx->hdr.len1) != 0x10 || if (le32_to_cpu(ctx->hdr.len1) != 0x10 ||
@ -1569,7 +1578,9 @@ top:
case S_PRINTER_SENT_DATA: case S_PRINTER_SENT_DATA:
if (sts->hdr.result != RESULT_SUCCESS) if (sts->hdr.result != RESULT_SUCCESS)
goto printer_error; goto printer_error;
if (sts->hdr.status == STATUS_READY || if (ctx->fast_return)
state = S_FINISHED;
else if (sts->hdr.status == STATUS_READY ||
sts->hdr.status == STATUS_FINISHED) sts->hdr.status == STATUS_FINISHED)
state = S_FINISHED; state = S_FINISHED;
break; break;
@ -1647,7 +1658,7 @@ static int shinkos2145_query_serno(struct libusb_device_handle *dev, uint8_t end
struct dyesub_backend shinkos2145_backend = { struct dyesub_backend shinkos2145_backend = {
.name = "Shinko/Sinfonia CHC-S2145 (S2)", .name = "Shinko/Sinfonia CHC-S2145 (S2)",
.version = "0.21", .version = "0.22",
.uri_prefix = "shinkos2145", .uri_prefix = "shinkos2145",
.cmdline_usage = shinkos2145_cmdline, .cmdline_usage = shinkos2145_cmdline,
.cmdline_arg = shinkos2145_cmdline_arg, .cmdline_arg = shinkos2145_cmdline_arg,