diff --git a/doc/usb_adapters/dump.sh b/doc/usb_adapters/dump.sh index 1ecfb40f08..557ef7f4c9 100755 --- a/doc/usb_adapters/dump.sh +++ b/doc/usb_adapters/dump.sh @@ -1,6 +1,22 @@ #!/bin/sh # SPDX-License-Identifier: GPL-2.0-or-later +hid_unavailable_report() { + a=$(echo $1 | tr '[:lower:]' '[:upper:]') + b=$(basename $(dirname $(ls -d /sys/bus/usb/drivers/usbhid/*/*:$a.*))) + + echo "" + echo "ATTENTION!" + echo "Unable to read completely the USB descriptors." + echo "Please run the following command(s) and then run this script again" + for i in $b; do + echo " sudo sh -c \"echo -n $i > /sys/bus/usb/drivers/usbhid/unbind\"" + done + echo "" + echo "Please notice that the USB device will not function after the above" + echo "operations; you should unplug and replug it to get it working again." +} + devs=$(lsusb -d $1:$2 | wc -l) case "$devs" in 0 ) @@ -22,3 +38,5 @@ echo '' echo '# Optional comment' lsusb -v -d $1:$2 | sed 's/ *$//' + +lsusb -v -d $1:$2 2>&1 | grep -Fq '** UNAVAILABLE **' && (hid_unavailable_report $1:$2 > /dev/stderr)