From: Gerhard Sittig Date: Sat, 22 May 2021 10:25:27 +0000 (+0200) Subject: hp-59306a: only match when conn= is given to avoid false probe positives X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=d008c0273fb168dc78cf2a8b682cf11ecb36a871;p=libsigrok.git hp-59306a: only match when conn= is given to avoid false probe positives The HP 59306A device was made in 1973 and would not reliably identify by means of SCPI queries. The previous scan() implementation would have matched any connected SCPI device, then upset these devices by emitting non-SCPI requests. Tighten the scope of the hp-59306a probe, only scan for devices when a conn= spec was provided. This avoids false positives and malfunction of other devices, and still lets users address the problematic device. This is similar to serial-dmm and unspecific cables and has proven to work there. How to reproduce the issue: (while any auto enumerating SCPI device is connected) $ sigrok-cli --scan --- diff --git a/src/hardware/hp-59306a/api.c b/src/hardware/hp-59306a/api.c index 6038bccb..28927432 100644 --- a/src/hardware/hp-59306a/api.c +++ b/src/hardware/hp-59306a/api.c @@ -50,6 +50,14 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi) size_t idx, nr; struct sr_channel_group *cg; + /* + * The device cannot get identified by means of SCPI queries. + * Neither shall non-SCPI requests get emitted before reliable + * identification of the device. Assume that we only get here + * when user specs led us to believe it's safe to communicate + * to the expected kind of device. + */ + sdi = g_malloc0(sizeof(*sdi)); sdi->vendor = g_strdup("Hewlett-Packard"); sdi->model = g_strdup("59306A"); @@ -79,6 +87,14 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi) static GSList *scan(struct sr_dev_driver *di, GSList *options) { + const char *conn; + + /* Only scan for a device when conn= was specified. */ + conn = NULL; + (void)sr_serial_extract_options(options, &conn, NULL); + if (!conn) + return NULL; + return sr_scpi_scan(di->context, options, probe_device); }