How to Identify Multiple Usb-Serial Adapters Under Ubuntu 10.1

Persistence between USB to Serial devices with the same serial number

I had this problem in the past with two identical USB-Serial devices. In the end we solved it long term by replacing them with a four-port USB-Serial device which was the only USB-Serial device in the system, making it simpler to find and detect the individual serial ports regardless of where the four-port USB was connected.

However:

Empirical Approach

You may be able to do it with a bit of empirical observation, if you can physically identify and maintain the USB port it is connected to, and if the USB subsystems don't change (say, thanks to other PCI cards or USB hubs being removed/added, BIOS update, etc. - its a big 'if', I know...) and if you only have one system you care about...

The command lsusb -t will give you a tree of USB devices and ports. You can use this to find your device(s). Pick one then remove it and plug it into a different USB ports to confirm you have the device you want. Label it, and label the physical port you want to use it with, and make a note of the Bus, Port, Device, address etc. at that point in time. Provided the PCI bus doesn't change, etc., then that USB bus, device, port should remain the one corresponding to that USB-serial device.

Example output:

/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=ehci_hcd/5p, 480M
|__ Port 3: Dev 2, If 0, Class=hub, Driver=hub/4p, 480M
|__ Port 1: Dev 7, If 0, Class=vend., Driver=pl2303, 12M

In this case, the chain Bus 02, Port 3 Dev1 --> Port 1 Dev 7

You might then be able to use that information in a udev rule to discriminate the specific USB-serial device, something along the lines of:

ATTRS{devpath}=="3.1",ATTRS{idVendor}=="0557", ATTRPICS{idProduct}=="2008"

Here, 3.1 corresponds to the bottom Port 3, Port 1

Here is an example not plugged into a hub:

/:  Bus 03.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/2p, 480M
|__ Port 1: Dev 2, If 0, Class=vend., Driver=pl2303, 12M

and

ATTRS{devpath}=="1",ATTRS{idVendor}=="0557", ATTRS{idProduct}=="2008"

Ignore the Dev number, it changes each time you plug in.
Obviously, replace the productId, etc. with yours...

Linux USB device path meaning? (need to distinguish USB-Serial converters)

I'm no expert in this field, but these are my interpretation of those numbers:

  • pci0000:00: This is your PCI controller.
  • 0000:00:0f.5: This is the PCI identifier of your USB controller.
  • usb1: The usb controller itself.
  • 1-3: The identifier of the USB hub. It may be an internal hub, or it may be absent.
  • 1-3.1: Device connected to the first port of that hub.
  • 1-3.1:1.0: Configuration #1, Interface #0 in that device.

So, my guess is that the physical port is identified by 1-3.1, that is the string to the left of the colon in the last piece of the device path.

I don't have a hub around but I'd bet that if you connect it via a hub you'll get something like:

/devices/pci0000:00/0000:00:0f.5/usb1/1-3/1-3.1/1-3.1.1/1-3.1.1:1.0/ttyUSB0

The physical port would be 1-3.1.1, and that last 1 would be the port used in that hub.

ttyusb udev naming by hardware port

There is already a rules file (60-persistent-serial.rules) that creates pretty paths in /dev/serial/by-path/ that match the port. For example, when my USB serial device got inserted in a USB 3.0 port:

$ ls -l serial/by-path/
total 0
lrwxrwxrwx 1 root root 13 Apr 2 22:20 pci-0000:02:00.0-usb-0:1:1.0-port0 -> ../../ttyUSB0

And when the same device is connected to a different USB 2.0 port:

$ ls -l /dev/serial/by-path/
total 0
lrwxrwxrwx 1 root root 13 Apr 2 22:20 pci-0000:00:1d.0-usb-0:1.2:1.0-port0 -> ../../ttyUSB0

How to locate ttyUSB0 in Xubuntu 14.04?

I returned to the original PC, where the problem was encountered, and tried dmesg on it. The results were interesting.

[587216.474235] usb 7-1: FTDI USB Serial Device converter now attached to ttyUSB0
[587221.340323] usb 7-1: usbfs: interface 0 claimed by ftdi_sio while 'brltty' sets config #1
[587221.342999] ftdi_sio ttyUSB0: FTDI USB Serial Device converter now disconnected from ttyUSB0
[587221.343171] ftdi_sio 7-1:1.0: device disconnected

This showed that brltty is disconnecting me. I looked up the output and found some bug reports which address the problem. The linked report includes the workaround (remove brltty)

bug report to Debian



Related Topics



Leave a reply



Submit