usb-resetter


Nameusb-resetter JSON
Version 1.3.0 PyPI version JSON
download
home_pagehttps://github.com/netinvent/udev_monitor
Summarysmall tool to reset USB controllers, hubs or devices
upload_time2023-03-30 18:25:36
maintainer
docs_urlNone
authorNetInvent - Orsiris de Jong
requires_python>=3.6
licenseBSD
keywords shell usb reset hub controller plug and pray
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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:

1. Buy a robot hand that unplugs / plugs the device :) - Nice solution but costly... But again, very nice...
2. Reset the USB device (works sometimes)
3. Reset the USB hub where the device is plugged in (is generally sufficient)
4. Reset all USB controllers (a bit broad, but works miracles on reluctant devices)
5. 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.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/netinvent/udev_monitor",
    "name": "usb-resetter",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "shell,usb,reset,hub,controller,plug and pray",
    "author": "NetInvent - Orsiris de Jong",
    "author_email": "contact@netinvent.fr",
    "download_url": "https://files.pythonhosted.org/packages/56/85/e3d4da0fb28150c277a07925eb27c291c474ef9652d32120f2422948f9c4/usb_resetter-1.3.0.tar.gz",
    "platform": null,
    "description": "# usb_resetter\r\nsmall tool to reset USB controllers, hubs or devices\r\n\r\n## So here we are, with sh*TTY built usb devices, that don't work properly.\r\n\r\nI've had numerous problems with USB devices that simply don't work unless you disconnect / reconnect them.\r\nWhile I'd probably like to throw away those devices, sometimes there's no choice than the rejoice of using those devices.\r\n\r\nA couple solutions:\r\n\r\n1. Buy a robot hand that unplugs / plugs the device :) - Nice solution but costly... But again, very nice...\r\n2. Reset the USB device (works sometimes)\r\n3. Reset the USB hub where the device is plugged in (is generally sufficient)\r\n4. Reset all USB controllers (a bit broad, but works miracles on reluctant devices)\r\n5. Burn the device and promise to buy better hardware (also very nice solution)\r\n\r\nI've scripted solutions 2 to 4 in order to achieve what I need into a Python script.\r\n\r\n## Setup\r\n\r\nGrab yourself a copy of `usb_resetter` via pypi with `pip install usb_resetter` or download via\r\n\r\n```\r\ncurl -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\r\n```\r\n\r\n## Usage\r\n\r\n### List all USB devices\r\n```\r\nusb_resetter -l\r\n```\r\nResult\r\n```\r\nFound 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\r\nFound device 0665:5161 at /dev/bus/usb/001/002 Manufacturer=INNO TECH, Product=USB to Serial\r\nFound 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\r\nFound device 1199:9071 at /dev/bus/usb/002/002 Manufacturer=Sierra Wireless, Incorporated, Product=EM7455\r\n```\r\n\r\n\r\n### Reset a reluctant USB device\r\n\r\n```\r\nusb_resetter -d [vendor_id]:[product_id] --reset-device\r\n```\r\nExample:\r\n```\r\nusb_resetter -d 1199:9071 --reset-device\r\n```\r\n\r\nResult:\r\n```\r\nResetting usb device /dev/bus/usb/002/002\r\n```\r\n\r\n### Reset the USB hub where a device is connected in\r\n```\r\nusb_resetter -d [vendor_id]:[product_id] --reset-hub\r\n```\r\nExample:\r\n```\r\nusb_resetter -d 1199:9071 --reset-hub\r\n```\r\n\r\nResult:\r\n```\r\nunbind hub /sys/bus/usb/devices/2-4\r\nbind hub /sys/bus/usb/devices/2-4\r\n```\r\n\r\n\r\n### Reset the whole USB controller (usually makes reluctant devices work again)\r\n```\r\nusb_resetter --reset-all\r\n```\r\n\r\nResult\r\n``` \r\nunbind hub /sys/bus/pci/drivers/xhci_hcd/0000:00:14.0\r\nbind hub /sys/bus/pci/drivers/xhci_hcd/0000:00:14.0\r\n```\r\n\r\nAfterwards, 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.\r\n",
    "bugtrack_url": null,
    "license": "BSD",
    "summary": "small tool to reset USB controllers, hubs or devices",
    "version": "1.3.0",
    "split_keywords": [
        "shell",
        "usb",
        "reset",
        "hub",
        "controller",
        "plug and pray"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "dd73bd92cf63d46630afd322344894771e46710038ed2f85a437e76017d9751e",
                "md5": "fb67057df5417119fc8ca7bdd0c0a22b",
                "sha256": "47756e246d296c97095bad8ff040644df2676b70398acfb96122d6a59fd873ec"
            },
            "downloads": -1,
            "filename": "usb_resetter-1.3.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "fb67057df5417119fc8ca7bdd0c0a22b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 8250,
            "upload_time": "2023-03-30T18:25:34",
            "upload_time_iso_8601": "2023-03-30T18:25:34.613437Z",
            "url": "https://files.pythonhosted.org/packages/dd/73/bd92cf63d46630afd322344894771e46710038ed2f85a437e76017d9751e/usb_resetter-1.3.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5685e3d4da0fb28150c277a07925eb27c291c474ef9652d32120f2422948f9c4",
                "md5": "6eecf6b50857041eb665f1f532670369",
                "sha256": "33aa3ea0dafc129b677e7916219f10fde8225acc1ec0c3383d9b6910719dc07a"
            },
            "downloads": -1,
            "filename": "usb_resetter-1.3.0.tar.gz",
            "has_sig": false,
            "md5_digest": "6eecf6b50857041eb665f1f532670369",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 9477,
            "upload_time": "2023-03-30T18:25:36",
            "upload_time_iso_8601": "2023-03-30T18:25:36.437488Z",
            "url": "https://files.pythonhosted.org/packages/56/85/e3d4da0fb28150c277a07925eb27c291c474ef9652d32120f2422948f9c4/usb_resetter-1.3.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-03-30 18:25:36",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "netinvent",
    "github_project": "udev_monitor",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "usb-resetter"
}
        
Elapsed time: 0.10440s