admin管理员组文章数量:1401298
I am trying to read the data from my electronic board using Python. I am using the Libusb library on VSCode platform in order to do that on Windows. However, I am getting an error related to the timeout.
I don't know how to solve it. Anyone would have an idea why this is happening? Should I download another librarry into the Python environment? The following is my code:
import usb.backend.libusb1, os, usb.core, numpy as np
# Needed variables for the sensor:
VENDOR_ID = 0x04d8
PRODUCT_ID = 0xf2a6
INTERFACE = 0
CONFIGURATION = 0
ENDPOINT_IN = 0
ENDPOINT_OUT = 1
INTEGRATION_TIMES = {"1ms": 0x00, "2ms": 0x01, "4ms": 0x02, "8ms": 0x03, "16ms": 0x04, "32ms": 0x05,
"64ms": 0x06, "128ms": 0x07, "256ms": 0x08, "512ms": 0x09, "1024ms": 0x0A}
REFERENCE_CURRENTS = {"20nA": 0x80, "80nA": 0x90,
"320nA": 0xA0, "1280nA": 0xB0, "5120nA": 0xC0}
def openPixelSensor():
"""
Prepare USB libraries, locate Coher Sense KISA device, initialize device
"""
cwd = os.getcwd()
libpath = cwd + "\\libusb-1.0.dll"
backend = usb.backend.libusb1.get_backend(find_library=lambda x: libpath)
activeDev = usb.core.find(idVendor=VENDOR_ID, idProduct=PRODUCT_ID)
# If device was found do platform specific configuration
if activeDev is not None:
configuration = activeDev.get_active_configuration()
interface = configuration[(INTERFACE, CONFIGURATION)]
endpointIn = interface[ENDPOINT_IN]
endpointOut = interface[ENDPOINT_OUT]
return activeDev, endpointIn, endpointOut
else:
return None
def getReadings(pixelsensor):
"""
Get the 8 sensor values from Coher Sense KISA device
"""
data = pixelsensor[0].read(endpoint=pixelsensor[1].bEndpointAddress,
size_or_buffer= pixelsensor[1].wMaxPacketSize, timeout=1000
)
values = []
for i in range(0, 8):
values.append(int.from_bytes(
data[(4+2*i):(6+2*i)], byteorder='little'))
print(values)
return values
result = openPixelSensor()
getReadings(result)
The error is the following:
raise USBTimeoutError(_strerror(ret), ret, _libusb_errno[ret])
usb.core.USBTimeoutError: [Errno 10060] Operation timed out
本文标签: visual studio codeGetting TIMEOUT ERROR using Libusb in PythonStack Overflow
版权声明:本文标题:visual studio code - Getting TIMEOUT ERROR using Libusb in Python - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744247736a2597102.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论