mirror of
https://git.familie-radermacher.ch/linux/ptouch-print.git
synced 2026-09-15 22:27:34 +00:00
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:
committed by
Dominic Radermacher
parent
ef6e6f4925
commit
41c4af0d0d
@@ -62,6 +62,10 @@ struct _pt_dev_info {
|
|||||||
Brother "Software Developer's Manual - Raster Command Reference,
|
Brother "Software Developer's Manual - Raster Command Reference,
|
||||||
PT-P900/P900W/P950NW", section 2.3.5 "Raster line". 0 = centred. */
|
PT-P900/P900W/P950NW", section 2.3.5 "Raster line". 0 = centred. */
|
||||||
int pin_offset;
|
int pin_offset;
|
||||||
|
/* Seconds to wait for a status response when the user did not ask for a
|
||||||
|
particular --timeout. 0 means use the global default; a printer only
|
||||||
|
needs an entry here if the global default is too short for it. */
|
||||||
|
int min_timeout;
|
||||||
};
|
};
|
||||||
typedef struct _pt_dev_info *pt_dev_info;
|
typedef struct _pt_dev_info *pt_dev_info;
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -107,7 +107,7 @@ struct _pt_dev_info ptdevs[] = {
|
|||||||
/* 3,5/6/9/12/18 mm TZe Tapes, 12mm and 18mm tested */
|
/* 3,5/6/9/12/18 mm TZe Tapes, 12mm and 18mm tested */
|
||||||
/* 5,2/9/11,2 mm HSe heat shrink tubes not tested, probably requiring extension of struct _pt_tape_info */
|
/* 5,2/9/11,2 mm HSe heat shrink tubes not tested, probably requiring extension of struct _pt_tape_info */
|
||||||
{0x04f9, 0x2201, "PT-E310BT", 128, 180, FLAG_P700_INIT|FLAG_USE_INFO_CMD|FLAG_D460BT_MAGIC, 0},
|
{0x04f9, 0x2201, "PT-E310BT", 128, 180, FLAG_P700_INIT|FLAG_USE_INFO_CMD|FLAG_D460BT_MAGIC, 0},
|
||||||
{0x04f9, 0x2203, "PT-E560BT", 128, 180, FLAG_P700_INIT|FLAG_USE_INFO_CMD|FLAG_D460BT_MAGIC, 0},
|
{0x04f9, 0x2203, "PT-E560BT", 128, 180, FLAG_P700_INIT|FLAG_USE_INFO_CMD|FLAG_D460BT_MAGIC, 0, 10},
|
||||||
{0,0,"",0,0,0,0}
|
{0,0,"",0,0,0,0}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+8
-2
@@ -108,7 +108,7 @@ static struct argp_option options[] = {
|
|||||||
{ "writepng", 'w', "<file>", OPTION_ALIAS, "alias for write-png", 1},
|
{ "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},
|
{ "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},
|
{ "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},
|
{ 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},
|
{ "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,
|
.forced_tape_width = 0,
|
||||||
.save_png = NULL,
|
.save_png = NULL,
|
||||||
.verbose = 0,
|
.verbose = 0,
|
||||||
.timeout = 1
|
.timeout = -1 /* -1 = not given; 0 is already "infinity" */
|
||||||
};
|
};
|
||||||
|
|
||||||
job_t *jobs = NULL;
|
job_t *jobs = NULL;
|
||||||
@@ -751,6 +751,12 @@ int main(int argc, char *argv[])
|
|||||||
if (ptouch_init(ptdev) != 0) {
|
if (ptouch_init(ptdev) != 0) {
|
||||||
printf(_("ptouch_init() failed\n"));
|
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) {
|
if (ptouch_getstatus(ptdev, arguments.timeout) != 0) {
|
||||||
printf(_("ptouch_getstatus() failed\n"));
|
printf(_("ptouch_getstatus() failed\n"));
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user