USB Device File Definition Path

How can I get the file path of a USB device in Linux correctly. I used the command: find / -iname "usb" and got the result as shown below:

/dev/bus/usb
/sys/bus/usb
/sys/bus/usb/drivers/usb
/sys/kernel/debug/usb

In the / dev / bus / usb section, I see:

001  002  003  004  005  006

But I think that these are not the files that I need.

In the / sys / bus / usb / devices / section:

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 I plugged in the USB, I see:

2:0:0:0      host0        host2        target2:0:0

And when I removed the USB, I see:

sh-3.2# ls
host0

So which device file is used for USB? How can I identify it? I need to make program C with a USB device file ...

Further, could you explain to me the number 1-1: 1.0? What does it mean?

Thanks.

+10
source share
1 answer

, USB? ?

, /sys/, - / . /dev/bus/usb - , . ,

http://www.linuxjournal.com/article/7466?page=0,0

, . ( /proc/bus/usb, /dev/bus/usb)

, 1-1:1.0? ?

X-Y.Z:A.B

. :

  • X - USB- , USB.
  • Y - , .

, USB-, 3-3, , 3 3.

USB, USB-. Linux , Z.

  • Z -

, USB-, 1-2.5, , 5 , 2 1.

USB USB-, ​​Linux , . , USB-, 1-2.1.1, - , 1 , 1 , 2 1.

- ( ).

$ 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 ...]

( ) USB-:

  • A -
  • B -

, 4-1:1.1 : 1, 1, 1 4.

lsusb.

+14

Source: https://habr.com/ru/post/1611712/


All Articles