X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fscpi%2Fscpi_usbtmc_libusb.c;h=cd9ade47c18ff736bb1dab1e583be160d7380860;hb=98654c99daf85bd2a81a9c87f517e800c31e34f2;hp=61d1b70d02f0b7a6935da871fef51e02d3c9e21d;hpb=04229f7bfc750f2b67e8dd54ac82ae6bb7eae1e4;p=libsigrok.git diff --git a/src/scpi/scpi_usbtmc_libusb.c b/src/scpi/scpi_usbtmc_libusb.c index 61d1b70d..cd9ade47 100644 --- a/src/scpi/scpi_usbtmc_libusb.c +++ b/src/scpi/scpi_usbtmc_libusb.c @@ -45,7 +45,6 @@ struct scpi_usbtmc_libusb { int response_length; int response_bytes_read; int remaining_length; - int rigol_ds1000; }; /* Some USBTMC-specific enums, as defined in the USBTMC standard. */ @@ -105,6 +104,8 @@ struct usbtmc_blacklist { 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 }, ALL_ZERO }; @@ -345,8 +346,6 @@ static int scpi_usbtmc_libusb_open(struct sr_scpi_dev_inst *scpi) } } found = 1; - uscpi->rigol_ds1000 = des.idVendor == 0x1ab1 && - des.idProduct == 0x0588; } libusb_free_config_descriptor(confdes); if (found) @@ -380,24 +379,6 @@ static int scpi_usbtmc_libusb_open(struct sr_scpi_dev_inst *scpi) return SR_ERR; } - if (!uscpi->rigol_ds1000) { - 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_in_ep, libusb_error_name(ret)); - return SR_ERR; - } - 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)); - return SR_ERR; - } - if ((ret = libusb_clear_halt(usb->devhdl, uscpi->interrupt_ep)) < 0) { - sr_err("Failed to clear halt/stall condition for EP %d: %s.", - uscpi->interrupt_ep, libusb_error_name(ret)); - return SR_ERR; - } - } - /* Get capabilities. */ ret = libusb_control_transfer(usb->devhdl, LIBUSB_ENDPOINT_IN | @@ -638,21 +619,24 @@ 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; - if (!uscpi->rigol_ds1000) { - 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_in_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)); - if ((ret = libusb_clear_halt(usb->devhdl, uscpi->interrupt_ep)) < 0) - sr_err("Failed to clear halt/stall condition for EP %d: %s.", - uscpi->interrupt_ep, libusb_error_name(ret)); + 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);