Search code examples
pythonwindows-10usbpyusb

Simple communication USB with python PyUSB on Windows 10


I'm trying to communicate with a USB device with python. I am running Windows 10 and that I use Python 3.7.2 32bit. I installed PyUSB with pip

pip install pyusb

Here is my test code

import usb.core

dev = usb.core.find(idVendor=0x1664, idProduct=0x0001)
if dev is None:
    raise ValueError('Device not found')
dev.set_configuration()
print("Read: ", dev.read(0x81, 7))
print("Write: ", dev.write(1, '0xB1')) 

On my reading function or my writing function I have an error:

usb.core.USBError: [Errno 5] Input/Output Error

Do you have any idea what's wrong?

Thank you in advance for your help.


Solution

  • I found a solution. I used this software zadig to change the usb driver of my device from WinUSB to libusb-win32.

    Now read write work perfectly.