ubuntu下修改usb设备为固定设备名
在ubuntu下经常插入多个usb设备则需要知道端口号但是每次都是随即分配/dev/ttyUSB0~9
一,绑定usb芯片,但是同型号芯片不能同时插
则通过一下方法绑定设备串口名称
首先
lsusb
出现如下
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub Bus 001 Device 008: ID 1a86:7523 QinHeng Electronics HL-340 USB-Serial adapter Bus 001 Device 007: ID 046d:c534 Logitech, Inc. Unifying Receiver Bus 001 Device 002: ID 2109:3431 VIA Labs, Inc. Hub Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
以第2个为例
记下ID 1a86:7523
sudo vim /etc/udev/rules.d/com_port.rules
内容如下
KERNEL=="ttyUSB*" , ATTRS{idVendor}=="1a86",ATTRS{idProduct}=="7523",MODE:="0 777" ,SYMLINK+="mpu9250"
然后
sudo sudo udevadm trigger
使其生效
查阅别的看到有使用 sudo service udev reload sudo service udev restart 但是我这里没啥效果
然后查看
pi@raspberry:~$ ls -l /dev/mpu9250 lrwxrwxrwx 1 root root 7 12月 16 08:53 /dev/mpu9250 -> ttyUSB0
二,绑定usb硬件端口,只要插入该usb端口即为设定设备名
pi@raspberry:~$ ls /sys/class/tty/ttyUSB* -l lrwxrwxrwx 1 root root 0 12月 18 03:20 /sys/class/tty/ttyUSB0 -> ../../devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.2/1-1.2:1.0/ttyUSB0/tty/ttyUSB0 lrwxrwxrwx 1 root root 0 12月 18 03:20 /sys/class/tty/ttyUSB1 -> ../../devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.4/1-1.4:1.0/ttyUSB1/tty/ttyUSB1 lrwxrwxrwx 1 root root 0 12月 18 03:20 /sys/class/tty/ttyUSB2 -> ../../devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.3/1-1.3:1.0/ttyUSB2/tty/ttyUSB2
黄色字体极为固定串口编号
sudo vim /etc/udev/rules.d/com_port.rules
内容如下
ACTION=="add", KERNELS=="1-1.2:1.0" , SUBSYSTEMS=="usb" , MODE:="0777" , SYMLINK+="mpu9250" ACTION=="add", KERNELS=="1-1.4:1.0" , SUBSYSTEMS=="usb" , MODE:="0777" , SYMLINK+="arduino2560" ACTION=="add", KERNELS=="1-1.3:1.0" , SUBSYSTEMS=="usb" , MODE:="0777" , SYMLINK+="rplidar"
保存退出后重新插拔设备即可生成固定设备名
通过该方式 设定的激光雷达不能正常驱动错误如下
Error, cannot bind to the specified serial port /dev/rpliadr.
解决
ACTION=="add", KERNELS=="1-1.3:1.0" , SUBSYSTEMS=="usb" , MODE:="0777" , SYML INK+="rplidar" ,TAG+="systemed"
https://answers.ros.org/question/248066/integrating-voxel_layer-into-the-costmap/