UDEV-如何获取子设备属性的值 [英] UDEV-How to get value of a child device attributes

查看:43
本文介绍了UDEV-如何获取子设备属性的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写udev规则来设置两个串行端口的名称.我想在符号链接中使用属性 bInterfaceNumber 的值.

I am writting an udev rule to set name of two serial ports. I want to use the value of the attribute bInterfaceNumber in the symlink.

我的规则是:

SUBSYSTEMS =="usb",DRIVERS =="=" usb,ATTRS {idVendor} ==" 0403,ATTRS {idProduct} ==" 6010,SYMLINK + =" toto%s {bInterfaceNumber}"

SUBSYSTEMS=="usb", DRIVERS=="usb", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6010", SYMLINK+="toto%s{bInterfaceNumber}"

该规则与设备匹配,但从未找到该属性的值.

The rule matched the device but value of the attribute is never found.

这是一台设备的层次结构视图:

Here is the hierarchical view of one device:

console@host:udevadm info --name=/dev/ttyUSB0 --attribute-walk
looking at parent device '/devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0':
    KERNELS=="1-1:1.0"
    SUBSYSTEMS=="usb"
    DRIVERS=="ftdi_sio"
    ATTRS{bInterfaceNumber}=="00"

  looking at parent device '/devices/pci0000:00/0000:00:14.0/usb1/1-1':
    KERNELS=="1-1"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{idVendor}=="0403"
    ATTRS{idProduct}=="6010"

预先感谢

推荐答案

这是我为双端口 FTDI 芯片创建别名时制定的规则:

This is rule I made to create an alias for dual port FTDI chip:

# Internal serial ports
SUBSYSTEMS=="usb", ATTRS{interface}=="Dual RS232", SYMLINK+="sertest%s{bInterfaceNumber}"

根据此帖子,属性必须在一个级别上匹配.这就是为什么 idVendor idProduct 无法与 bInterfaceNumber 一起使用的原因.下面你可以看到,interfacebInterfaceNumber 属于同一层:

According to this post the attributes must be matching on one level. That's why idVendor and idProduct won't work with bInterfaceNumber. Below you can see, that interface and bInterfaceNumber belong to the same level:

looking at parent device '/devices/platform/omap/musb-ti81xx/musb-hdrc.1/usb1/1-1/1-1.2/1-1.2:1.0':
KERNELS=="1-1.2:1.0"
SUBSYSTEMS=="usb"
DRIVERS=="ftdi_sio"
ATTRS{bInterfaceNumber}=="00"
ATTRS{bAlternateSetting}==" 0"
ATTRS{bNumEndpoints}=="02"
ATTRS{bInterfaceClass}=="ff"
ATTRS{bInterfaceSubClass}=="ff"
ATTRS{bInterfaceProtocol}=="ff"
ATTRS{supports_autosuspend}=="1"
ATTRS{interface}=="Dual RS232"

这篇关于UDEV-如何获取子设备属性的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆