2

I have an USB device that sometimes hangs. Since it is really a pain to unplug/plug it (cables under desk, behind things...), is there a way to virtually unplug/plug the device ? For example by shutting down its power then bring it back again ?

Thanks

2 Answers 2

3

Try with the USBDEVFS_RESET ioctl.

If your system doesn't come with a usbreset utility as part of usbutils, you can compile the one from https://github.com/gregkh/usbutils/blob/master/usbreset.c with just cc usbreset.c -o usbreset.

On some devices (like my router) you'll have to reset the hub it's connected to instead of the device for it to have effect.

# ./usbreset
Usage:
  usbreset PPPP:VVVV - reset by product and vendor id
  usbreset BBB/DDD   - reset by bus and device number
  usbreset "Product" - reset by product name

Devices:
  Number 001/004  ID 062a:4101  2.4G Keyboard Mouse
  Number 001/006  ID 03f0:e111  DeskJet 2130 series
  Number 001/002  ID 05e3:0608  USB2.0 Hub
  Number 001/005  ID 248a:8514  Wireless Receiver
  Number 001/003  ID 05e3:0608  USB2.0 Hub
$ ./a.out 062a:4101
0

The accepted USBDEVFS_RESET solution is not as good as replugging (based on the kernel messages). Better use the "port" interface, e.g.:

echo 1 > /sys/bus/usb/devices/3-2.1/port/disable

See more on this on my other answer.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.