By modifying udev / dev / ttyTHS1 repeatedly read and write access after the failure to find reasons

Modify / dev / ttyTHS1 read and write permissions by udev

A, Jetson Nano's / dev / ttyTHS1 correspond USART2 serial default only root has read and write permissions.

The Internet to find a lot of similar cases: permanent modification / dev / ttyUSB0 read and write permissions posts. But in the same manner, but it can not solve the problem.

Second, the causes and solutions

Google found the cause of the problem: because of start-up service takes up equipment, leading to modify the rules can not reload properly. After the service corresponds to switch off, and then modify UDEV configuration file.

sudo lsof | grep ttyTHS1 # 发现一直占用该串口的服务进程是: nvgetty
systemctl stop nvgetty	 # 停止服务
systemctl disable nvgetty # 取消服务
三、UDEV

The concept that is a long time Linux device file, UDEV distinguished from "ordinary device files" and "devfs", which in Linux device access, especially those with extreme demands on the site of the device (such as the need to control thousands of hard drives) and there is a strong advantage on hot-plug devices (such as USB cameras and MP3 players). The device can be flexibly set by the configuration rules file /etc/udev/rules.d/. UDEV used as follows:

# 查看设备信息
udevinfo -a -p /dev/ttyTHS1  
# 或者 
udevadm info -a /dev/ttyTHS1
# 添加规则文件, 一般前缀数字越小优先级越高
vim /etc/udev/rules.d/20-myserial.rules
# 增加或修改规则文件后重载规则
sudo  udevadm control --reload
# 重启电脑
sudo reboot
Four rules file, / etc / udev / rules.d / syntax Introduction
# == 作用是条件匹配,= 作用是条件匹配成功后赋值
# KERNEL 代表设备名,SUBSYSTEM 代表设备所在子系统名
KERNEL=="ttyTHS1", SUBSYSTEM=="tty", GROUP="users", MODE="0666"
Published 18 original articles · won praise 1 · views 960

Guess you like

Origin blog.csdn.net/ManWZD/article/details/102749906