PyUSB 错误“USBError: [Errno 2] Entity not found";使用 libusb0 驱动程序 (Windows 10) [英] PyUSB error "USBError: [Errno 2] Entity not found" using libusb0 driver (Windows 10)
问题描述
我正在尝试与 USB 设备建立通信.我确实在 Python 中安装了 libusb1 和 libusb,并为我正在与之通信的设备安装了驱动程序.该设备在设备管理器中显示为 libusb-win32-devices.我试图按照本教程
使用 libusbK 驱动程序的 libusbK USB 设备(在我的例子中是 v3.0.7.0).这将实际安装 libusbK 驱动程序并更改驱动程序.这可以通过
这将解决错误代码的问题
USBError: [Errno 2] 实体未找到
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?
Solution #1: If your USB bulk device appears as libusb-win32 in the device manager. You need to change the libusb-win32 driver which uses libusb0 (v1.0.6.0)
To libusbK USB device which uses libusbK driver (in my case v3.0.7.0). This will actually install libusbK driver and change the driver. This seamlessly can be done with Zadig free software
This will solve the problem with the error code
USBError: [Errno 2] Entity not found
这篇关于PyUSB 错误“USBError: [Errno 2] Entity not found";使用 libusb0 驱动程序 (Windows 10)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!