]> sigrok.org Git - libsigrok.git/blobdiff - src/scpi/scpi_usbtmc_libusb.c
hp-3478a: Initial driver skeleton.
[libsigrok.git] / src / scpi / scpi_usbtmc_libusb.c
index decafdb62af3c44b0635853d751694d0fb29eef8..a109703ea0318d81d43877cc2fa1364a625b1cab 100644 (file)
@@ -107,6 +107,13 @@ static struct usbtmc_blacklist blacklist_remote[] = {
        { 0x1ab1, 0x04b0 }, /* Rigol DS2000 series */
        { 0x0957, 0x0588 }, /* Agilent DSO1000 series (rebadged Rigol DS1000) */
        { 0x0b21, 0xffff }, /* All Yokogawa devices */
+       { 0xf4ec, 0xffff }, /* All Siglent SDS devices */
+       ALL_ZERO
+};
+
+/* Devices that shall get reset during open(). */
+static struct usbtmc_blacklist whitelist_usb_reset[] = {
+       { 0xf4ec, 0xffff }, /* All Siglent SDS devices */
        ALL_ZERO
 };
 
@@ -155,7 +162,7 @@ static GSList *scpi_usbtmc_libusb_scan(struct drv_context *drvc)
        }
        libusb_free_device_list(devlist, 1);
 
-       sr_dbg("Found %d device(s).", g_slist_length(resources));
+       /* No log message for #devices found (caller will log that). */
 
        return resources;
 }
@@ -290,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;
@@ -370,6 +378,12 @@ static int scpi_usbtmc_libusb_open(struct sr_scpi_dev_inst *scpi)
                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);
+
        /* Get capabilities. */
        ret = libusb_control_transfer(usb->devhdl, LIBUSB_ENDPOINT_IN |
                LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE,
@@ -617,7 +631,7 @@ static int scpi_usbtmc_libusb_close(struct sr_scpi_dev_inst *scpi)
        if ((ret = libusb_release_interface(usb->devhdl, uscpi->interface)) < 0)
                sr_err("Failed to release interface: %s.",
                       libusb_error_name(ret));
-       
+
        if (uscpi->detached_kernel_driver) {
                if ((ret = libusb_attach_kernel_driver(usb->devhdl,
                                                uscpi->interface)) < 0)