9

I'm using a Huawei GMS/UMTS USB modem with Gnokii and Gammu. The modem was in the lower port on Pi. With dmesg | grep tty it would show up on /dev/ttyUSB0 and /dev/ttyUSB1. (2 USB devices on 1 stick is normal, in this case).

I configured Gnokii and Gammu accordingly, however on ttyUSB0 I could only send messages. Both sending and receiving would only work over ttyUSB1.

I then moved the stick to the upper USB socket (because otherwise my WiFi-stick wouldn't fit next to it). Everything kept working fine. Also after several reboots, cold and warm.

I then needed to expand the file system (Yeah, I know I should have done that earlier). After that, the modem was on ttyUSB0 and ttyUSB*2*. Send/receive worked on the latter. This took me some time to find out.

Update: 2 days later, ttyUSB2 has disappeared. The working modem now manifests itself on ttyUSB0 (was ttyUSB1).

Any idea why this happened? Any links to relevant debian or linux docs, perhaps? I'd be much obliged..

  • Try using the names in /sys/class/tty/ as a guide. – Lekensteyn Dec 12 '13 at 17:43
  • The only ttyUSB's in /sys/class/tty are ttyUSB0 and ttyUSB1. Now. Who know what'll it be tomorrow. – RolfBly Dec 14 '13 at 21:55
  • USB enumeration changes by design, you plug a new device and get a new number. or maybe an old device while the previous port number is still busy with unfinished transfers. try not to reconnect devices back too soon and make sure all the software using these devices has happily finished their business. – lenik Dec 17 '13 at 0:07
14

The Gammu documentation suggests (but doesn't go into any detail of) a workaround,

Edit: Atmel has an Application Note that nicely describes the enumeration process.

Enumeration changes because it happens in a conversation between host, hub and device, and response timing from each of these may vary, even if the setup is identical from one reboot to the next.

Update: The solution is not easily found on line, and scattered in pieces all over the place. So I put it all together in one document. This is what it boils down to.
1. find out what's on ttyUSB:

dmesg | grep ttyUSB  

2. list all attributes of the device and pick out a unique identifier set, eg idVendor + idProduct (and if necessary SerialNumber if you have more than one device with the same idVendor and idProduct).

udevadm info --name=/dev/ttyUSB1 --attribute-walk

3. Create a file /etc/udev/rules.d/99-usb-serial.rules with something like this line in it:

SUBSYSTEM=="tty", ATTRS{idVendor}=="1234", ATTRS{idProduct}=="5678", SYMLINK+="your_device_name" 

(assuming you don't need a serial number there, and of course with the numbers for idVendor and idProduct that you found in step 2.
4. Load the new rule:

sudo udevadm trigger

5. Verify what happened:

ls -l /dev/your_device_name  

will show what ttyUSB number the symlink went to. If it's /dev/ttyUSB1, then verify who owns that and to which group it belongs:

ls -l /dev/ttyUSB1   

Then just for the fun of it:

udevadm test -a -p  $(udevadm info -q path -n /dev/your_device_name)
8

You've partially answered your own question, but there is another way of doing it, especially for serial devices: the /dev/serial/* paths. I have a Prolific USB→RS232 interface on my Raspberry Pi which almost invariably shows up as /dev/ttyUSB0. But it also appears on the system as:

  • /dev/serial/by-path/platform-bcm2708_usb-usb-0:1.3:1.0-port0
  • /dev/serial/by-id/usb-067b_2303-if00-port0

Using the by-id link should stay the same, unless I add another PL2303-based converter.

  • ..And when someone really adds a new PL2303-based converter. ( 2 of them ) then what can be donw ? – Obmerk Kronen May 15 '16 at 13:18
  • You're stuck. I prefer to mix and match brands to avoid this. – scruss May 15 '16 at 19:16
  • This was immensely helpful for a Serial port that was changing on me in Python -thanks! – GhostToast Jan 14 at 21:13

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.