From: Daniel Elstner Date: Wed, 16 Sep 2015 20:35:13 +0000 (+0200) Subject: sysclk-lwla: Set USB device configuration X-Git-Tag: libsigrok-0.4.0~282 X-Git-Url: http://sigrok.org/gitweb/?a=commitdiff_plain;ds=sidebyside;h=ad6181e25ea04c1cfed6bd89d108a60454ab6cb6;p=libsigrok.git sysclk-lwla: Set USB device configuration After opening the USB device, set the device configuration to 1. Actually, do it twice, just as the vendor driver seems to do. This is supposed to trigger a lightweight reset of the device. Originally, I omitted this reset sequence from the sigrok driver because it simply did not work at all for me. However, it does seem to work now, so that may have been a problem in libusb or the kernel which is now fixed. With some luck, this change may finally fix #327. --- diff --git a/src/hardware/sysclk-lwla/api.c b/src/hardware/sysclk-lwla/api.c index cee779eb..154d4f90 100644 --- a/src/hardware/sysclk-lwla/api.c +++ b/src/hardware/sysclk-lwla/api.c @@ -203,6 +203,18 @@ static int dev_open(struct sr_dev_inst *sdi) if (ret != SR_OK) return ret; + /* Set the configuration twice to trigger a lightweight reset. + */ + ret = libusb_set_configuration(usb->devhdl, USB_CONFIG); + if (ret == 0) + ret = libusb_set_configuration(usb->devhdl, USB_CONFIG); + if (ret != 0) { + sr_err("Failed to set USB configuration: %s.", + libusb_error_name(ret)); + sr_usb_close(usb); + return SR_ERR; + } + ret = libusb_claim_interface(usb->devhdl, USB_INTERFACE); if (ret < 0) { sr_err("Failed to claim interface: %s.", diff --git a/src/hardware/sysclk-lwla/protocol.h b/src/hardware/sysclk-lwla/protocol.h index ce489f71..aedac6ee 100644 --- a/src/hardware/sysclk-lwla/protocol.h +++ b/src/hardware/sysclk-lwla/protocol.h @@ -34,6 +34,7 @@ #define MODEL_NAME "LWLA1034" #define USB_VID_PID "2961.6689" +#define USB_CONFIG 1 #define USB_INTERFACE 0 #define USB_TIMEOUT_MS 3000