当前位置: 首页 > news >正文

linux udev

udev

  • 属性
    KERNEL=="ttyUSB0"SUBSYSTEM=="tty"ATTRS{idVendor}=="1a86" 这些都是属性,是用来匹配有这些属性的设备的

  • 操作
    SYMLINK+="ttyUSB_A":再添加一个 /dev/ttyUSB_A 的链接指向这个 ttyusb
    MODE="0666":权限为 666
    OWNER="abc":所属用户为 abc

示例:
这个的意思是对于同时有 SUBSYSTEM=="tty"SUBSYSTEMS=="usb" 属性的设备,其所属用户为 abc,这样就不用把用户加到 dialout 用户组也能使用这个设备

cat << EOF | sudo tee /etc/udev/rules.d/50-usb-serial.rules
SUBSYSTEM=="tty", SUBSYSTEMS=="usb", OWNER="abc"
EOF

查看属性信息

先看一个 usb 转串口的设备的信息 udevadm info -a /dev/ttyUSB0

Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.looking at device '/devices/pci0000:00/0000:00:08.1/0000:04:00.3/usb1/1-2/1-2.2/1-2.2:1.0/ttyUSB0/tty/ttyUSB0':KERNEL=="ttyUSB0"SUBSYSTEM=="tty"DRIVER==""ATTR{power/control}=="auto"ATTR{power/runtime_active_time}=="0"ATTR{power/runtime_status}=="unsupported"ATTR{power/runtime_suspended_time}=="0"looking at parent device '/devices/pci0000:00/0000:00:08.1/0000:04:00.3/usb1/1-2/1-2.2/1-2.2:1.0/ttyUSB0':KERNELS=="ttyUSB0"SUBSYSTEMS=="usb-serial"DRIVERS=="ch341-uart"ATTRS{port_number}=="0"ATTRS{power/control}=="auto"ATTRS{power/runtime_active_time}=="0"ATTRS{power/runtime_status}=="unsupported"ATTRS{power/runtime_suspended_time}=="0"looking at parent device '/devices/pci0000:00/0000:00:08.1/0000:04:00.3/usb1/1-2/1-2.2/1-2.2:1.0':KERNELS=="1-2.2:1.0"SUBSYSTEMS=="usb"DRIVERS=="ch341"ATTRS{authorized}=="1"ATTRS{bAlternateSetting}==" 0"ATTRS{bInterfaceClass}=="ff"ATTRS{bInterfaceNumber}=="00"ATTRS{bInterfaceProtocol}=="02"ATTRS{bInterfaceSubClass}=="01"ATTRS{bNumEndpoints}=="03"ATTRS{supports_autosuspend}=="1"looking at parent device '/devices/pci0000:00/0000:00:08.1/0000:04:00.3/usb1/1-2/1-2.2':KERNELS=="1-2.2"SUBSYSTEMS=="usb"DRIVERS=="usb"ATTRS{authorized}=="1"ATTRS{avoid_reset_quirk}=="0"ATTRS{bConfigurationValue}=="1"ATTRS{bDeviceClass}=="ff"ATTRS{bDeviceProtocol}=="00"ATTRS{bDeviceSubClass}=="00"ATTRS{bMaxPacketSize0}=="8"ATTRS{bMaxPower}=="104mA"ATTRS{bNumConfigurations}=="1"ATTRS{bNumInterfaces}==" 1"ATTRS{bcdDevice}=="8134"ATTRS{bmAttributes}=="80"ATTRS{busnum}=="1"ATTRS{configuration}==""ATTRS{devnum}=="31"ATTRS{devpath}=="2.2"ATTRS{idProduct}=="7523"ATTRS{idVendor}=="1a86"ATTRS{ltm_capable}=="no"ATTRS{maxchild}=="0"ATTRS{power/active_duration}=="738205"ATTRS{power/autosuspend}=="2"ATTRS{power/autosuspend_delay_ms}=="2000"ATTRS{power/connected_duration}=="738205"ATTRS{power/control}=="on"
...

http://www.mrgr.cn/news/17577.html

相关文章:

  • Codeforces Round 970 (Div. 3) A~F
  • 深度学习速通系列:贝叶思和SVM
  • STM32+W5500实现以太网通信
  • [创业之路-145] :做项目做产品,50米/100米短跑与马拉松长跑,跑法不同,几人的小分队作战与兵团战役,打法不同
  • 【Kubernetes】持久卷声明 PVC
  • 机器学习之监督学习(二)逻辑回归(二元分类问题)
  • 基于SpringBoot+Vue+MySQL的的宠物商城网站
  • Self-study Python Fish-C Note20 P64to65
  • 电阻器件的选型
  • Open3D mesh 均值滤波
  • [Algorithm][综合训练][循环汉诺塔][kotori和素因子][dd爱科学]详细讲解
  • Spring MVC 框架简介与实例
  • vector模拟实现迭代器失效
  • 【Kubernetes】持久卷的动态供给 Dynamic Provisioning
  • HX711—称重模块
  • 18. 为什么浮点类型不支持左移和右移运算符?
  • 计算机毕业设计hadoop+spark知识图谱课程推荐系统 课程预测系统 课程大数据 课程数据分析 课程大屏 mooc慕课推荐系统 大数据毕业设计
  • 提高工作效益方法(一)
  • 【EtherCAT】运行原理
  • 支付平台构建支付接口供整个公司调用—支付代理商