reklama

Bash: jak získat ID USB zařízení

Petr V.

Bash: jak získat ID USB zařízení
« kdy: 12. 02. 2016, 18:01:58 »
dobry den,
potrebuji v bash skriptu ziskat ID mysi pripojene pres USB..

Kód: [Vybrat]
lsusb
Bus 002 Device 012: ID 2109:0812 
Bus 002 Device 013: ID 045e:077b Microsoft Corp.    <<<  tady je ta mys
Bus 002 Device 005: ID 046d:c31d Logitech, Inc. Media Keyboard K200
....


lsusb -t
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/2p, 480M
    |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/8p, 480M
        |__ Port 4: Dev 3, If 0, Class=Hub, Driver=hub/7p, 480M
            |__ Port 1: Dev 4, If 0, Class=Hub, Driver=hub/3p, 480M
                |__ Port 1: Dev 8, If 0, Class=Printer, Driver=usblp, 12M
                |__ Port 2: Dev 9, If 0, Class=Vendor Specific Class, Driver=pl2303, 12M
                |__ Port 3: Dev 10, If 0, Class=Audio, Driver=snd-usb-audio, 12M
                |__ Port 3: Dev 10, If 1, Class=Audio, Driver=snd-usb-audio, 12M
                |__ Port 3: Dev 10, If 2, Class=Audio, Driver=snd-usb-audio, 12M
                |__ Port 3: Dev 10, If 3, Class=Human Interface Device, Driver=usbhid, 12M
            |__ Port 2: Dev 5, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M
            |__ Port 2: Dev 5, If 1, Class=Human Interface Device, Driver=usbhid, 1.5M
            |__ Port 3: Dev 13, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M     <<< tady je ta mys
            |__ Port 4: Dev 12, If 0, Class=Hub, Driver=hub/4p, 480M
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/2p, 480M
...

vysledkem by melo byt  '2-1.4.3'
muzete mi prosim poradit jak se k tomu jednoduse dostat?
dekuji. P.
« Poslední změna: 15. 02. 2016, 10:26:11 od Petr Krčmář »

reklama


jose

Re:bash: jak ziskat ID USB zarizeni
« Odpověď #1 kdy: 12. 02. 2016, 18:58:26 »
mozno by som skusil parsovat nieco viac script-friendly. aky vystup da

udevadm info -q all -a -n /dev/input/mouse* ?

robotron

Re:bash: jak ziskat ID USB zarizeni
« Odpověď #2 kdy: 12. 02. 2016, 19:03:35 »
grep -r nebo find v /sys/bus/usb

fedorac

Re:bash: jak ziskat ID USB zarizeni
« Odpověď #3 kdy: 12. 02. 2016, 20:26:33 »
co tohle ?

# usb-devices

T:  Bus=01 Lev=01 Prnt=01 Port=02 Cnt=01 Dev#=  2 Spd=12  MxCh= 0
D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=32 #Cfgs=  1
P:  Vendor=046d ProdID=c52b Rev=24.01
S:  Manufacturer=Logitech
S:  Product=USB Receiver
C:  #Ifs= 3 Cfg#= 1 Atr=a0 MxPwr=98mA
I:  If#= 0 Alt= 0 #EPs= 1 Cls=03(HID  ) Sub=01 Prot=01 Driver=usbhid
I:  If#= 1 Alt= 0 #EPs= 1 Cls=03(HID  ) Sub=01 Prot=02 Driver=usbhid
I:  If#= 2 Alt= 0 #EPs= 1 Cls=03(HID  ) Sub=00 Prot=00 Driver=usbhid

T:  Bus=01 Lev=01 Prnt=01 Port=08 Cnt=02 Dev#=  3 Spd=12  MxCh= 0
D:  Ver= 1.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs=  1
P:  Vendor=062a ProdID=4101 Rev=03.12
S:  Manufacturer=MOSART Semi.
S:  Product=2.4G Keyboard Mouse
C:  #Ifs= 2 Cfg#= 1 Atr=a0 MxPwr=100mA
I:  If#= 0 Alt= 0 #EPs= 1 Cls=03(HID  ) Sub=01 Prot=01 Driver=usbhid
I:  If#= 1 Alt= 0 #EPs= 1 Cls=03(HID  ) Sub=01 Prot=02 Driver=usbhid

T:  Bus=02 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#=  1 Spd=5000 MxCh=10
D:  Ver= 3.00 Cls=09(hub  ) Sub=00 Prot=03 MxPS= 9 #Cfgs=  1
P:  Vendor=1d6b ProdID=0003 Rev=04.03
S:  Manufacturer=Linux 4.3.4-200.fc22.x86_64 xhci-hcd
S:  Product=xHCI Host Controller
S:  SerialNumber=0000:00:14.0
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

...
...

ByCzech

Re:bash: jak ziskat ID USB zarizeni
« Odpověď #4 kdy: 12. 02. 2016, 20:54:37 »
lsusb -n


 

reklama