usb_resetter
small tool to reset USB controllers, hubs or devices
So here we are, with sh*TTY built usb devices, that don't work properly.
I've had numerous problems with USB devices that simply don't work unless you disconnect / reconnect them. While I'd probably like to throw away those devices, sometimes there's no choice than the rejoice of using those devices.
A couple solutions:
- Buy a robot hand that unplugs / plugs the device :) - Nice solution but costly... But again, very nice...
- Reset the USB device (works sometimes)
- Reset the USB hub where the device is plugged in (is generally sufficient)
- Reset all USB controllers (a bit broad, but works miracles on reluctant devices)
- Burn the device and promise to buy better hardware (also very nice solution)
I've scripted solutions 2 to 4 in order to achieve what I need into a Python script.
Setup
Grab yourself a copy of usb_resetter via pypi with pip install usb_resetter or download via
curl -o /usr/local/bin/usb_resetter -L https://raw.githubusercontent.com/netinvent/usb_resetter/main/usb_resetter/usb_resetter.py && chmod +x /usr/local/bin/usb_resetter
Usage
List all USB devices
usb_resetter -l
Result
Found device 1d6b:0002 at /dev/bus/usb/001/001 Manufacturer=Linux 5.14.0-70.26.1.el9_0.x86_64 xhci-hcd, Product=xHCI Host Controller
Found device 0665:5161 at /dev/bus/usb/001/002 Manufacturer=INNO TECH, Product=USB to Serial
Found device 1d6b:0003 at /dev/bus/usb/002/001 Manufacturer=Linux 5.14.0-70.26.1.el9_0.x86_64 xhci-hcd, Product=xHCI Host Controller
Found device 1199:9071 at /dev/bus/usb/002/002 Manufacturer=Sierra Wireless, Incorporated, Product=EM7455
Reset a reluctant USB device
usb_resetter -d [vendor_id]:[product_id] --reset-device
Example:
usb_resetter -d 1199:9071 --reset-device
Result:
Resetting usb device /dev/bus/usb/002/002
Reset the USB hub where a device is connected in
usb_resetter -d [vendor_id]:[product_id] --reset-hub
Example:
usb_resetter -d 1199:9071 --reset-hub
Result:
unbind hub /sys/bus/usb/devices/2-4
bind hub /sys/bus/usb/devices/2-4
Reset the whole USB controller (usually makes reluctant devices work again)
usb_resetter --reset-all
Result
unbind hub /sys/bus/pci/drivers/xhci_hcd/0000:00:14.0
bind hub /sys/bus/pci/drivers/xhci_hcd/0000:00:14.0
Afterwards, all your USB devices should work as if they were just plugged in, since this reset also temporarily cuts power from given USB device, making it reboot.
Metadata
Release files for usb-resetter 1.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| usb_resetter-1.3.0.tar.gz | 9.5 kB | Without provenance | Details for usb_resetter-1.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| usb_resetter-1.3.0-py3-none-any.whl | Python 3 | none | any | Details for usb_resetter-1.3.0-py3-none-any.whl |
Total release size: 17.7 kB
Release files / usb_resetter-1.3.0.tar.gz
| Download URL | usb_resetter-1.3.0.tar.gz |
|---|---|
| Size | 9.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
33aa3ea0dafc129b677e7916219f10fde8225acc1ec0c3383d9b6910719dc07a
|
|
BLAKE2b-256 checksum How to use checksums |
5685e3d4da0fb28150c277a07925eb27c291c474ef9652d32120f2422948f9c4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.1
|
Release files / usb_resetter-1.3.0-py3-none-any.whl
| Download URL | usb_resetter-1.3.0-py3-none-any.whl |
|---|---|
| Size | 8.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
47756e246d296c97095bad8ff040644df2676b70398acfb96122d6a59fd873ec
|
|
BLAKE2b-256 checksum How to use checksums |
dd73bd92cf63d46630afd322344894771e46710038ed2f85a437e76017d9751e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.1
|
Security for usb-resetter 1.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.