2

I'm using a Raspberry Pi 3 Model B with Ubuntu Mate on a mobile device, connected to an IMU, a GPS and two LIDAR.

Ubuntu 16.04.2
Kernel version 4.4.38-v7+

The device boots once powered then starts the drivers and the programs to sample the data. These programs must have the port (ttyUSB* or symlink) of the device assigned beforehand.

Every time I boot, the USB devices pick a random ttyUSB* to go with. This works fine for the IMU and the GPS since they have unique serial ids, etc, however, the LIDAR devices both use the same UART to USB chip which are indistinguishable from each other.

lsusb:

Bus 001 Device 005: ID 0403:6014 Future Technology Devices International, Ltd FT232H Single HS USB-UART/FIFO IC
Bus 001 Device 004: ID 06c2:0033 Phidgets Inc. (formerly GLAB)
Bus 001 Device 007: ID 10c4:ea60 Cygnal Integrated Products, Inc. CP210x UART Bridge / myAVR mySmartUSB light
Bus 001 Device 006: ID 10c4:ea60 Cygnal Integrated Products, Inc. CP210x UART Bridge / myAVR mySmartUSB light
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp. SMC9514 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

I tried comparing the device info to see how they could be differentiated.

diff <(udevadm info --name /dev/ttyUSB1) <(udevadm info --name /dev/ttyUSB2)

1,2c1,2
- P: /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2/1-1.2:1.0/ttyUSB1/tty/ttyUSB1
- N: ttyUSB1
---
+ P: /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.3/1-1.3:1.0/ttyUSB2/tty/ttyUSB2
+ N: ttyUSB2

4,7c4,7
- S: serial/by-path/platform-3f980000.usb-usb-0:1.2:1.0-port0
- E: DEVLINKS=/dev/serial/by-id/usb-Silicon_Labs_CP2102_USB_to_UART_Bridge_Controller_0001-if00-port0 /dev/serial/by-path/platform-3f980000.usb-usb-0:1.2:1.0-port0
- E: DEVNAME=/dev/ttyUSB1
- E: DEVPATH=/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2/1-1.2:1.0/ttyUSB1/tty/ttyUSB1
---
+ S: serial/by-path/platform-3f980000.usb-usb-0:1.3:1.0-port0
+ E: DEVLINKS=/dev/serial/by-path/platform-3f980000.usb-usb-0:1.3:1.0-port0 /dev/serial/by-id/usb-Silicon_Labs_CP2102_USB_to_UART_Bridge_Controller_0001-if00-port0
+ E: DEVNAME=/dev/ttyUSB2
+ E: DEVPATH=/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.3/1-1.3:1.0/ttyUSB2/tty/ttyUSB2

14,15c14,15
- E: ID_PATH=platform-3f980000.usb-usb-0:1.2:1.0
- E: ID_PATH_TAG=platform-3f980000_usb-usb-0_1_2_1_0
---
+ E: ID_PATH=platform-3f980000.usb-usb-0:1.3:1.0
+ E: ID_PATH_TAG=platform-3f980000_usb-usb-0_1_3_1_0

28c28
- E: MINOR=1
---
+ E: MINOR=2

31c31
- E: USEC_INITIALIZED=4706121921
---
+ E: USEC_INITIALIZED=4706424041

What I would like to do at this stage is assign a persistent name to each physical USB port on the Raspberry Pi so that, as long as the devices are plugged into the correct socket, it'll work. I've tried a lot of rules with no success. Many combinations of:

KERNEL=="ttyUSB*",KERNELS=="1-1.2",NAME="ttyUSB0",MODE="0666" KERNEL=="ttyUSB*",KERNELS=="1-1.2:1.0",NAME="ttyUSB0",MODE="0666" KERNEL=="ttyUSB*",KERNELS=="1-1.3",NAME="ttyUSB1",MODE="0666" KERNEL=="ttyUSB*",KERNELS=="1-1.3:1.0",NAME="ttyUSB1",MODE="0666" KERNEL=="ttyUSB*",KERNELS=="1-1.5",NAME="ttyUSB2",MODE="0666" KERNEL=="ttyUSB*",KERNELS=="1-1.5:1.0",NAME="ttyUSB2",MODE="0666"

as recommended here; https://askubuntu.com/questions/49910/how-to-distinguish-between-identical-usb-to-serial-adapters

From the udevadm info, the only other difference seemed to be the MINOR attribute but I haven't figured out how to use this info. My best guess so far is:

SUBSYSTEM=="tty", ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea60", ATTRS{Minor}=="1", SYMLINK+="rplidar1"
SUBSYSTEM=="tty", ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea60", ATTRS{Minor}=="2", SYMLINK+="rplidar2"

but that doesn't seem to work either (I've tried MINOR and minor too).

  • 1
    Have you looked into /dev/serial/by-id? With the default udev rules, there should already be symlinks there which you can use as persistent names. – dirkt Sep 25 '17 at 21:33
  • When both LIDAR are connected, only a single entry is added to /dev/serial/by-id. I assume this is because they have the same serial number – Tynow Sep 26 '17 at 7:46
3

I found a solution. The following rules assign a symbolic link to the corresponding usb ports for the given device. You could probably get rid of the idVendor and idProduct terms.

SUBSYSTEM=="tty", KERNELS=="1-1.2", ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea60", SYMLINK+="rplidar1"
SUBSYSTEM=="tty", KERNELS=="1-1.3", ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea60", SYMLINK+="rplidar2"

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.