Windows 10上与python PyUSB的简单通信USB [英] Simple communication USB with python PyUSB on Windows 10

查看:104
本文介绍了Windows 10上与python PyUSB的简单通信USB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 python 与 USB 设备通信.我正在运行 Windows 10 并且我使用 Python 3.7.2 32 位.我用 pip 安装了 PyUSB

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

这是我的测试代码

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] 输入/输出错误

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

你知道出了什么问题吗?

Do you have any idea what's wrong?

预先感谢您的帮助.

推荐答案

我找到了解决方案.我使用这个软件 zadig 将我设备的 USB 驱动程序从 WinUSB 更改为 libusb-win32.

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

现在读写工作完美.

这篇关于Windows 10上与python PyUSB的简单通信USB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆