F.J Kong's Blog

BRAVO HOTEL ONE SIERRA CHARLIE WHISKEY

多个串口节点名称不固定的解决方法 How to identify multiple USB-serial adapters under Ubuntu

copy from here:http://stackoverflow.com/questions/4800099/how-to-identify-multiple-usb-serial-adapters-under-ubuntu-10-1

The USB “KERNEL” was not enough in my case, but I found the port number.

I am aware that what I’m proposing now might be considered an insane hack, but it works for me..
for now..

I would actually be pleased to see a more elegant suggestion that accomplish something similar..

So… Based on the previous answer form Ilya Matveychikov

File: /etc/udev/rules.d/usb-parse-devpath.sh

#!/bin/bash

DEVNUM=$(echo "${1}" | rev | cut -d'/' -f4 | rev | tr -d '-' | tr -d '.' | tr -d ':')
PORTNUM=$(/sbin/udevadm info -a --path=${1} | grep "ATTRS{port_number}" | head -1 | cut -d'"' -f2)
PRODUCT=$(/sbin/udevadm info -a --path=${1} | grep "ATTRS{product}" | head -1 | cut -d'"' -f2 | tr -d '/' | tr ' ' '_')

NEWID="ttyUSB_${PRODUCT}_${DEVNUM}${PORTNUM}"

#echo "${NEWID} :: $1" >> /tmp/DEBUG_udev.txt

echo "$NEWID"

And File: /etc/udev/rules.d/99-usb-serial.rules

ACTION=="add", KERNEL=="ttyUSB[0-9]*", PROGRAM="/etc/udev/rules.d/usb-parse-devpath.sh %p", SYMLINK+="TTYUSBs/%c"

then restart udev

Leave a Reply