当前位置:网站首页>Serial port configuration of raspberry pie
Serial port configuration of raspberry pie
2022-07-28 07:12:00 【The most beautiful wish must be the craziest】
Because of the raspberry pie uart Not enough use , So what we're using is usb To serial port . But there is a problem . When usb The devices are inserted in different order , Its device nodes will be different , Sometimes it's ttyUSB0, Sometimes it's ttyUSB1 Or other . According to this question , After Baidu found a simple solution . That's through udev To statically set the name of the file node . About udev No discussion here . I apply it directly .
First of all ttyUSB0 For example :
Input udevadm info -a /dev/ttyUSB0
The printed information is as follows :
looking at device
'/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.4/1-1.4:1.0/ttyUSB0/tty/ttyUSB0':
KERNEL=="ttyUSB0"
SUBSYSTEM=="tty"
DRIVER==""
looking at parent device
'/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.4/1-1.4:1.0/ttyUSB0':
KERNELS=="ttyUSB0"
SUBSYSTEMS=="usb-serial"
DRIVERS=="ch341-uart"
ATTRS{port_number}=="0"
looking at parent device '/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.4/1-1.4:1.0':
KERNELS=="1-1.4:1.0"
SUBSYSTEMS=="usb"
DRIVERS=="ch341"
ATTRS{bInterfaceClass}=="ff"
ATTRS{bInterfaceSubClass}=="01"
ATTRS{bInterfaceProtocol}=="02"
ATTRS{bNumEndpoints}=="03"
ATTRS{authorized}=="1"
ATTRS{supports_autosuspend}=="1"
ATTRS{bAlternateSetting}==" 0"
ATTRS{bInterfaceNumber}=="00"
looking at parent device '/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.4':
KERNELS=="1-1.4"
SUBSYSTEMS=="usb"
DRIVERS=="usb"
ATTRS{bDeviceSubClass}=="00"
ATTRS{bDeviceProtocol}=="00"
ATTRS{devpath}=="1.4"
ATTRS{idVendor}=="1a86"
ATTRS{speed}=="12"
ATTRS{bNumInterfaces}==" 1"
ATTRS{bConfigurationValue}=="1"
ATTRS{bMaxPacketSize0}=="8"
ATTRS{busnum}=="1"
ATTRS{devnum}=="4"
ATTRS{configuration}==""
ATTRS{bMaxPower}=="96mA"
ATTRS{authorized}=="1"
ATTRS{bmAttributes}=="80"
ATTRS{bNumConfigurations}=="1"
ATTRS{maxchild}=="0"
ATTRS{bcdDevice}=="0254"
ATTRS{avoid_reset_quirk}=="0"
ATTRS{quirks}=="0x0"
ATTRS{version}==" 1.10"
ATTRS{urbnum}=="20"
ATTRS{ltm_capable}=="no"
ATTRS{removable}=="removable"
ATTRS{idProduct}=="7523"
ATTRS{bDeviceClass}=="ff"
ATTRS{product}=="USB2.0-Serial"
......... The printed information is followed by , But there's no need for , So I didn't post it ........
Okay , The blue font above is the information we need .
As for why we choose this
looking at parent device '/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.4': The message inside , Not the others , My understanding is that , The system is based on the idVendor and idProduct To distinguish between ttyUSB0,ttyUSB1.... etc. USB Serial equipment .
Then get other information in the same way . And then in the catalog /etc/udev/rules.d Next new file 188-usbtty.rules This file can be named differently , But it needs to be .rules file .
Enter the content in the file
KERNEL=="ttyUSB*", SUBSYSTEMS=="usb", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="7523", KERNELS=="1-1.2",NAME="ttyUSB0", SYMLINK+="myuart0"
KERNEL=="ttyUSB*", SUBSYSTEMS=="usb", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="7523", KERNELS=="1-1.3",NAME="ttyUSB1", SYMLINK+="myuart1"
KERNEL=="ttyUSB*", SUBSYSTEMS=="usb", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="7523", KERNELS=="1-1.4",NAME="ttyUSB2", SYMLINK+="myuart2"
KERNEL=="ttyUSB*", SUBSYSTEMS=="usb", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="7523", KERNELS=="1-1.5",NAME="ttyUSB3", SYMLINK+="myuart3"
among SYMLINK+="myuart0" Is the name of the static file node you want to set . After restarting the system, you can see the following :

边栏推荐
猜你喜欢

Clock tree analysis example

Easypoi export table with echars chart

Shell--- function

MySQL查询父节点下面的所有子孙节点,查询用户列表时多级(公司)部门处理,根据反射,递归树形结构工具类

静态和浮动路由

Wangeditor (@4.7.15) - lightweight rich text editor

freemarker导出word,带表格和多张图片,解决图片重复和变形

VNC Timed out waiting for a response from the computer

Neo4j运行报错Error occurred during initialization of VM Incompatible minimum and maximum heap sizes spec

Redis哨兵模式及集群
随机推荐
Standard C language summary 2
Freemaker merges cells, uses if and else tags, and processes null and empty strings
About gcc:multiple definition of
DOM operation cases
MOOC Weng Kai C language week 8: pointer and string: 1. Pointer 2. Character type 3. String 4. String calculation
三层交换和VRRP
Shell -- first day homework
Animation animation realizes the crossing (click) pause
Joern's code uses -devign
DNS domain name resolution
Esxi community network card driver updated again
MySQL excludes holidays and calculates the date difference
easypoi导出隔行样式设置
Static and floating routes
freemarker导出word,带表格和多张图片,解决图片重复和变形
As a result, fill in the birthday candles
Operation document tree
1、 PXE overview and installation
Servlet
Forward and backward slash notes