Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

USB Device Release

Tags:

python

pyusb

I am currently working on PyUSB. As I am new to USB, I don’t know, how can I do the following.

I have successfully connected to my USB Device hardware from Python PyUSB. In the code I required to reset the USB Device hardware. Which I did by sending a command to the hardware. Now after hardware reset, I want to release the current USB device from Python PyUSB. And then I want to connect again to the USB Device Hardware after it come back from reset.

Please let me know, how can I release the USB Device Connection and interfaces etc so that I can reconnect?

Thank you very much in advance.

like image 804
user977601 Avatar asked Jun 24 '26 07:06

user977601


2 Answers

my_device = usb.core.find(...)

...

# necessary to allow further claim_interface calls
#   (bulk read), generally not needed
usb.util.dispose_resources(my_device)
like image 73
Liviu Avatar answered Jun 25 '26 19:06

Liviu


#!/usr/bin/python
from usb.core import find as finddev
dev = finddev(idVendor=0x1234, idProduct=0x5678)
dev.reset()
like image 28
Jacek Krysztofik Avatar answered Jun 25 '26 19:06

Jacek Krysztofik