From: Gerhard Sittig Date: Sun, 11 Feb 2018 15:16:17 +0000 (+0100) Subject: usbtmc: only reset Siglent (and Atten) devices in open X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=7a970e3170a94b6cb8f6f92647552643dd20dc9a;p=libsigrok.git usbtmc: only reset Siglent (and Atten) devices in open Make the USB reset for USB TMC devices conditional. Check a whitelist, which in this implementation exclusively contains the Siglent VID. The whitelist's comment may need adjustment. The VID probably not only applies to SDS devices, but could be used for SDG and others as well. And lsusb output suggests the VID is used by Atten, too. --- diff --git a/src/scpi/scpi_usbtmc_libusb.c b/src/scpi/scpi_usbtmc_libusb.c index 7e49a8a0..a109703e 100644 --- a/src/scpi/scpi_usbtmc_libusb.c +++ b/src/scpi/scpi_usbtmc_libusb.c @@ -111,6 +111,12 @@ static struct usbtmc_blacklist blacklist_remote[] = { ALL_ZERO }; +/* Devices that shall get reset during open(). */ +static struct usbtmc_blacklist whitelist_usb_reset[] = { + { 0xf4ec, 0xffff }, /* All Siglent SDS devices */ + ALL_ZERO +}; + static GSList *scpi_usbtmc_libusb_scan(struct drv_context *drvc) { struct libusb_device **devlist; @@ -291,6 +297,7 @@ static int scpi_usbtmc_libusb_open(struct sr_scpi_dev_inst *scpi) int confidx, intfidx, epidx, config = 0, current_config; uint8_t capabilities[24]; int ret, found = 0; + int do_reset; if (usb->devhdl) return SR_OK; @@ -371,7 +378,11 @@ static int scpi_usbtmc_libusb_open(struct sr_scpi_dev_inst *scpi) return SR_ERR; } - libusb_reset_device(usb->devhdl); + /* Optionally reset the USB device. */ + do_reset = check_usbtmc_blacklist(whitelist_usb_reset, + des.idVendor, des.idProduct); + if (do_reset) + libusb_reset_device(usb->devhdl); /* Get capabilities. */ ret = libusb_control_transfer(usb->devhdl, LIBUSB_ENDPOINT_IN |