扩展坞映射名称
# 多USB设备配置固定名称
- 该种方式给固定设备口起名,如果更换设备需要重新mapping端口号
### 查询硬件设备端口号
```bash
ls /sys/class/tty/ttyUSB* -l
lrwxrwxrwx 1 root root 0 3月 18 19:22 /sys/class/tty/ttyUSB0 -> ../../devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3.2/3-3.2:1.0/ttyUSB0/tty/ttyUSB0
lrwxrwxrwx 1 root root 0 3月 18 19:22 /sys/class/tty/ttyUSB1 -> ../../devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3.3/3-3.3:1.0/ttyUSB1/tty/ttyUSB1
```
其中,“3-3.3:1.0”极为固定串口编号
### 写入设备而名称
```bash
sudo vim /etc/udev/rules.d/com_port.rules
```
- 写入后的配置文件为:
```config
ACTION=="add", KERNELS=="3-3.3:1.0" , SUBSYSTEMS=="usb" , MODE:="0777" , SYMLINK+="USB_UWBDEV"
ACTION=="add", KERNELS=="3-3.2:1.0" , SUBSYSTEMS=="usb" , MODE:="0777" , SYMLINK+="USB_WHEELTEC_IMU"
ACTION=="add", KERNELS=="3-2.1:1.0" , SUBSYSTEMS=="usb" , MODE:="0777" , SYMLINK+="USB_ULTRASONIC"
```
### 重启设备
- 如果以下指令不生效,重启
```bash
sudo udevadm trigger
sudo service udev reload
sudo service udev restart
```
### 验证设备
```bash
ls -l /dev | grep ttyUSB
# 显示重命名:
lrwxrwxrwx 1 root root 7 Jul 16 16:48 USB_GPS -> ttyUSB0
crwxrwxrwx 1 root dialout 188, 0 Jul 16 16:48 ttyUSB0
```