I have tested Bryan's suggestions (err tutorial) and here are my
observations.

Indeed, I get iSerials from my phone devices connected to my Ubuntu box:

r...@smsc:/etc/udev/rules.d# lsusb -v | grep iSerial
>   iSerial                 1 0000:00:13.1
>   iSerial                 0
>   iSerial                 1 0000:00:13.0
>   iSerial                 1 0000:00:13.2
>

However, I'm not sure which iSerial belongs to which phone (yeah yeah, an
instantiation of noobish regression). So I proceeded to the next option of
using the ID instead of ATTR parameter.

# /dev/ttyACM0,
> SUBSYSTEMS=="usb", ID=="3-2:1.1", KERNEL=="ttyACM[0123]",
> SYMLINK+="ttyACM0"
>
> # /dev/ttyACM1,
> SUBSYSTEMS=="usb", ID=="2-2:1.1", KERNEL=="ttyACM[0123]",
> SYMLINK+="ttyACM1"
>
> # /dev/ttyACM2,
> SUBSYSTEMS=="usb", ID=="3-1:1.1", KERNEL=="ttyACM[0123]",
> SYMLINK+="ttyACM2"
>

Stopped my Kannel (just in case), unplugged the devices, then restarted
UDEV.

I then proceeded in checking if indeed the devices get assigned the correct
symlink.

PLUGGED "ttyACM1" device without other devices plugged in :
>
> r...@smsc:/etc/udev/rules.d# dmesg | grep ttyACM
> [355247.366823] cdc_acm 2-2:1.1: ttyACM0: USB ACM device
>
> Removed "ttyACM1" device, and plugged "ttyACM2" device:
>
> r...@smsc:/etc/udev/rules.d# dmesg | grep ttyACM
> [355247.366823] cdc_acm 2-2:1.1: ttyACM0: USB ACM device
> [355317.549674] cdc_acm 3-1:1.1: ttyACM0: USB ACM device
>
> Removed "ttyACM2" device, and plugged "ttyACM0" device:
>
> r...@smsc:/etc/udev/rules.d# dmesg | grep ttyACM
> [355247.366823] cdc_acm 2-2:1.1: ttyACM0: USB ACM device
> [355317.549674] cdc_acm 3-1:1.1: ttyACM0: USB ACM device
> [355348.800105] cdc_acm 3-2:1.1: ttyACM0: USB ACM device
>

However, I noticed that if there are no other devices connected, the device
will be given ttyACM0 - regardless. But then again, Bryan is also right,
that the device will be able to receive the correct symlink regardless of
which USB port it is connected in. But I had to make sure that I connect the
devices in the _proper_ order!

I tested this out again by connecting the "ttyACM0" device to a
randomly-selected USB port, and yes, it got the correct symlink --
"ttyACM0". I proceeded in plugging the other devices in exact order but not
necessary which USB port they're connected in.

r...@smsc:/etc/udev/rules.d# dmesg | grep ttyACM
[355348.800105] cdc_acm 3-2:1.1: ttyACM0: USB ACM device
[355247.366823] cdc_acm 2-2:1.1: ttyACM1: USB ACM device
[355317.549674] cdc_acm 3-1:1.1: ttyACM2: USB ACM device

So far it works, but with just a little twist than what I originally
intended. Connecting the devices in exact order is just a minor nuisance.
Hope this will be useful to somebody.

(NOTE TO BRYAN:  Is it OK to publish your steps (unedited) into my blog as a
supplement to my test results? )

Best regards!



---------- Forwarded message ----------
From: Bryan Smith <[email protected]>
Date: Thu, Feb 12, 2009 at 8:10 PM
Subject: [lug:14112] Re: Permanently associate a device file to a USB port
To: [email protected]



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

udev rules need to be made, but there are more than 3 ways to tackle
this. udev can create rules from certain device strings so there could
be rules made for the manufacturer of the device, but they are all the
same. The next choice is to make a rule the devices themselves ignoring
the ports, which would allow you to plug the little boogers in anywhere
and get the correct symlink. This is by a serial number that the device
reports, but not all devices report serials.

Next is your idea of choosing to assign links to ports, which is not a
bad idea, but what if you plug a device other than your phone into a
port that is setup just for your phones...things won't work as they
should. I think its best to get a serial from each phone.

With all 3 devices plugged in do this:
lsusb -v | grep iSerial

It might show something like this:
iSerial                 1 ABCDEFG123
iSerial                 1 BCDEFG1234
iSerial                 1 CDEFG12345

If so then put the lines below in a file named
/etc/udev/rules.d/10-local.rules

# /dev/ttyACM0,
SUBSYSTEMS=="usb", ATTRS{serial}=="ABCDEFG123", KERNEL=="ttyACM[0123]",
SYMLINK+="ttyNOKIA0"

# /dev/ttyACM1,
SUBSYSTEMS=="usb", ATTRS{serial}=="BCDEFG1234", KERNEL=="ttyACM[0123]",
SYMLINK+="ttyNOKIA1"

# /dev/ttyACM2
SUBSYSTEMS=="usb", ATTRS{serial}=="CDEFG12345", KERNEL=="ttyACM[0123]",
SYMLINK+="ttyNOKIA2"


The examples above match 3 conditions, though you could easily get away
with just this :

SUBSYSTEMS=="usb", ATTRS{serial}=="ABCDEFG123", SYMLINK+="ttyNOKIA0"

Next:
/etc/init.d/udev restart

YOU MUST UNPLUG THE DEVICES THEN REINSERT THEM FOR THIS TO WORK

Now go into your program and set it for ttyNOKIA0-2 and you should never
have to worry about this again. Use the custom symlink because it is
bound to the phones serial, whereas udev will still create the
incremented ttyACM* device. You can plug the device in the front, back,
side,usb hub or what ever. There will never be an issue with just those
3 phones.

If you get no iSerials:

Unplug the phones
Run udevmonitor IF it's still available on your Ubuntu system...it
disappeared on Debian so if you don't have it run udevadm --monitor
Now plug them in...one at a time noting the dev file path fore each port.

My laptop port 1 and 2 on Debian look like this:
/devices/pci0000:00/0000:00:1f.2/usb1/1-1/1-1:1.0
/devices/pci0000:00/0000:00:1f.2/usb1/1-2/1-2:1.0

You want the last bit, such as 1-1:1.0
Here are the rules to use if the iSerials don't show:

# /dev/ttyACM0,
SUBSYSTEMS=="usb", ID=="1-1:1.0" KERNEL=="ttyACM[0123]",
SYMLINK+="ttyNOKIA0"

# /dev/ttyACM1,
SUBSYSTEMS=="usb", ID=="1-2:1.0", KERNEL=="ttyACM[0123]",
SYMLINK+="ttyNOKIA1"

# /dev/ttyACM2
SUBSYSTEMS=="usb", ID=="1-3:1.0", KERNEL=="ttyACM[0123]",
SYMLINK+="ttyNOKIA2"

Replace those ID's with the correct ones on your server, restart udev,
reinsert your devices and you're cooking with grease.


Additional reading:
http://www.reactivated.net/writing_udev_rules.html

man udev...its actually not a bad man page


Bryan





-- 
Part-time SysAd, full-time Dad, part-time netNinja
CNS, ACFE, FOSS Advocate and Consultant
Registered Linux User #400165
http://baudizm.blogsome.com
http://linuxblazon.wordpress.com
http://3x-comic.blogspot.com  (NEW!)

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Linux Users Group.
To post a message, send email to [email protected]
To unsubscribe, send email to [email protected]
For more options, visit our group at 
http://groups.google.com/group/linuxusersgroup
-~----------~----~----~----~------~----~------~--~---

Reply via email to