【发布时间】:2019-07-11 03:09:56
【问题描述】:
我正在尝试在 python 中使用 pyusb 从 USB 读取数据。我能够获取设备的所有配置,但是当我尝试读取数据时。我收到以下错误:
USBError: [Errno None] libusb0-dll:err [claim_interface] could not claim interface 1, win error: The requested resource is in use.
PF 代码也是我写的:
import usb.core
test = usb.core.find(idVendor=0x0ghe, idProduct=0x0241)
print test
test.set_configuration()
for i in range(0, 20):
while True:
try:
test = test.read(0x81, 8, timeout=50)
break
except usb.core.USBError, e:
if str(e).find("timeout") >= 0:
pass
else:
raise IOError("USB Error: %s"%str(e))
print test
以下是我的问题:
- 当我们在 USB 连接的设备中进行任何操作时,如何每秒从主机中的 USB 读取数据?
- 为什么从端点读取数据时会出现此错误?
- 使用 pyusb 从 USB 读取输入的有效方法是什么?
【问题讨论】:
-
行为是否取决于设备?在您的系统上使用 pyusb 是否有任何访问权限?
-
不,它不依赖于特定设备。是的,它适用于获取具有配置和接口的设备信息。仅用于读取数据我遇到问题。
标签: python python-2.7 pyusb