Wednesday, October 22, 2008

Check USB status in Linux

簡單介紹一下如何在Linux OS下查看USB的控制器與其它資訊,一個非常簡單的方法是透過lspci,如下所示:
[root@s1 ~]# lspci | grep -i usb
00:07.2 USB Controller: VIA Technologies, Inc. VT82xxxxx UHCI USB 1.1 Controller (rev 16)
00:07.3 USB Controller: VIA Technologies, Inc. VT82xxxxx UHCI USB 1.1 Controller (rev 16)

可以看出這台老PC只支援USB 1.x 
PS. USB 控制器:
-UHCI: USB 1.x Inetl/VIA mb
-OHCI: USB 1.x 非Intel/VIA mb
-EHCI: USB 2.0

另外一個包含非常多USB資訊的檔案:
[root@s1 ~]# cat /proc/bus/usb/devices 
T:  Bus=02 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#=  1 Spd=12  MxCh= 2
B:  Alloc=  0/900 us ( 0%), #Int=  0, #Iso=  0
D:  Ver= 1.10 Cls=09(hub  ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=0000 ProdID=0000 Rev= 2.06
S:  Manufacturer=Linux 2.6.18-53.el5 uhci_hcd
S:  Product=UHCI Host Controller
S:  SerialNumber=0000:00:07.3
C:* #Ifs= 1 Cfg#= 1 Atr=e0 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=   2 Ivl=255ms

T:  Bus=01 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#=  1 Spd=12  MxCh= 2
B:  Alloc=  0/900 us ( 0%), #Int=  0, #Iso=  0
D:  Ver= 1.10 Cls=09(hub  ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=0000 ProdID=0000 Rev= 2.06
S:  Manufacturer=Linux 2.6.18-53.el5 uhci_hcd
S:  Product=UHCI Host Controller
S:  SerialNumber=0000:00:07.2
C:* #Ifs= 1 Cfg#= 1 Atr=e0 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=   2 Ivl=255ms


3 comments:

jserv said...

用 lsusb 應該更方便,比方說:
$ lsusb
Bus 005 Device 001: ID 0000:0000
Bus 001 Device 001: ID 0000:0000
Bus 002 Device 001: ID 0000:0000
Bus 003 Device 001: ID 0000:0000
Bus 004 Device 002: ID 0483:2016 SGS Thomson Microelectronics Fingerprint Reader
Bus 004 Device 001: ID 0000:0000

用 "lsusb -v" 可看到更多資訊,注意,由於透過 libusb 來存取系統 USB 狀態,所以,要切換到 root

另外,新版的 Kernel 有個 usbfs (USB Device File System),可透過這機制,來作更深入的操作。

瘋狂帽客 said...

Thanks for your information, very helpful!

瘋狂帽客 said...

more info about usbfs:
http://www.linux-usb.org/USB-guide/x173.html