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.
This commit is contained in:
Gerhard Sittig 2018-02-11 16:16:17 +01:00 committed by Uwe Hermann
parent 9a4cc7dd38
commit 7a970e3170
1 changed files with 12 additions and 1 deletions

View File

@ -111,6 +111,12 @@ static struct usbtmc_blacklist blacklist_remote[] = {
ALL_ZERO 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) static GSList *scpi_usbtmc_libusb_scan(struct drv_context *drvc)
{ {
struct libusb_device **devlist; 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; int confidx, intfidx, epidx, config = 0, current_config;
uint8_t capabilities[24]; uint8_t capabilities[24];
int ret, found = 0; int ret, found = 0;
int do_reset;
if (usb->devhdl) if (usb->devhdl)
return SR_OK; return SR_OK;
@ -371,6 +378,10 @@ static int scpi_usbtmc_libusb_open(struct sr_scpi_dev_inst *scpi)
return SR_ERR; return SR_ERR;
} }
/* 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); libusb_reset_device(usb->devhdl);
/* Get capabilities. */ /* Get capabilities. */