From: Gerhard Sittig Date: Tue, 18 Jun 2019 17:26:04 +0000 (+0200) Subject: serial_hid: restrict .list() result set, supported chips only X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=74eeebfb6da68d128575eaeebdeeb588f7787808;p=libsigrok.git serial_hid: restrict .list() result set, supported chips only The --list-serial output was excessively large for the HID transport, listing mice and keyboards and other stuff that could never by used for serial communication. Especially when one device provided multiple interfaces, and on Windows where paths are rather long by default. Limit the result set of the HID transport's .list() operation. Only consider connections that we know how to communicate to (supported chip type). The others are not usable anyway, so there is no point in presenting them to the user. --- diff --git a/src/serial_hid.c b/src/serial_hid.c index ac9afaca..221bb6af 100644 --- a/src/serial_hid.c +++ b/src/serial_hid.c @@ -181,9 +181,10 @@ static char *extract_hidapi_path(const char *copy) } /* - * The HIDAPI specific list() callback, invoked by common serial.c code. - * Enumerate all devices (no VID:PID is involved). - * Invoke an 'append' callback with "path" and "name". + * Enumerate all devices (no VID:PID is involved). Invoke an 'append' + * callback with "path" and "name". Exclusively list connections that + * involve supported chip types, because mice and keyboards etc are not + * too useful to communicate to measurement equipment. */ static GSList *ser_hid_hidapi_list(GSList *list, sr_ser_list_append_t append) { @@ -197,14 +198,14 @@ static GSList *ser_hid_hidapi_list(GSList *list, sr_ser_list_append_t append) devs = hid_enumerate(0x0000, 0x0000); for (curdev = devs; curdev; curdev = curdev->next) { /* - * Determine the chip name from VID:PID (if it's one of - * the supported types with an ID known to us). + * Determine the chip name from VID:PID. Exlusively list + * supported connection types (known chips). */ vid = curdev->vendor_id; pid = curdev->product_id; chipname = ser_hid_chip_find_name_vid_pid(vid, pid); if (!chipname) - chipname = ""; + continue; /* * Prefix port names such that open() calls with this