Chapter 3. Using Linux USB

Table of Contents
Reading the Linux USB Device Filesystem output
Configuring extra keys on USB keyboards
Communicating with the Handspring Visor
Communicating with the Diamond Rio 500
Using a USB Scanner

Reading the Linux USB Device Filesystem output

The USB device filesystem is a dynamically generated filesystem that complements the normal device node system, and can be used to write user space device drivers. Writing of user space device drivers is covered in the programmer's section of this guide. In addition to the device nodes, there are two files that are also generated - the drivers and devices files. If you followed the instructions in the installation chapter, you should find them as /proc/bus/usb/drivers and /proc/bus/usb/device respectively. If the /proc/bus/usb directory is empty, you have not mounted the filesystem, or you have mounted it in the wrong location.

/proc/bus/usb/drivers just lists the currently registered drivers (even if the driver is not being used by any device). This is most useful when testing module installation, and checking for USB support in an unknown kernel. Here is an example of its use:

[bradh@rachel bradh]$ more /proc/bus/usb/drivers
hid
ov511
cpia
printer
hub

/proc/bus/usb/devices lists information about the devices currently attached to the USB bus. This is very useful when trying to figure out if the device is correctly enumerated. Here is an example of its use, showing the root hub, a hub, a mouse and a camera:

T:  Bus=00 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#=  1 Spd=12  MxCh= 2
B:  Alloc= 28/900 us ( 3%), #Int=  2, #Iso=  0
D:  Ver= 1.00 Cls=09(hub  ) Sub=00 Prot=00 MxPS= 8 #Cfgs=  1
P:  Vendor=0000 ProdID=0000 Rev= 0.00
C:* #Ifs= 1 Cfg#= 1 Atr=40 MxPwr=  0mA
I:  If#= 0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub
E:  Ad=81(I) Atr=03(Int.) MxPS=   8 Ivl=255ms
T:  Bus=00 Lev=01 Prnt=01 Port=01 Cnt=01 Dev#=  2 Spd=12  MxCh= 4
D:  Ver= 1.00 Cls=09(hub  ) Sub=00 Prot=00 MxPS= 8 #Cfgs=  1
P:  Vendor=0451 ProdID=1446 Rev= 1.00
C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=100mA
I:  If#= 0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub
E:  Ad=81(I) Atr=03(Int.) MxPS=   1 Ivl=255ms
T:  Bus=00 Lev=02 Prnt=02 Port=00 Cnt=01 Dev#=  3 Spd=12  MxCh= 0
D:  Ver= 1.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs=  1
P:  Vendor=0553 ProdID=0002 Rev= 1.00
C:* #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=400mA
I:  If#= 1 Alt= 0 #EPs= 1 Cls=ff(vend.) Sub=00 Prot=ff Driver=cpia
E:  Ad=81(I) Atr=01(Isoc) MxPS=   0 Ivl=  1ms
I:  If#= 1 Alt= 1 #EPs= 1 Cls=ff(vend.) Sub=00 Prot=ff Driver=cpia
E:  Ad=81(I) Atr=01(Isoc) MxPS= 448 Ivl=  1ms
I:  If#= 1 Alt= 2 #EPs= 1 Cls=ff(vend.) Sub=00 Prot=ff Driver=cpia
E:  Ad=81(I) Atr=01(Isoc) MxPS= 704 Ivl=  1ms
I:  If#= 1 Alt= 3 #EPs= 1 Cls=ff(vend.) Sub=00 Prot=ff Driver=cpia
E:  Ad=81(I) Atr=01(Isoc) MxPS= 960 Ivl=  1ms
T:  Bus=00 Lev=02 Prnt=02 Port=02 Cnt=02 Dev#=  5 Spd=1.5 MxCh= 0
D:  Ver= 1.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs=  1
P:  Vendor=046d ProdID=c001 Rev= 1.10
S:  Manufacturer=Logitech
S:  Product=USB-PS/2 Mouse
C:* #Ifs= 1 Cfg#= 1 Atr=a0 MxPwr= 50mA
I:  If#= 0 Alt= 0 #EPs= 1 Cls=03(HID  ) Sub=01 Prot=02 Driver=hid
E:  Ad=81(I) Atr=03(Int.) MxPS=   8 Ivl= 10ms

The information in the /proc/bus/usb/devices output is arranged in groups:

Refer to linux/Documentation/usb/proc_usb_info.txt for more information on using the USB device filesystem information.