Killertechno
Posts: 174
Joined: Wed Jan 02, 2013 8:28 am

USB to serial adapter: ttyUSBx identification?

Fri Apr 19, 2019 1:36 pm

Hi to all, I donìt know if this is correct section....

I'm using several devices with serial to USB bridge, so I have ttyUSB0, ttyUSB1, ttyUSB2, ttyUSB3, up to 8 ttyUSBx entries.

Here dmesg log:

Code: Select all

[178399.675164] usbcore: registered new interface driver pl2303
[178399.675250] usbserial: USB Serial support registered for pl2303
[178399.675269] pl2303 1-1.1:1.0: pl2303 converter detected
[178399.681292] usb 1-1.1: pl2303 converter now attached to ttyUSB0
[178440.346398] pl2303 ttyUSB0: usb_serial_generic_read_bulk_callback - urb stopped: -32
[178667.204867] pl2303 ttyUSB0: usb_serial_generic_read_bulk_callback - urb stopped: -32
[178742.386178] pl2303 ttyUSB0: usb_serial_generic_read_bulk_callback - urb stopped: -32
[178742.609318] pl2303 ttyUSB0: pl2303_set_control_lines - failed: -19
[178742.609324] pl2303 ttyUSB0: error sending break = -19
[178742.609426] pl2303 ttyUSB0: pl2303 converter now disconnected from ttyUSB0
[178742.609444] pl2303 1-1.1:1.0: device disconnected

To understand which device type I'm using I need to poll every ttyUSBx.
If I correctly remember I can program chip, so I would like to know if there is a way to tell linux to use specific desctiption for every ttyUSBx so I can detect specific device in dmesg?

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 2170
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: USB to serial adapter: ttyUSBx identification?

Fri Apr 19, 2019 2:12 pm

This isn't really a Device Tree question, but I'll have a go at answering. FTDI adaptors have unique serial identifiers, and you can use udev to associate specific names with them. From https://gist.github.com/cbrake/4337154:

Code: Select all

SUBSYSTEM=="tty", ATTRS{serial}=="FT4M9NIU", ENV{ID_USB_INTERFACE_NUM}=="00", SYMLINK+="ttyUSB_du"
SUBSYSTEM=="tty", ATTRS{serial}=="FT4M9NIU", ENV{ID_USB_INTERFACE_NUM}=="01", SYMLINK+="ttyUSB_redcloud"
SUBSYSTEM=="tty", ATTRS{serial}=="FT4M9NJ7", ENV{ID_USB_INTERFACE_NUM}=="00", SYMLINK+="ttyUSB_unused1"
SUBSYSTEM=="tty", ATTRS{serial}=="FT4M9NJ7", ENV{ID_USB_INTERFACE_NUM}=="01", SYMLINK+="ttyUSB_twister"
However, it sounds like your adaptors are Prolific pl2303 devices, and the same page says:

Code: Select all

# single blue USB serial adapter, prolific devices don't seem to have a serial number that I can find
SUBSYSTEM=="tty", DRIVERS=="pl2303", SYMLINK+="ttyUSB_panda"
so you may be unlucky. I was going to suggest using the udevadm tool to look for a device-specific identifier of some kind, but someone else has already looked for (and failed to find) one. From https://stackoverflow.com/questions/544 ... e-in-linux:
i run:

Code: Select all

udevadm info -a -n /dev/ttyUSB0
i get:

Code: Select all

KERNELS=="1-2"
SUBSYSTEMS=="usb"
DRIVERS=="usb"
ATTRS{authorized}=="1"
ATTRS{avoid_reset_quirk}=="0"
ATTRS{bConfigurationValue}=="1"
ATTRS{bDeviceClass}=="00"
ATTRS{bDeviceProtocol}=="00"
ATTRS{bDeviceSubClass}=="00"
ATTRS{bMaxPacketSize0}=="64"
ATTRS{bMaxPower}=="100mA"
ATTRS{bNumConfigurations}=="1"
ATTRS{bNumInterfaces}==" 1"
ATTRS{bcdDevice}=="0400"
ATTRS{bmAttributes}=="80"
ATTRS{busnum}=="1"
ATTRS{configuration}==""
ATTRS{devnum}=="27"
ATTRS{devpath}=="2"
ATTRS{idProduct}=="2303"
ATTRS{idVendor}=="067b"
ATTRS{ltm_capable}=="no"
ATTRS{manufacturer}=="Prolific Technology Inc. "
ATTRS{maxchild}=="0"
ATTRS{product}=="USB-Serial Controller D"
ATTRS{quirks}=="0x0"
ATTRS{removable}=="removable"
ATTRS{speed}=="12"
ATTRS{urbnum}=="20"
ATTRS{version}==" 1.10"
But no

Code: Select all

ATTRS{serial}

User avatar
scruss
Posts: 2228
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: USB to serial adapter: ttyUSBx identification?

Fri Apr 19, 2019 3:42 pm

pl2303s don't have serial numbers, as PhilE said. As long as you're not unplugging the cables and moving them around, /dev/serial/by-id/ or /dev/serial/by-path/ should stay the same over system restarts.

If you are unplugging the cables and moving them around on the Raspberry Pi, you really need to replace them with real FTDI cables. These give you constant locations in /dev/serial/by-id/
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.

Return to “Device Tree”