-
Notifications
You must be signed in to change notification settings - Fork 671
question: reset device #358
Copy link
Copy link
Closed
Labels
Description
Hello,
I'm having trouble with an USB device and I don't know if I'm doing the correct sequence to reset it.
At some point during the operation we get a read timeout; the cleanup code call dispose
if self.device is not None:
self.device.reset()
usb.util.dispose_resources(self.device)Next the device is created again, searching it by the serial number
# first loop to reset the device
for device in usb.core.find(find_all=True):
try:
if device.serial_number.strip().strip('\0').lower() == self.serial_number.lower():
device.reset()
usb.util.dispose_resources(device)
break
else:
print(device.serial_number.strip().strip('\0').lower(), self.serial_number.lower())
except:
continue
else:
raise Exception("Device with serial {} not found".format(self.serial_number))
# second loop to keep the handle
for device in usb.core.find(find_all=True):
try:
if device.serial_number.strip().strip('\0').lower() == self.serial_number.lower():
self.device = device
break
else:
print(device.serial_number.strip().strip('\0').lower(), self.serial_number.lower())
except:
continue
else:
raise Exception("Device with serial {} not found".format(self.serial_number))The init code works and we get the device handle, but any further write attempts end up in a protocol timeout with this traceback:
File "lib\site-packages\pyxcp\master\errorhandler.py", line 398, in inner
File "lib\site-packages\pyxcp\master\base.py", line 174, in connect
File "lib\site-packages\pyxcp\transport\base.py", line 153, in request
File "lib\site-packages\pyxcp\transport\usb_transport.py", line 147, in send
File "lib\site-packages\usb\core.py", line 408, in write
File "lib\site-packages\usb\core.py", line 984, in write
File "lib\site-packages\usb\backend\libusb1.py", line 842, in bulk_write
File "lib\site-packages\usb\backend\libusb1.py", line 938, in __write
File "lib\site-packages\usb\backend\libusb1.py", line 602, in _check
usb.core.USBTimeoutError: [Errno 10060] Operation timed out
Do you have any suggestion about what I could try?
Thank you!
Edit
- pyusb version 1.1.1
- python 3.7.9 x64
- windows 10 x64
- libusb 1.0.24
Reactions are currently unavailable
