3

On gentoo I have 10 USB modems and every of them has 3 interfaces /dev/ttyUSB0, 1, 2 and so on for each modem. Sometimes their positions can change, so it is very difficult to work with them.

I'm working with each modem first interface. So for first modem it would be ttyUSB0, other ttyUSB1 and ttyUSB2 I don't need for sending commands to modem.

How can I write static udev rules for each of them so they would have fixed position, and how could I rename ttyUSB0 in something like modem-xxxxxxx interface for easier working with them ?

lsusb output:

client dev # lsusb
Bus 002 Device 039: ID 12d1:1001 Huawei Technologies Co., Ltd. E169/E620/E800 HSDPA Modem

dmesg output for one of the huawei modems:

[166041.393547] usb 2-6: default language 0x0409
[166041.402548] usb 2-6: udev 40, busnum 2, minor = 167
[166041.402552] usb 2-6: New USB device found, idVendor=12d1, idProduct=1001
[166041.402555] usb 2-6: New USB device strings: Mfr=1, Product=2, SerialNumber=1
[166041.402558] usb 2-6: Product: HUAWEI Mobile
[166041.402660] usb 2-6: usb_probe_device
[166041.402664] usb 2-6: configuration #1 chosen from 1 choice
[166041.405566] usb 2-6: adding 2-6:1.0 (config #1, interface 0)
[166041.408589] option 2-6:1.0: usb_probe_interface
[166041.408593] option 2-6:1.0: usb_probe_interface - got id
[166041.408600] option 2-6:1.0: GSM modem (1-port) converter detected
[166041.408803] usb 2-6: GSM modem (1-port) converter now attached to ttyUSB0
[166041.408835] usb 2-6: adding 2-6:1.1 (config #1, interface 1)
[166041.411572] option 2-6:1.1: usb_probe_interface
[166041.411576] option 2-6:1.1: usb_probe_interface - got id
[166041.411581] option 2-6:1.1: GSM modem (1-port) converter detected
[166041.411683] usb 2-6: GSM modem (1-port) converter now attached to ttyUSB1
[166041.411703] usb 2-6: adding 2-6:1.2 (config #1, interface 2)
[166041.414572] option 2-6:1.2: usb_probe_interface
[166041.414576] option 2-6:1.2: usb_probe_interface - got id
[166041.414580] option 2-6:1.2: GSM modem (1-port) converter detected
[166041.414682] usb 2-6: GSM modem (1-port) converter now attached to ttyUSB2
[166041.414714] hub 2-0:1.0: state 7 ports 10 chg 0000 evt 0040

Tried to find port addresses like this:

client rules.d # udevadm info -q path -n /dev/ttyUSB0
/devices/pci0000:00/0000:00:02.0/usb2/2-6/2-6:1.0/ttyUSB0/tty/ttyUSB0

then created file /etc/udev/rules.d/10-local.rules and wrote there lines like this:

KERNEL=="ttyUSB*", KERNELS=="2-6:1.0", NAME="ttyUSB0_654"
KERNEL=="ttyUSB*", KERNELS=="2-6:1.1", NAME="ttyUSB1_654"
KERNEL=="ttyUSB*", KERNELS=="2-6:1.2", NAME="ttyUSB2_654"

but looks like it's not working.

  • The output of udevadm info -q all -n /dev/ttyUSB0 would be useful, to see what you can filter on. – derobert Mar 20 '13 at 20:07
  • Your requested output is here: pastebin.com/vWSCdbNB – user991 Mar 20 '13 at 20:08
  • According to your pastebin, you already have a /dev/serial/by-path/pci-0000:00:02.0-usb-0:5:1.0-port0 ... does that work for you? – derobert Mar 20 '13 at 20:10
  • At this moment I pluged in one modem into box, for easier debugging. It's position is /dev/ttyUSB0, /dev/ttyUSB1 and /dev/ttyUSB2, if i will plug another 9 modems their poisitions could change. But i need to pshisicaly tell linux what modem would be mapped for ttyUSBX port. – user991 Mar 20 '13 at 20:13
2

After some discussion in chat it appears that that symlinks already exist in /dev/serial/by-path/ and will work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.