我写了一个小的python脚本来从数字温度计读取数据,并且一切都可以在我的计算机上正常工作。但是,我需要在其他系统中运行相同的脚本,但是我不断收到“ [Errno 10060]操作超时”错误。
在第二台计算机上,我可以看到该设备,端点和所有内容,但是当我尝试从中读取信息时,我遇到了错误。
这是代码(我有意未设置设备的配置,因为我正试图加快阅读速度,而在我的系统中,这没有必要):
import usb.core
def get_temp(T):
# find our device
dev = usb.core.find(idVendor=0x04d9, idProduct=0xe000)
# was it found?
if dev is None:
raise ValueError('Device not found')
# poll the thermometer for current temperature
t = dev.read(0x83, 32) # gets 32 bytes from ENDPOINT address 0x83
因此,在我编写此代码的计算机中,它按预期运行,并且返回了一个不错的32字节数组。但是在其他系统中,我得到了错误:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\usb\core.py", line 402, in read
return self.device.read(self, size_or_buffer, timeout)
File "C:\Python27\lib\site-packages\usb\core.py", line 988, in read
self.__get_timeout(timeout))
File "C:\Python27\lib\site-packages\usb\backend\libusb1.py", line 851, in
intr_read
timeout)
File "C:\Python27\lib\site-packages\usb\backend\libusb1.py", line 936, in
__read
_check(retval)
File "C:\Python27\lib\site-packages\usb\backend\libusb1.py", line 595, in
_check
raise USBError(_strerror(ret), ret, _libusb_errno[ret])
usb.core.USBError: [Errno 10060] Operation timed out
这次我也尝试设置设备配置,但仍然是相同的错误。
关于我可能会缺少的任何想法?
编辑:这是我的输出日志,其中PYUSB_DEBUG环境变量设置为调试:
>>> dev.read(0x83,32)
2019-01-11 10:35:06,951 DEBUG:usb.backend.libusb1:_LibUSB.get_configuration(<usb.backend.libusb1._DeviceHandle object at 0x02A2A610>)
2019-01-11 10:35:06,953 DEBUG:usb.backend.libusb1:_LibUSB.get_configuration_descriptor(<usb.backend.libusb1._Device object at 0x02A2A650>, 0)
2019-01-11 10:35:06,954 DEBUG:usb.backend.libusb1:_LibUSB.get_interface_descriptor(<usb.backend.libusb1._Device object at 0x02A2A650>, 0, 0, 0)
2019-01-11 10:35:06,956 DEBUG:usb.backend.libusb1:_LibUSB.get_configuration_descriptor(<usb.backend.libusb1._Device object at 0x02A2A650>, 0)
2019-01-11 10:35:06,957 DEBUG:usb.backend.libusb1:_LibUSB.get_endpoint_descriptor(<usb.backend.libusb1._Device object at 0x02A2A650>, 0, 0, 0, 0)
2019-01-11 10:35:06,957 DEBUG:usb.backend.libusb1:_LibUSB.get_interface_descriptor(<usb.backend.libusb1._Device object at 0x02A2A650>, 0, 0, 0)
2019-01-11 10:35:06,957 DEBUG:usb.backend.libusb1:_LibUSB.get_configuration_descriptor(<usb.backend.libusb1._Device object at 0x02A2A650>, 0)
2019-01-11 10:35:06,957 DEBUG:usb.backend.libusb1:_LibUSB.claim_interface(<usb.backend.libusb1._DeviceHandle object at 0x02A2A610>, 0)
2019-01-11 10:35:06,957 DEBUG:usb.backend.libusb1:_LibUSB.intr_read(<usb.backend.libusb1._DeviceHandle object at 0x02A2A610>, 131, 0, array('B', [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), 1000)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\usb\core.py", line 988, in read
self.__get_timeout(timeout))
File "C:\Python27\lib\site-packages\usb\_debug.py", line 60, in do_trace
return f(*args, **named_args)
File "C:\Python27\lib\site-packages\usb\backend\libusb1.py", line 851, in intr_read
timeout)
File "C:\Python27\lib\site-packages\usb\backend\libusb1.py", line 936, in __read
_check(retval)
File "C:\Python27\lib\site-packages\usb\backend\libusb1.py", line 595, in _check
raise USBError(_strerror(ret), ret, _libusb_errno[ret])
usb.core.USBError: [Errno 10060] Operation timed out
>>>