linux - Determine USB device file Path -
how can usb device file path correctly in linux. used command: find / -iname "usb" , got result below:
/dev/bus/usb /sys/bus/usb /sys/bus/usb/drivers/usb /sys/kernel/debug/usb
under /dev/bus/usb see:
001 002 003 004 005 006
but think aren't files need.
under /sys/bus/usb/devices/:
sh-3.2# ls /sys/bus/usb/devices/ 1-0:1.0 1-1:1.0 3-0:1.0 5-0:1.0 usb1 usb3 usb5 1-1 2-0:1.0 4-0:1.0 6-0:1.0 usb2 usb4 usb6
and under /sys/bus/scsi/devices/ when pluged usb see:
2:0:0:0 host0 host2 target2:0:0
and when removed usb see:
sh-3.2# ls host0
so device file used usb? how can indentify it? need make c program usb device file...
further more, explain me number 1-1:1.0? mean?
thank you.
so device file used usb? how can indentify it?
what see behind /sys/
configuration/information devices. /dev/bus/usb
looking for. think following article can you
http://www.linuxjournal.com/article/7466?page=0,0
is quite old, still can you. (in article speak /proc/bus/usb
, today have /dev/bus/usb
)
further more, explain me number 1-1:1.0? mean?
the generic form is
x-y.z:a.b
each field identify connection point of device. first 2 field mandatory:
- x usb bus of motherboard connected usb system.
- y port in use on bus system
so usb device identified string 3-3
device connected on port 3 of bus 3.
if connect usb hub, extending connection capability of single usb port. linux kernel identify situation appending z field.
- z port use on hub
so, usb device identified string 1-2.5
device connected on port 5 of hub connected on port 2 of bus 1.
usb specification allow connect in cascade more 1 usb hub, linux kernel continue append port in use on different hubs. so, usb device identified string 1-2.1.1
device connected on port 1 of hub connected on port 1 of hub connected port 2 of bus 1.
a fast way retrieve these information read kernel messages (if can).
$ dmesg | grep usb [... snip ...] [ 2.047950] usb 4-1: new full-speed usb device number 2 using ohci_hcd [ 2.202628] usb 4-1: new usb device found, idvendor=046d, idproduct=c318 [ 2.202638] usb 4-1: new usb device strings: mfr=1, product=2, serialnumber=0 [ 2.202643] usb 4-1: product: logitech illuminated keyboard [ 2.202648] usb 4-1: manufacturer: logitech [... snip ...]
then, last 2 fields of pattern (after colon) identify internal section of usb device :
- a configuration number of device
- b interface number of configuration
so, string 4-1:1.1
means: interface 1, on configuration 1 connected on port 1 of bus 4.
you can retrieve these information command lsusb
.
Comments
Post a Comment