]> sigrok.org Git - libsigrok.git/blobdiff - src/scpi/scpi_usbtmc_libusb.c
std_serial_dev_acquisition_stop(): Drop unneeded parameter.
[libsigrok.git] / src / scpi / scpi_usbtmc_libusb.c
index cd9ade47c18ff736bb1dab1e583be160d7380860..6e472750cb5d2f261227a9c2081f3f75c1ddb3ff 100644 (file)
@@ -101,11 +101,12 @@ struct usbtmc_blacklist {
        uint16_t pid;
 };
 
+/* Devices that publish RL1 support, but don't support it. */
 static struct usbtmc_blacklist blacklist_remote[] = {
-       /* Rigol DS1000 series publishes RL1 support, but doesn't support it. */
-       { 0x1ab1, 0x0588 },
-       /* Agilent DSO1000 series are rebadged versions of the Rigol DS1000. */
-       { 0x0957, 0x0588 },
+       { 0x1ab1, 0x0588 },  /* Rigol DS1000 series */
+       { 0x1ab1, 0x04b0 },  /* Rigol DS2000 series */
+       { 0x0957, 0x0588 },  /* Agilent DSO1000 series (rebadged Rigol DS1000) */
+       { 0x0b21, 0xffff },  /* All Yokogawa devices */
        ALL_ZERO
 };
 
@@ -192,7 +193,8 @@ static int check_usbtmc_blacklist(struct usbtmc_blacklist *blacklist,
        int i;
 
        for (i = 0; blacklist[i].vid; i++) {
-               if (blacklist[i].vid == vid && blacklist[i].pid == pid)
+               if ((blacklist[i].vid == vid && blacklist[i].pid == 0xFFFF) ||
+                       (blacklist[i].vid == vid && blacklist[i].pid == pid))
                        return TRUE;
        }
 
@@ -236,7 +238,7 @@ static int scpi_usbtmc_remote(struct scpi_usbtmc_libusb *uscpi)
                        LIBUSB_ENDPOINT_IN         |
                        LIBUSB_REQUEST_TYPE_CLASS  |
                        LIBUSB_RECIPIENT_INTERFACE,
-                       LOCAL_LOCKOUT, 1,
+                       LOCAL_LOCKOUT, 0,
                        uscpi->interface,
                        &status, 1,
                        TRANSFER_TIMEOUT);
@@ -274,7 +276,7 @@ static void scpi_usbtmc_local(struct scpi_usbtmc_libusb *uscpi)
                        LIBUSB_ENDPOINT_IN         |
                        LIBUSB_REQUEST_TYPE_CLASS  |
                        LIBUSB_RECIPIENT_INTERFACE,
-                       GO_TO_LOCAL, 1,
+                       GO_TO_LOCAL, 0,
                        uscpi->interface,
                        &status, 1,
                        TRANSFER_TIMEOUT);
@@ -299,7 +301,7 @@ static int scpi_usbtmc_libusb_open(struct sr_scpi_dev_inst *scpi)
        struct libusb_config_descriptor *confdes;
        const struct libusb_interface_descriptor *intfdes;
        const struct libusb_endpoint_descriptor *ep;
-       int confidx, intfidx, epidx, config = 0;
+       int confidx, intfidx, epidx, config = 0, current_config;
        uint8_t capabilities[24];
        int ret, found = 0;
 
@@ -367,10 +369,13 @@ static int scpi_usbtmc_libusb_open(struct sr_scpi_dev_inst *scpi)
                uscpi->detached_kernel_driver = 1;
        }
 
-       if ((ret = libusb_set_configuration(usb->devhdl, config)) < 0) {
-               sr_err("Failed to set configuration: %s.",
-                      libusb_error_name(ret));
-               return SR_ERR;
+       if (libusb_get_configuration(usb->devhdl, &current_config) == 0
+           && current_config != config) {
+               if ((ret = libusb_set_configuration(usb->devhdl, config)) < 0) {
+                       sr_err("Failed to set configuration: %s.",
+                              libusb_error_name(ret));
+                       return SR_ERR;
+               }
        }
 
        if ((ret = libusb_claim_interface(usb->devhdl, uscpi->interface)) < 0) {
@@ -619,26 +624,11 @@ static int scpi_usbtmc_libusb_close(struct sr_scpi_dev_inst *scpi)
 {
        struct scpi_usbtmc_libusb *uscpi = scpi->priv;
        struct sr_usb_dev_inst *usb = uscpi->usb;
-       struct libusb_device *dev;
-       struct libusb_device_descriptor des;
        int ret;
 
        if (!usb->devhdl)
                return SR_ERR;
 
-       dev = libusb_get_device(usb->devhdl);
-       libusb_get_device_descriptor(dev, &des);
-       if (des.idVendor == 0x1ab1 && des.idProduct == 0x0588
-                       && scpi->firmware_version >= 24) {
-               /* Rigol DS1000 with firmware > 0.2.4 needs this. */
-               if ((ret = libusb_clear_halt(usb->devhdl, uscpi->bulk_in_ep)) < 0)
-                       sr_err("Failed to clear halt/stall condition for EP %d: %s.",
-                              uscpi->bulk_out_ep, libusb_error_name(ret));
-               if ((ret = libusb_clear_halt(usb->devhdl, uscpi->bulk_out_ep)) < 0)
-                       sr_err("Failed to clear halt/stall condition for EP %d: %s.",
-                              uscpi->bulk_out_ep, libusb_error_name(ret));
-       }
-
        scpi_usbtmc_local(uscpi);
 
        if ((ret = libusb_release_interface(usb->devhdl, uscpi->interface)) < 0)