Linux下usb串口修改名称
1 查看自己的串口号
fly@ubuntu:~/Desktop$ lsusb
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 004: ID 0e0f:0002 VMware, Inc. Virtual USB Hub
Bus 003 Device 003: ID 0e0f:0002 VMware, Inc. Virtual USB Hub
Bus 003 Device 020: ID 1a86:7523 QinHeng Electronics HL-340 USB-Serial adapter
Bus 003 Device 002: ID 0e0f:0003 VMware, Inc. Virtual Mouse
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 003: ID 0e0f:0002 VMware, Inc. Virtual USB Hub
Bus 002 Device 002: ID 0e0f:0008 VMware, Inc. Virtual Bluetooth Adapter
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
2 新建设备信息文件
打开终端,输入下面指令进入rules.d下
fly@ubuntu:~/Desktop$ cd /etc/udev/rules.d
创建新的rules文件
fly@ubuntu:/etc/udev/rules.d$ sudo gedit newusb.rules
在文本中添加
根据第一步中串口ID为1a86:7523,idVendor对应1a86, idProduct对应7523
KERNEL=="ttyUSB0", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="7523", MODE:="0777", SYMLINK+="newusb"
3 刷新串口
sudo service udev reload
sleep 2
sudo service udev restart
拔插串口
4 重新查看串口
可以看到自己创建的名称映射到串口上
fly@ubuntu:~/Desktop$ ls -l /dev/ | grep ttyUSB
lrwxrwxrwx 1 root root 7 3月 13 14:08 newusb -> ttyUSB0
crwxrwxrwx 1 root dialout 188, 0 3月 13 14:08 ttyUSB0