Hi, The lsusb documentation (lsusb.8) says:
-s [[bus]:][devnum] Show only devices in specified bus and/or devnum. Both ID's are given in hexadecimal and may be omitted. Even though the documentation says "Both ID's are given in hexadecimal", that's not really true. lsusb parses the arguments like this: devnum = strtoul(cp, NULL, 0); So strtoul() will interpret the argument as decimal, unless it begins with at '0' (octal) or '0x' (hex). So if someone mouses a device number such as '010' from the output of a previous lsusb, it will be interpreted as 8 (octal), not 10 (and not 16, as documented!). To make this worse, I've seen where at least one linux distribution has added their own patch to usbutils to make lsusb work as documented (interpret all -s bus and dev IDs as hex numbers). So why should the bus and devnum be given in hex to begin with? The vendor and product IDs (-d option) must also be given in hex, but since lsusb displays them in hex (and the usb.ids file lists them in hex), it makes sense for -d. idVendor 0x0430 Sun Microsystems, Inc. idProduct 0x0100 3-button Mouse But it doesn't seem to make sense for -s. The /proc entries are decimal numbers, and lsusb displays them in decimal, so what reason is there for anyone to want to supply them in hex? To be consistent the option arguments to the -s option should be decimal numbers. As it is, I think it's very confusing. I realize this is a pretty trivial issue that few people will care about, but I hope you will consider it anyway. I've attached a patch for your consideration that changes lsusb to interpret the -s option argument as a decimal number. Thank you, Tony Ernst
--- usbutils/lsusb.c 2005-05-13 13:38:55.089982379 -0500 +++ usbutils/lsusb.c 2005-05-13 13:42:49.111462344 -0500 @@ -2014,12 +2014,12 @@ if (cp) { *cp++ = 0; if (*optarg) - bus = strtoul(optarg, NULL, 0); + bus = strtoul(optarg, NULL, 10); if (*cp) - devnum = strtoul(cp, NULL, 0); + devnum = strtoul(cp, NULL, 10); } else { if (*optarg) - devnum = strtoul(optarg, NULL, 0); + devnum = strtoul(optarg, NULL, 10); } break; --- usbutils/lsusb.8 2005-05-13 13:48:48.519908884 -0500 +++ usbutils/lsusb.8 2005-05-13 13:49:06.697459266 -0500 @@ -32,7 +32,7 @@ .I bus and/or .I devnum. -Both ID's are given in hexadecimal and may be omitted. +Both ID's are given in decimal and may be omitted. .TP \fB\-d\fP [\fIvendor\fP]\fB:\fP[\fIproduct\fP] Show only devices with the specified vendor and product ID.