Re: Resetting a USB port in Debian 10
On Wed, 2022-05-18 at 17:22 -0500, Jason wrote:
> What is the best way to power cycle or reset a USB port?
The method I use, which I found described online is to unbind the
driver then re-bind it like...
echo "$ID" >/sys/bus/usb/drivers/usb/unbind
sleep 1
echo "$ID" >/sys/bus/usb/drivers/usb/bind
To find the device ID my bash script scans the USB serial numbers
looking for the one I'm interested in...
pushd /sys/bus/usb/drivers/usb >/dev/null
for f in **/serial
do
if [ "$(cat $f)" = MY_SERIAL_NUMBER ]; then
ID=${f%%/*}
fi
done
popd >/dev/null
if [ "$ID" = "" ]; then
echo "Can't find device"
exit 1
fi
There's no doubt better ways of doing the above, but it works for me.
(Looking at it now I'd get rid of the pushd/popd by using an extra
string splice operation and that use of ** probably needs something
doing to it to cope with spaces in paths)
--
Tixy
Reply to: