add --serial and --list-connected to pick one of several printers

When more than one printer is connected, ptouch-print used the first
one it found. --serial <serial> now uses only the printer with that USB
serial number, and --list-connected lists the connected printers with
their serials.

libptouch gets ptouch_open_serial() and ptouch_list_connected();
ptouch_open() keeps its signature and calls ptouch_open_serial() with
NULL. The serial is checked before the P-Lite and unsupported-raster
checks, so a different printer in the wrong mode no longer ends the
search, and the "found on USB bus" line now shows the serial. The early
error returns in the open loop now free the device list.
This commit is contained in:
James A
2026-09-25 09:51:25 +02:00
committed by Dominic Radermacher
parent d05d31bb86
commit 7fa1e1ac46
4 changed files with 115 additions and 9 deletions
+2
View File
@@ -107,6 +107,7 @@ struct _ptouch_dev {
typedef struct _ptouch_dev *ptouch_dev;
int ptouch_open(ptouch_dev *ptdev);
int ptouch_open_serial(ptouch_dev *ptdev, const char *serial);
int ptouch_close(ptouch_dev ptdev);
int ptouch_send(ptouch_dev ptdev, uint8_t *data, size_t len);
int ptouch_init(ptouch_dev ptdev);
@@ -130,6 +131,7 @@ int ptouch_rasterstart(ptouch_dev ptdev);
int ptouch_sendraster(ptouch_dev ptdev, uint8_t *data, size_t len);
void ptouch_rawstatus(uint8_t raw[32]);
void ptouch_list_supported();
int ptouch_list_connected();
const char* pt_mediatype(unsigned char media_type);
const char* pt_tapecolor(unsigned char tape_color);