LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Debian (https://www.linuxquestions.org/questions/debian-26/)
-   -   Naming problem with udev (https://www.linuxquestions.org/questions/debian-26/naming-problem-with-udev-933025/)

zkab 03-06-2012 08:56 AM

Naming problem with udev
 
I am trying to link symbolic names to 2 USB devices with udev as follows:

ad_teknik_reader -> /dev/ttyUSB0
smart_ups -> /dev/ttyUSB1

sudo udevadm info --name=/dev/ttyUSB0 --attribute-walk gives:

looking at parent device '/devices/pci0000:00/0000:00:1a.0/usb2/2-1/2-1.6/2-1.6:1.0/ttyUSB0':
KERNELS=="ttyUSB0"
SUBSYSTEMS=="usb-serial"
DRIVERS=="pl2303"
ATTRS{port_number}=="0"

sudo udevadm info --name=/dev/ttyUSB1 --attribute-walk gives:

looking at parent device '/devices/pci0000:00/0000:00:1a.0/usb2/2-1/2-1.5/2-1.5:1.0/ttyUSB1':
KERNELS=="ttyUSB1"
SUBSYSTEMS=="usb-serial"
DRIVERS=="ftdi_sio"
ATTRS{latency_timer}=="1"
ATTRS{port_number}=="0"

My /etc/udev/rules.d/10-udev.rules looks like:

KERNELS=="ttyUSB0" , SUBSYSTEMS=="usb-serial" , DRIVERS=="ftdi_sio" , SYMLINK+="ad_teknik_reader"
KERNELS=="ttyUSB1" , SUBSYSTEMS=="usb-serial" , DRIVERS=="pl2303" , SYMLINK+="smart_ups"

But I can't get it working.
Sometime I get it right like:

lrwxrwxrwx 1 root root 7 6 mar 15.08 /dev/ad_teknik_reader -> ttyUSB0

after reboot but very often I just get /dev/ad_teknik_reader not pointing at ttyUSB0.

When I delete /dev/ad_teknik_reader and reboot I can get it right but not always ... it is frustrating to reboot since it is also a server.
I have Debian 2.6.32-5-amd64 (server).

catkin 03-07-2012 11:43 PM

Strange that it should not behave the same way on every reboot. Is there a pattern to that, like it's OK every other reboot.

You could try changing SYMLINK+="ad_teknik_reader" to SYMLINK="ad_teknik_reader"

EDIT: can you avoid the need to reboot by using udevadm control --reload-rules and re-plugging the hardware or, for a more complete re-initialisation, run /etc/init.d/udev restart or whatever the equivalent is on your distro.

zkab 03-08-2012 03:25 AM

Thanks for your input.
I solved the problem, the rule should be like this:

KERNEL=="ttyUSB[0-1]" , SUBSYSTEMS=="usb-serial" , DRIVERS=="ftdi_sio" , NAME="ad_teknik_reader"
KERNEL=="ttyUSB[0-1]" , SUBSYSTEMS=="usb-serial" , DRIVERS=="pl2303" , NAME="smart_ups"

since /dev/ttyUSB0 and /dev/ttyUSB1 depend on where they are plugged in ...


All times are GMT -5. The time now is 02:39 AM.