我的代码如下:
import usb.core
import usb.util
dev = usb.core.find(idVendor=0x18F8, idProduct=0x1286) # 鼠标端口号
# dev=usb.core.find(idVendor='0483',idProduct='5710')#外接USB端口号
print(dev)
if dev is None:
raise ValueError('找不到设备')
# 进行配置
dev.set_configuration()
# 读取数据
data = dev.read(0x82, 7)
print(data)
出现如下错误:
runfile('C:/Users/Admin/.spyder-py3/temp.py', wdir='C:/Users/Admin/.spyder-py3')
DEVICE ID 18f8:1286 on Bus 001 Address 008 =================
bLength : 0x12 (18 bytes)
bDescriptorType : 0x1 Device
bcdUSB : 0x110 USB 1.1
bDeviceClass : 0x0 Specified at interface
bDeviceSubClass : 0x0
bDeviceProtocol : 0x0
bMaxPacketSize0 : 0x8 (8 bytes)
idVendor : 0x18f8
idProduct : 0x1286
bcdDevice : 0x100 Device 1.0
iManufacturer : 0x0
iProduct : 0x1 USB GAMING MOUSE
iSerialNumber : 0x0
bNumConfigurations : 0x1
CONFIGURATION 1: 100 mA ==================================
bLength : 0x9 (9 bytes)
bDescriptorType : 0x2 Configuration
wTotalLength : 0x3b (59 bytes)
bNumInterfaces : 0x2
bConfigurationValue : 0x1
iConfiguration : 0x0
bmAttributes : 0xa0 Bus Powered, Remote Wakeup
bMaxPower : 0x32 (100 mA)
INTERFACE 0: Human Interface Device ====================
bLength : 0x9 (9 bytes)
bDescriptorType : 0x4 Interface
bInterfaceNumber : 0x0
bAlternateSetting : 0x0
bNumEndpoints : 0x1
bInterfaceClass : 0x3 Human Interface Device
bInterfaceSubClass : 0x1
bInterfaceProtocol : 0x2
iInterface : 0x0
ENDPOINT 0x81: Interrupt IN ==========================
bLength : 0x7 (7 bytes)
bDescriptorType : 0x5 Endpoint
bEndpointAddress : 0x81 IN
bmAttributes : 0x3 Interrupt
wMaxPacketSize : 0x8 (8 bytes)
bInterval : 0x8
INTERFACE 1: Human Interface Device ====================
bLength : 0x9 (9 bytes)
bDescriptorType : 0x4 Interface
bInterfaceNumber : 0x1
bAlternateSetting : 0x0
bNumEndpoints : 0x1
bInterfaceClass : 0x3 Human Interface Device
bInterfaceSubClass : 0x0
bInterfaceProtocol : 0x1
iInterface : 0x0
ENDPOINT 0x82: Interrupt IN ==========================
bLength : 0x7 (7 bytes)
bDescriptorType : 0x5 Endpoint
bEndpointAddress : 0x82 IN
bmAttributes : 0x3 Interrupt
wMaxPacketSize : 0x8 (8 bytes)
bInterval : 0x8
Traceback (most recent call last):
File ~\anaconda3\Lib\site-packages\spyder_kernels\py3compat.py:356 in compat_exec
exec(code, globals, locals)
File c:\users\admin\.spyder-py3\temp.py:18
data = dev.read(0x82, 7)
File ~\anaconda3\Lib\site-packages\usb\core.py:1029 in read
ret = fn(
File ~\anaconda3\Lib\site-packages\usb\backend\libusb1.py:864 in intr_read
return self.__read(self.lib.libusb_interrupt_transfer,
File ~\anaconda3\Lib\site-packages\usb\backend\libusb1.py:954 in __read
_check(retval)
File ~\anaconda3\Lib\site-packages\usb\backend\libusb1.py:604 in _check
raise USBError(_strerror(ret), ret, _libusb_errno[ret])
USBError: [Errno 5] Input/Output Error
请问各位大佬,这该如何解决?感谢!