I'm trying to debug a USB issue on an Ubuntu 22.04. I've come across the usb-devices command. However I do not understand the output. I've read the man page, and it says:
The output of the script is similar to the usb/devices file available either under /proc/bus (if usbfs is mounted), or under /sys/kernel/debug (if debugfs is mounted there). The script is primarily intended to be used if the file is not available. In contrast to the usb/devices file, this script only lists active interfaces (those marked with a "*" in the usb/devices file) and their endpoints. Be advised that there can be differences in the way information is sorted, as well as in the format of the output.
However I am not able to find a clear guide on how to read the output of those files either. What follows is example output from a different machine:
T: Bus=01 Lev=01 Prnt=01 Port=03 Cnt=01 Dev#= 3 Spd=1.5 MxCh= 0
D: Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs= 1
P: Vendor=045e ProdID=082c Rev=01.00
S: Manufacturer=Microsoft
S: Product=Microsoft Ergonomic Keyboard
S: SerialNumber=601135501321
C: #Ifs= 2 Cfg#= 1 Atr=a0 MxPwr=100mA
I: If#= 0 Alt= 0 #EPs= 1 Cls=03(HID ) Sub=01 Prot=01 Driver=usbhid
E: Ad=81(I) Atr=03(Int.) MxPS= 8 Ivl=10ms
I: If#= 1 Alt= 0 #EPs= 1 Cls=03(HID ) Sub=00 Prot=00 Driver=usbhid
E: Ad=82(I) Atr=03(Int.) MxPS= 8 Ivl=10ms
How do I read this? What do the initials mean?
I can read the script itself, from vim $(which usb-devices), and that helps a little. For example, in the 1st line, It outputs:
T: Bus=01 Lev=01 Prnt=01 Port=03 Cnt=01 Dev#= 3 Spd=1.5 MxCh= 0
And in the code I can see that it refers comes from the line:
printf "\nT: Bus=%02i Lev=%02i Prnt=%02i Port=%02i Cnt=%02i Dev#=%3i Spd=%-3s MxCh=%2i\n" \
$busnum $level $parent $port $count $devnum $speed $maxchild
So from that I can see where $busnum and such come, but even then I don't see that the T in the beginning stands for.
/usr/binyou're welcome to read it and understand what it does. Maybe instead of reading its output you could adjust it for your needs. It's going to be a lot easier than parsing its output.