本文介绍: 把用户名加入了dialout用户组,因tty设备隶属于dialout用户组,重启系统。查看串口设备的id,id为1a86和7523。的10-local.rules文件中添加。(username为用户民),reboot重启最好。

查看串口的详细信息

udevadm info --name=/dev/ttyUSB0

结果:

P: /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
N: ttyUSB0
L: 0
S: serial/by-id/usb-Silicon_Labs_CP2102_USB_to_UART_Bridge_Controller_0001-if00-port0
S: serial/by-path/platform-fd500000.pcie-pci-0000:01:00.0-usb-0:1.2:1.0-port0
S: device2
E: DEVPATH=/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
E: DEVNAME=/dev/ttyUSB0
E: MAJOR=188
E: MINOR=0
E: SUBSYSTEM=tty
E: USEC_INITIALIZED=366284608
E: ID_BUS=usb
E: ID_VENDOR_ID=10c4
E: ID_MODEL_ID=ea60
E: ID_PCI_CLASS_FROM_DATABASE=Serial bus controller
E: ID_PCI_SUBCLASS_FROM_DATABASE=USB controller
E: ID_PCI_INTERFACE_FROM_DATABASE=XHCI
E: ID_VENDOR_FROM_DATABASE=Silicon Labs
E: ID_MODEL_FROM_DATABASE=CP210x UART Bridge
E: ID_VENDOR=Silicon_Labs
E: ID_VENDOR_ENC=Siliconx20Labs
E: ID_MODEL=CP2102_USB_to_UART_Bridge_Controller
E: ID_MODEL_ENC=CP2102x20USBx20tox20UARTx20Bridgex20Controller
E: ID_REVISION=0100
E: ID_SERIAL=Silicon_Labs_CP2102_USB_to_UART_Bridge_Controller_0001
E: ID_SERIAL_SHORT=0001
E: ID_TYPE=generic
E: ID_USB_INTERFACES=:ff0000:
E: ID_USB_INTERFACE_NUM=00
E: ID_USB_DRIVER=cp210x
E: ID_PATH=platform-fd500000.pcie-pci-0000:01:00.0-usb-0:1.2:1.0
E: ID_PATH_TAG=platform-fd500000_pcie-pci-0000_01_00_0-usb-0_1_2_1_0
E: ID_MM_CANDIDATE=1
E: DEVLINKS=/dev/serial/by-id/usb-Silicon_Labs_CP2102_USB_to_UART_Bridge_Controller_0001-if00-port0 /dev/serial/by-path/platform-fd500000.pcie-pci-0000:01:00.0-usb-0:1.2:1.0-port0 /dev/device2
E: TAGS=:systemd:

通过id固定串口名称

通过lsusb查看串口设备的id,id为1a86和7523
在这里插入图片描述
/etc/udev/rules.d的10-local.rules文件中添加

ACTION=="add", KERNEL=="ttyUSB*", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="7523", MODE:=“0777”,SYMLINK+="serialname"

保存关闭,重启服务sudo /etc/init.d/udev restart,reboot重启最好

通过USB口位置固定名称

还是借鉴一下本文
如果插入扩展坞扩展USB口,也能这么配置,比如把编号1-1.1的USB口扩展成4个USB口
重新配置rules文件,注释之前的1.1.1那行配置,再添加4行

# KERNEL=="ttyUSB*",KERNELS=="1-1.1",MODE:="0777",SYMLINK+="device1"
KERNEL=="ttyUSB*",KERNELS=="1-1.1.1",MODE:="0777",SYMLINK+="device11"
KERNEL=="ttyUSB*",KERNELS=="1-1.1.2",MODE:="0777",SYMLINK+="device12"
KERNEL=="ttyUSB*",KERNELS=="1-1.1.3",MODE:="0777",SYMLINK+="device13"
KERNEL=="ttyUSB*",KERNELS=="1-1.1.4",MODE:="0777",SYMLINK+="device14"

Permission denied: ‘/dev/ttyUSB0‘

sudo usermod -aG dialout username(username为用户民)
把用户名加入了dialout用户组,因tty设备隶属于dialout用户组,重启系统

原文地址:https://blog.csdn.net/u014220146/article/details/135517791

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。

如若转载,请注明出处:http://www.7code.cn/show_55438.html

如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱:suwngjj01@126.com进行投诉反馈,一经查实,立即删除!

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注