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 313 14:08 newusb -> ttyUSB0
crwxrwxrwx  1 root dialout 188,   0 313 14:08 ttyUSB0
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值