參考博客
單個USB設備讀取路徑及權限設置
查看USB端口的狀態命令:
ls -l /dev |grep ttyUSB
生成rplidar.rules 文件:
sudo gedit /etc/udev/rules.d/rplidar.rules
然後編輯文件:
# set the udev rule , make the device_port be fixed by rplidar
#
KERNEL=="ttyUSB*", ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea60", MODE:="0777", SYMLINK+="rplidar"
然後拔插雷達的USB口,重新執行查看命令看到
hri@hri-Lenovo-Gaming:~$ ls -l /dev |grep ttyUSB
lrwxrwxrwx 1 root root 7 11月 20 17:07 rplidar -> ttyUSB0
lrwxrwxrwx 1 root root 7 11月 20 17:07 kobuki -> ttyUSB1
crwxrwxrwx 1 root dialout 188, 0 11月 20 17:07 ttyUSB0
crw-rw-rw- 1 root dialout 188, 1 11月 20 17:07 ttyUSB1
使用hub 鏈接多個USB設備
sudo gedit /etc/udev/rules.d/slam_hub.rules
然後編輯:
SUBSYSTEMS=="usb"
DRIVERS=="cp210x"
ATTRS{bInterfaceClass}=="ff"
ATTRS{bInterfaceSubClass}=="00"
ATTRS{bInterfaceProtocol}=="00"
ATTRS{bNumEndpoints}=="02"
ATTRS{supports_autosuspend}=="1"
ATTRS{bAlternateSetting}==" 0"
ATTRS{bInterfaceNumber}=="00"
ATTRS{interface}=="CP2102 USB to UART Bridge Controller"
KERNEL=="ttyUSB*", KERNELS=="3-2.3", MODE:="0777",SYMLINK+="slamtec_base_"
KERNEL=="ttyUSB*", KERNELS=="3-2.4", MODE:="0777",SYMLINK+="slamtec_laser_"
最後查看
hri@hri-Lenovo-Gaming:~$ ls -l /dev |grep ttyUSB
lrwxrwxrwx 1 root root 7 11月 20 17:07 kobuki -> ttyUSB1
lrwxrwxrwx 1 root root 7 11月 20 17:07 rplidar -> ttyUSB0
lrwxrwxrwx 1 root root 7 11月 20 17:07 slamtec_base_ -> ttyUSB1
lrwxrwxrwx 1 root root 7 11月 20 17:07 slamtec_laser_ -> ttyUSB0
crwxrwxrwx 1 root dialout 188, 0 11月 20 17:07 ttyUSB0
crw-rw-rw- 1 root dialout 188, 1 11月 20 17:07 ttyUSB1