X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fscpi%2Fscpi_usbtmc_libusb.c;h=6e472750cb5d2f261227a9c2081f3f75c1ddb3ff;hb=c68ade3cc721e0d5c5f24c96a4c461c776328037;hp=9042ef4fd22925c30813900da774d14f4a33234e;hpb=de285cce11aca3afd0d4adfdd514c691e6a71c64;p=libsigrok.git diff --git a/src/scpi/scpi_usbtmc_libusb.c b/src/scpi/scpi_usbtmc_libusb.c index 9042ef4f..6e472750 100644 --- a/src/scpi/scpi_usbtmc_libusb.c +++ b/src/scpi/scpi_usbtmc_libusb.c @@ -101,9 +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 }, + { 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 }; @@ -190,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; } @@ -234,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); @@ -272,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); @@ -297,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; @@ -365,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, ¤t_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) { @@ -617,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)