Raspberry pi上的Udev规则未触发

问题描述 投票:0回答:1

仅出于上下文考虑:我目前尝试检测被插入Raspbian上运行的树莓派的Huawei USB调制解调器,并使用udev规则自动将设备作为输入启动服务。

我目前正处于起步阶段,尝试仅触发此摇杆的udev规则(已通过usb-modeswitch切换到调制解调器模式:]

Bus 001 Device 008: ID 12d1:1001 Huawei Technologies Co., Ltd. E161/E169/E620/E800 HSDPA Modem

我尝试了以下三个规则,所有这些规则显然都没有触发:

SUBSYSTEMS=="usb", ATTRS{idVendor}=="12d1', ATRRS{idProduct}=="1001", RUN+="touch /home/pi/test"

SUBSYSTEM=="usb", ATTRS{idVendor}=="12d1', ATRRS{idProduct}=="1001", RUN+="touch /home/pi/test"

ATTRS{idVendor}=="12d1', ATRRS{idProduct}=="1001", RUN+="touch /home/pi/test"

pi的输出:

pi@raspberrypi:~ $ udevadm info --attribute-walk --name /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/platform/soc/3f980000.usb/usb1/1-1/1-1.1/1-1.1.2/1-1.1.2:1.0/ttyUSB0/tty/ttyUSB0':
    KERNEL=="ttyUSB0"
    SUBSYSTEM=="tty"
    DRIVER==""

  looking at parent device '/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.1/1-1.1.2/1-1.1.2:1.0/ttyUSB0':
    KERNELS=="ttyUSB0"
    SUBSYSTEMS=="usb-serial"
    DRIVERS=="option1"
    ATTRS{port_number}=="0"

  looking at parent device '/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.1/1-1.1.2/1-1.1.2:1.0':
    KERNELS=="1-1.1.2:1.0"
    SUBSYSTEMS=="usb"
    DRIVERS=="option"
    ATTRS{supports_autosuspend}=="1"
    ATTRS{bInterfaceProtocol}=="ff"
    ATTRS{authorized}=="1"
    ATTRS{bInterfaceNumber}=="00"
    ATTRS{bInterfaceSubClass}=="ff"
    ATTRS{bInterfaceClass}=="ff"
    ATTRS{bAlternateSetting}==" 0"
    ATTRS{bNumEndpoints}=="03"

  looking at parent device '/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.1/1-1.1.2':
    KERNELS=="1-1.1.2"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{manufacturer}=="HUAWEI"
    ATTRS{urbnum}=="13"
    ATTRS{bMaxPacketSize0}=="64"
    ATTRS{devspec}=="  (null)"
    ATTRS{ltm_capable}=="no"
    ATTRS{speed}=="480"
    ATTRS{tx_lanes}=="1"
    ATTRS{bDeviceClass}=="00"
    ATTRS{idVendor}=="12d1"
    ATTRS{bNumInterfaces}==" 3"
    ATTRS{devnum}=="8"
    ATTRS{configuration}==""
    ATTRS{busnum}=="1"
    ATTRS{removable}=="removable"
    ATTRS{quirks}=="0x10"
    ATTRS{bmAttributes}=="80"
    ATTRS{rx_lanes}=="1"
    ATTRS{version}==" 2.00"
    ATTRS{avoid_reset_quirk}=="1"
    ATTRS{maxchild}=="0"
    ATTRS{bMaxPower}=="500mA"
    ATTRS{idProduct}=="1001"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{authorized}=="1"
    ATTRS{bDeviceProtocol}=="00"
    ATTRS{bcdDevice}=="0102"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{product}=="HUAWEI Mobile"
    ATTRS{devpath}=="1.1.2"
    ATTRS{bDeviceSubClass}=="00"

  looking at parent device '/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.1':
    KERNELS=="1-1.1"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{avoid_reset_quirk}=="0"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{removable}=="fixed"
    ATTRS{bMaxPower}=="2mA"
    ATTRS{busnum}=="1"
    ATTRS{bcdDevice}=="0bb3"
    ATTRS{idProduct}=="2514"
    ATTRS{bmAttributes}=="e0"
    ATTRS{version}==" 2.00"
    ATTRS{tx_lanes}=="1"
    ATTRS{configuration}==""
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{devnum}=="3"
    ATTRS{ltm_capable}=="no"
    ATTRS{bDeviceProtocol}=="02"
    ATTRS{authorized}=="1"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{bMaxPacketSize0}=="64"
    ATTRS{rx_lanes}=="1"
    ATTRS{urbnum}=="90"
    ATTRS{bDeviceClass}=="09"
    ATTRS{idVendor}=="0424"
    ATTRS{quirks}=="0x0"
    ATTRS{maxchild}=="3"
    ATTRS{devpath}=="1.1"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{speed}=="480"

  looking at parent device '/devices/platform/soc/3f980000.usb/usb1/1-1':
    KERNELS=="1-1"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{removable}=="unknown"
    ATTRS{bcdDevice}=="0bb3"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{bMaxPacketSize0}=="64"
    ATTRS{version}==" 2.00"
    ATTRS{bMaxPower}=="2mA"
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{configuration}==""
    ATTRS{idProduct}=="2514"
    ATTRS{avoid_reset_quirk}=="0"
    ATTRS{urbnum}=="69"
    ATTRS{rx_lanes}=="1"
    ATTRS{speed}=="480"
    ATTRS{busnum}=="1"
    ATTRS{bmAttributes}=="e0"
    ATTRS{bDeviceClass}=="09"
    ATTRS{tx_lanes}=="1"
    ATTRS{devpath}=="1"
    ATTRS{quirks}=="0x0"
    ATTRS{ltm_capable}=="no"
    ATTRS{maxchild}=="4"
    ATTRS{authorized}=="1"
    ATTRS{idVendor}=="0424"
    ATTRS{devnum}=="2"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{bDeviceProtocol}=="02"
    ATTRS{bNumConfigurations}=="1"

  looking at parent device '/devices/platform/soc/3f980000.usb/usb1':
    KERNELS=="usb1"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{busnum}=="1"
    ATTRS{idVendor}=="1d6b"
    ATTRS{authorized}=="1"
    ATTRS{bmAttributes}=="e0"
    ATTRS{speed}=="480"
    ATTRS{version}==" 2.00"
    ATTRS{idProduct}=="0002"
    ATTRS{avoid_reset_quirk}=="0"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{removable}=="unknown"
    ATTRS{bMaxPower}=="0mA"
    ATTRS{devnum}=="1"
    ATTRS{maxchild}=="1"
    ATTRS{rx_lanes}=="1"
    ATTRS{manufacturer}=="Linux 4.19.66-v7+ dwc_otg_hcd"
    ATTRS{devpath}=="0"
    ATTRS{product}=="DWC OTG Controller"
    ATTRS{tx_lanes}=="1"
    ATTRS{bcdDevice}=="0419"
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{authorized_default}=="1"
    ATTRS{serial}=="3f980000.usb"
    ATTRS{quirks}=="0x0"
    ATTRS{configuration}==""
    ATTRS{bDeviceProtocol}=="01"
    ATTRS{urbnum}=="30"
    ATTRS{bMaxPacketSize0}=="64"
    ATTRS{bDeviceClass}=="09"
    ATTRS{interface_authorized_default}=="1"
    ATTRS{ltm_capable}=="no"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{bNumConfigurations}=="1"

  looking at parent device '/devices/platform/soc/3f980000.usb':
    KERNELS=="3f980000.usb"
    SUBSYSTEMS=="platform"
    DRIVERS=="dwc_otg"
    ATTRS{spramdump}=="SPRAM Dump"
    ATTRS{wr_reg_test}=="Time to write GNPTXFSIZ reg 10000000 times: 320 msecs (32 jiffies)"
    ATTRS{driver_override}=="(null)"
    ATTRS{regdump}=="Register Dump"
    ATTRS{inv_sel_hsic}=="Invert Select HSIC = 0x0"
    ATTRS{srpcapable}=="SRPCapable = 0x1"
    ATTRS{regoffset}=="0xffffffff"
    ATTRS{hcd_frrem}=="HCD Dump Frame Remaining"
    ATTRS{gnptxfsiz}=="GNPTXFSIZ = 0x01000306"
    ATTRS{gusbcfg}=="GUSBCFG = 0x20001700"
    ATTRS{hnp}=="HstNegScs = 0x0"
    ATTRS{gotgctl}=="GOTGCTL = 0x001c0000"
    ATTRS{srp}=="SesReqScs = 0x0"
    ATTRS{fr_interval}=="Frame Interval = 0x1d4b"
    ATTRS{hptxfsiz}=="HPTXFSIZ = 0x02000406"
    ATTRS{guid}=="GUID = 0x2708a000"
    ATTRS{hprt0}=="HPRT0 = 0x00001005"
    ATTRS{ggpio}=="GGPIO = 0x00000000"
    ATTRS{hnpcapable}=="HNPCapable = 0x1"
    ATTRS{buspower}=="Bus Power = 0x1"
    ATTRS{hcddump}=="HCD Dump"
    ATTRS{bussuspend}=="Bus Suspend = 0x0"
    ATTRS{regvalue}=="invalid offset"
    ATTRS{busconnected}=="Bus Connected = 0x1"
    ATTRS{hsic_connect}=="HSIC Connect = 0x1"
    ATTRS{mode_ch_tim_en}=="Mode Change Ready Timer Enable = 0x0"
    ATTRS{enumspeed}=="Device Enumeration Speed = 0x1"
    ATTRS{gpvndctl}=="GPVNDCTL = 0x00000000"
    ATTRS{rd_reg_test}=="Time to read GNPTXFSIZ reg 10000000 times: 890 msecs (89 jiffies)"
    ATTRS{gsnpsid}=="GSNPSID = 0x4f54280a"
    ATTRS{remote_wakeup}=="Remote Wakeup Sig = 0 Enabled = 0 LPM Remote Wakeup = 0"
    ATTRS{rem_wakeup_pwrdn}==""
    ATTRS{mode}=="Mode = 0x1"
    ATTRS{devspeed}=="Device Speed = 0x0"
    ATTRS{grxfsiz}=="GRXFSIZ = 0x00000306"

  looking at parent device '/devices/platform/soc':
    KERNELS=="soc"
    SUBSYSTEMS=="platform"
    DRIVERS==""
    ATTRS{driver_override}=="(null)"

  looking at parent device '/devices/platform':
    KERNELS=="platform"
    SUBSYSTEMS==""
    DRIVERS==""

即使在谷歌搜索时,udev上的资源似乎也非常有限。也许它还没有为我点击,但是我似乎迷路了。请发送帮助!

linux raspberry-pi usb raspbian udev
1个回答
0
投票

udev触发您的规则,但它不知道触摸的是什么。

您应该使用脚本的完整路径,即:/ usr / bin / touch

SUBSYSTEMS=="usb", ATTRS{idVendor}=="12d1', ATRRS{idProduct}=="1001", RUN+="/usr/bin/touch /home/pi/test"

如果未为脚本指定绝对路径,则udev在/ lib / udev文件夹中查找应用程序/脚本。

© www.soinside.com 2019 - 2024. All rights reserved.