USB Device command line restart?


Recommended Posts

Is there a command that I can ssh into Unraid and execute to have it be the equivalent of unplugging and reinserting a USB Device?  

I am passing a USB zigbee coordinator cc2531 to my zigbee2mqtt docker.... everything works fine, however when the docker updates it does not start.  When I am home this is no big deal as I just unplug then replug the USB dongle then start the docker container....however sometimes I am away so I would love a command line way to do this.

 

Thanks,

Dan

  • Like 1
Link to comment
  • 7 months later...
  • 8 months later...
On 4/18/2020 at 10:34 AM, Squid said:

Google is your friend

 

https://unix.stackexchange.com/questions/7412/how-to-reconnect-a-logically-disconnected-usb-device

 

But, you would have to be very careful to not detach the boot flash drive, as then you'll run into other problems.

I followed the instructions here which works well via command line.

 

The usbfs interaction seems to have changed a number of times since this question was originally answered. So, here's how I cycle hub port power on Ubuntu Oneiric Ocelot from a Bash shell.

Search for the bus and device number:

sudo lsusb -v|less
Locate the device in the bus / hub port hierarchy using the bus and device number:

sudo lsusb -t|less
The syntax seems to be 'bus-port.port.port.port.port...' For example, my mouse is connected to an external hub which connects to my computer's hub which internally connects to a root hub:

/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=ehci_hcd/2p, 480M
    |__ Port 1: Dev 2, If 0, Class=hub, Driver=hub/6p, 480M
        |__ Port 1: Dev 3, If 0, Class=hub, Driver=hub/3p, 480M
            |__ Port 1: Dev 6, If 0, Class=HID, Driver=usbhid, 1.5M
So, '2-1.1.1' in the above case. Finally, cycle the port power:

echo '2-1.1.1'|sudo tee /sys/bus/usb/drivers/usb/unbind
sleep 1
echo '2-1.1.1'|sudo tee /sys/bus/usb/drivers/usb/bind

Is there a way to automate this to execute at reboot (or at restart of VM, or restart of OZWDaemon docker)?

Edited by Rick_Sanchez
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.