I am trying to establish communication with an usb device. I do have libusb1 and libusb installed in Python as well as driver installed for the device I am communicating with. The device appears as libusb-win32-devices in the Device Manager. I have tried to follow this tutorial https://github.com/walac/pyusb/blob/master/docs/tutorial.rst I am not sure what I am doing wrong.
- Windows 10
- Python: 2.7.15
- pyusb: version '1.0.2'
Simple code example:
import usb
dev = usb.core.find(idVendor=0x0683, idProduct=0x4108)
if dev is None:
print 'Unable to find the usb device'
dev.set_configuration()
I get this error:
---------------------------------------------------------------------------
USBError Traceback (most recent call last)
Y:\All Projects\Lab Equipment\DataQ\python\DI-4108\DI_4108_SANDBOX.py in <module>()
9
10
---> 11 dev.set_configuration()
12
13 # get an endpoint instance
C:\Anaconda2\lib\site-packages\usb\core.pyc in set_configuration(self, configuration)
867 without arguments is enough to get the device ready.
868 """
--> 869 self._ctx.managed_set_configuration(self, configuration)
870
871 def get_active_configuration(self):
C:\Anaconda2\lib\site-packages\usb\core.pyc in wrapper(self, *args, **kwargs)
100 try:
101 self.lock.acquire()
--> 102 return f(self, *args, **kwargs)
103 finally:
104 self.lock.release()
C:\Anaconda2\lib\site-packages\usb\core.pyc in managed_set_configuration(self, device, config)
146
147 self.managed_open()
--> 148 self.backend.set_configuration(self.handle, cfg.bConfigurationValue)
149
150 # cache the index instead of the object to avoid cyclic references
C:\Anaconda2\lib\site-packages\usb\backend\libusb1.pyc in set_configuration(self, dev_handle, config_value)
792 @methodtrace(_logger)
793 def set_configuration(self, dev_handle, config_value):
--> 794 _check(self.lib.libusb_set_configuration(dev_handle.handle, config_value))
795
796 @methodtrace(_logger)
C:\Anaconda2\lib\site-packages\usb\backend\libusb1.pyc in _check(ret)
593 raise NotImplementedError(_strerror(ret))
594 else:
--> 595 raise USBError(_strerror(ret), ret, _libusb_errno[ret])
596
597 return ret
USBError: [Errno 2] Entity not found
I do get information about my device:
> DEVICE ID 0683:4108 on Bus 002 Address 005 ================= bLength
> : 0x12 (18 bytes) bDescriptorType : 0x1 Device bcdUSB
> : 0x200 USB 2.0 bDeviceClass : 0xff Vendor-specific
> bDeviceSubClass : 0x0 bDeviceProtocol : 0x0
> bMaxPacketSize0 : 0x40 (64 bytes) idVendor :
> 0x0683 idProduct : 0x4108 bcdDevice :
> 0x100 Device 1.0 iManufacturer : 0x1 Error Accessing
> String iProduct : 0x2 Error Accessing String
> iSerialNumber : 0x3 Error Accessing String
> bNumConfigurations : 0x1 CONFIGURATION 1: 500 mA
> ================================== bLength : 0x9 (9 bytes) bDescriptorType : 0x2 Configuration wTotalLength
> : 0x20 (32 bytes) bNumInterfaces : 0x1
> bConfigurationValue : 0x1 iConfiguration : 0x5 Error
> Accessing String bmAttributes : 0xc0 Self Powered
> bMaxPower : 0xfa (500 mA)
> INTERFACE 0: Vendor Specific ===========================
> bLength : 0x9 (9 bytes)
> bDescriptorType : 0x4 Interface
> bInterfaceNumber : 0x0
> bAlternateSetting : 0x0
> bNumEndpoints : 0x2
> bInterfaceClass : 0xff Vendor Specific
> bInterfaceSubClass : 0x0
> bInterfaceProtocol : 0x0
> iInterface : 0x4 Error Accessing String
> ENDPOINT 0x81: Bulk IN ===============================
> bLength : 0x7 (7 bytes)
> bDescriptorType : 0x5 Endpoint
> bEndpointAddress : 0x81 IN
> bmAttributes : 0x2 Bulk
> wMaxPacketSize : 0x40 (64 bytes)
> bInterval : 0x0
> ENDPOINT 0x1: Bulk OUT ===============================
> bLength : 0x7 (7 bytes)
> bDescriptorType : 0x5 Endpoint
> bEndpointAddress : 0x1 OUT
> bmAttributes : 0x2 Bulk
> wMaxPacketSize : 0x40 (64 bytes)
> bInterval : 0x0
So, the final question is: How do I get premissions in Windows? In Linux, you can do it through udev. How to fix this problem in Windows?