X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Funi-t-ut32x%2Fapi.c;h=0329727fbf5385522e1527af1f4a5d3b3644a8a1;hb=b2ea391147a838ea03d475add4e345d1575fdbdf;hp=199fe473c069af6e86519029ff2e2b03dfddabff;hpb=164c5ae537f1ae60641cd496b8332436b49c6557;p=libsigrok.git diff --git a/src/hardware/uni-t-ut32x/api.c b/src/hardware/uni-t-ut32x/api.c index 199fe473..0329727f 100644 --- a/src/hardware/uni-t-ut32x/api.c +++ b/src/hardware/uni-t-ut32x/api.c @@ -65,7 +65,13 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) struct dev_context *devc; size_t i; - conn = "hid/ch9325"; + /* + * Implementor's note: Do _not_ add a default conn value here, + * always expect users to specify the connection. Otherwise the + * UT32x driver's scan routine results in false positives, will + * match _any_ UT-D04 cable which uses the same USB HID chip. + */ + conn = NULL; serialcomm = "2400/8n1"; for (l = options; l; l = l->next) { src = l->data; @@ -78,11 +84,12 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) break; } } + if (!conn) + return NULL; devices = NULL; serial = sr_serial_dev_inst_new(conn, serialcomm); rc = serial_open(serial, SERIAL_RDWR); - serial_flush(serial); /* Cannot query/identify the device. Successful open shall suffice. */ serial_close(serial); if (rc != SR_OK) { @@ -106,10 +113,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) } devices = g_slist_append(devices, sdi); - serial_close(serial); - if (!devices) - sr_serial_dev_inst_free(serial); - return std_scan_complete(di, devices); }