allow a printer to raise the default status timeout

The PT-E560BT stays busy about 2.2 s after even an 8 mm label, so the
1 second default timeout cannot succeed on a job sent straight after
another: printing five chained labels gives a strip carrying three of
them. ptouch-print reports the timeout and exits non-zero correctly every
time, but no amount of waiting helps when the default is below the
printer's fixed overhead.

Add a trailing min_timeout to the device table. Every other row keeps its
initialiser and gets 0, which resolves to the old default of 1; only the
E560BT carries a value. An explicit --timeout always wins.

Raising the global default would also be defensible: ptouch_getstatus()
returns as soon as the status arrives, measured 0.13 s with --timeout 30
against 0.14 s with --timeout 1, so a higher ceiling costs nothing on a
printer that is ready. But that is a judgement about printers I do not
have, so this keeps it to the one that was measured.
This commit is contained in:
Kevin Bradenstein authored and Dominic Radermacher committed 2026-09-08 07:19:13 +02:00
1 parent ef6e6f4925
commit 41c4af0d0d
3 files changed
+13 -3

No files matched your search

+8 -2
View File
@@ -108,7 +108,7 @@ static struct argp_option options[] = {
{ "writepng", 'w', "<file>", OPTION_ALIAS, "alias for write-png", 1},
{ "force-tape-width", 6, "<px>", 0, "Set tape width in pixels, use together with --writepng without a printer connected", 1},
{ "copies", 7, "<number>", 0, "Sets the number of identical prints", 1},
{ "timeout", 8, "<seconds>", 0, "Set timeout waiting for finishing previous job. Default:1, 0 means infinity", 1},
{ "timeout", 8, "<seconds>", 0, "Set timeout waiting for finishing previous job. Default:1, or a per-printer minimum where one is known. 0 means infinity", 1},
{ 0, 0, 0, 0, "print commands:", 2},
{ "image", 'i', "<file>", 0, "Print the given image which must be a 2 color (black/white) png", 2},
@@ -141,7 +141,7 @@ struct arguments arguments = {
.forced_tape_width = 0,
.save_png = NULL,
.verbose = 0,
.timeout = 1
.timeout = -1 /* -1 = not given; 0 is already "infinity" */
};
job_t *jobs = NULL;
@@ -751,6 +751,12 @@ int main(int argc, char *argv[])
if (ptouch_init(ptdev) != 0) {
printf(_("ptouch_init() failed\n"));
}
/* Resolve the timeout only now, because it can depend on which
printer answered. An explicit --timeout always wins. */
if (arguments.timeout < 0) {
arguments.timeout = ptdev->devinfo->min_timeout > 0
? ptdev->devinfo->min_timeout : 1;
}
if (ptouch_getstatus(ptdev, arguments.timeout) != 0) {
printf(_("ptouch_getstatus() failed\n"));
return 1;