Saturday, May 4, 2024
 Popular · Latest · Hot · Upcoming
11
rated 0 times [  11] [ 0]  / answers: 1 / hits: 60510  / 3 Years ago, tue, june 8, 2021, 2:19:57

I need to write an script for restart USB dongles. I have all tools but I can't link my /dev/ttyUSBx to physical BUS and DEVICE. An issue is that I have three dongles with the same id vendor and id product.



If I do lsusb the output is:



Bus 001 Device 004: ID 12d1:1003 Huawei Technologies Co., Ltd. E220 HSDPA Modem / E270 HSDPA/HSUPA Modem
Bus 001 Device 006: ID 12d1:1003 Huawei Technologies Co., Ltd. E220 HSDPA Modem / E270 HSDPA/HSUPA Modem
Bus 001 Device 007: ID 12d1:1003 Huawei Technologies Co., Ltd. E220 HSDPA Modem / E270 HSDPA/HSUPA Modem
Bus 001 Device 002: ID 80ee:0021
Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub


And I have attached it to:



/dev/ttyUSB0
/dev/ttyUSB3
/dev/ttyUSB5


But I want to know which device is related with which Bus Device. By example I need to get the following:



/dev/ttyUSB0 -> Bus 001 Device 006
/dev/ttyUSB3 -> Bus 001 Device 004
/dev/ttyUSB5 -> Bus 001 Device 007


I'm using Ubuntu Server 10.04 and I tested the tools:



lsusb
hal
lsmod


But I can't get the relationship.


More From » server

 Answers
4

Since I don't have your hardware I can't give you an exact answer.



I'd suggest that you go to the device in question, for example:



ls -l /dev/ttyUSB0


and obtain the major and minor node numbers. Let's say they are 116, 7



Then go to:



ls -l /sys/dev/char/116:7


(char, because a tty is a character device, if you were tracing down a disk device you would specify block instead of char)



In the output from the command you will see something a little like:



lrwxrwxrwx 1 root root 0 Sep 6 00:17 116:7 -> ../../devices//sys/devices/pci0000:00/0000:00:13.5/pci0000:00/0000:00:13.5/usb1/1-3/1-3:1.1/sound/card1/pcmC1D0c



The directory /sys/devices/pci0000:00/0000:00:13.5/usb1/1-3/ and its subdirectories have much information on the device. As an example, /sys/devices/pci0000:00/0000:00:13.5/usb1/1-3/busnum and /sys/devices/pci0000:00/0000:00:13.5/usb1/1-3/devnum. On my system these match the bus and device number mentioned in the device hotplug entries in /var/log/syslog.



Something else that works on my system for /dev/video0:



find /sys/dev -lname '*video0' -exec cat {}/device/busnum {}/device/devnum ; 2>/dev/null

[#35729] Wednesday, June 9, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
fulpu

Total Points: 116
Total Questions: 118
Total Answers: 104

Location: Solomon Islands
Member since Fri, Oct 8, 2021
3 Years ago
fulpu questions
Fri, Apr 1, 22, 08:36, 2 Years ago
Wed, Mar 16, 22, 15:25, 2 Years ago
Wed, Aug 24, 22, 22:59, 2 Years ago
Tue, Dec 20, 22, 22:33, 1 Year ago
;