在ubuntu 13.04上,我为CDMA调制解调器编写的udev规则是
SUBSYSTEM=="tty", ATTRS{bInterfaceNumber}=="00", ATTRS{bNumEndpoints}=="03", ATTRS{product}=="ZTE CDMA Tech", ACTION=="add", SYMLINK+="CDMAModem"
和
$ sudo udevadm info -a -p $(sudo udevadm info -q path -n /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/ocp.2/47400000.usb/musb-hdrc.1.auto/usb1/1-1/1-1.4/1-1.4.3/1-1.4.3:1.0/ttyUSB0/tty/ttyUSB0':
KERNEL=="ttyUSB0"
SUBSYSTEM=="tty"
DRIVER==""
looking at parent device '/devices/ocp.2/47400000.usb/musb-hdrc.1.auto/usb1/1-1/1-1.4/1-1.4.3/1-1.4.3:1.0/ttyUSB0':
KERNELS=="ttyUSB0"
SUBSYSTEMS=="usb-serial"
DRIVERS=="option1"
ATTRS{port_number}=="0"
looking at parent device '/devices/ocp.2/47400000.usb/musb-hdrc.1.auto/usb1/1-1/1-1.4/1-1.4.3/1-1.4.3:1.0':
KERNELS=="1-1.4.3:1.0"
SUBSYSTEMS=="usb"
DRIVERS=="option"
ATTRS{bInterfaceClass}=="ff"
ATTRS{bInterfaceSubClass}=="ff"
ATTRS{bInterfaceProtocol}=="ff"
ATTRS{bNumEndpoints}=="03"
ATTRS{supports_autosuspend}=="1"
ATTRS{bAlternateSetting}==" 0"
ATTRS{bInterfaceNumber}=="00"
ATTRS{interface}=="Data Interface"
looking at parent device '/devices/ocp.2/47400000.usb/musb-hdrc.1.auto/usb1/1-1/1-1.4/1-1.4.3':
KERNELS=="1-1.4.3"
SUBSYSTEMS=="usb"
DRIVERS=="usb"
ATTRS{bDeviceSubClass}=="00"
ATTRS{bDeviceProtocol}=="00"
ATTRS{devpath}=="1.4.3"
ATTRS{idVendor}=="19d2"
ATTRS{speed}=="12"
ATTRS{bNumInterfaces}==" 6"
ATTRS{bConfigurationValue}=="1"
ATTRS{bMaxPacketSize0}=="64"
ATTRS{busnum}=="1"
ATTRS{devnum}=="10"
ATTRS{configuration}==""
ATTRS{bMaxPower}=="500mA"
ATTRS{authorized}=="1"
ATTRS{bmAttributes}=="a0"
ATTRS{bNumConfigurations}=="1"
ATTRS{maxchild}=="0"
ATTRS{bcdDevice}=="0000"
ATTRS{avoid_reset_quirk}=="1"
ATTRS{quirks}=="0x10"
ATTRS{version}==" 1.10"
ATTRS{urbnum}=="266"
ATTRS{ltm_capable}=="no"
ATTRS{manufacturer}=="ZTE, Incorporated"
ATTRS{removable}=="unknown"
ATTRS{idProduct}=="fff1"
ATTRS{bDeviceClass}=="00"
ATTRS{product}=="ZTE CDMA Tech"
looking at parent device '/devices/ocp.2/47400000.usb/musb-hdrc.1.auto/usb1/1-1/1-1.4':
KERNELS=="1-1.4"
SUBSYSTEMS=="usb"
DRIVERS=="usb"
ATTRS{bDeviceSubClass}=="00"
ATTRS{bDeviceProtocol}=="01"
ATTRS{devpath}=="1.4"
ATTRS{idVendor}=="05e3"
ATTRS{speed}=="480"
ATTRS{bNumInterfaces}==" 1"
ATTRS{bConfigurationValue}=="1"
ATTRS{bMaxPacketSize0}=="64"
ATTRS{busnum}=="1"
ATTRS{devnum}=="5"
ATTRS{configuration}==""
ATTRS{bMaxPower}=="100mA"
ATTRS{authorized}=="1"
ATTRS{bmAttributes}=="e0"
ATTRS{bNumConfigurations}=="1"
ATTRS{maxchild}=="4"
ATTRS{bcdDevice}=="7764"
ATTRS{avoid_reset_quirk}=="0"
ATTRS{quirks}=="0x0"
ATTRS{version}==" 2.00"
ATTRS{urbnum}=="116"
ATTRS{ltm_capable}=="no"
ATTRS{removable}=="unknown"
ATTRS{idProduct}=="0608"
ATTRS{bDeviceClass}=="09"
ATTRS{product}=="USB2.0 Hub"
looking at parent device '/devices/ocp.2/47400000.usb/musb-hdrc.1.auto/usb1/1-1':
KERNELS=="1-1"
SUBSYSTEMS=="usb"
DRIVERS=="usb"
ATTRS{bDeviceSubClass}=="00"
ATTRS{bDeviceProtocol}=="01"
ATTRS{devpath}=="1"
ATTRS{idVendor}=="05e3"
ATTRS{speed}=="480"
ATTRS{bNumInterfaces}==" 1"
ATTRS{bConfigurationValue}=="1"
ATTRS{bMaxPacketSize0}=="64"
ATTRS{busnum}=="1"
ATTRS{devnum}=="2"
ATTRS{configuration}==""
ATTRS{bMaxPower}=="100mA"
ATTRS{authorized}=="1"
ATTRS{bmAttributes}=="e0"
ATTRS{bNumConfigurations}=="1"
ATTRS{maxchild}=="4"
ATTRS{bcdDevice}=="7764"
ATTRS{avoid_reset_quirk}=="0"
ATTRS{quirks}=="0x0"
ATTRS{version}==" 2.00"
ATTRS{urbnum}=="67"
ATTRS{ltm_capable}=="no"
ATTRS{removable}=="unknown"
ATTRS{idProduct}=="0608"
ATTRS{bDeviceClass}=="09"
ATTRS{product}=="USB2.0 Hub"
looking at parent device '/devices/ocp.2/47400000.usb/musb-hdrc.1.auto/usb1':
KERNELS=="usb1"
SUBSYSTEMS=="usb"
DRIVERS=="usb"
ATTRS{bDeviceSubClass}=="00"
ATTRS{bDeviceProtocol}=="01"
ATTRS{devpath}=="0"
ATTRS{idVendor}=="1d6b"
ATTRS{speed}=="480"
ATTRS{bNumInterfaces}==" 1"
ATTRS{bConfigurationValue}=="1"
ATTRS{bMaxPacketSize0}=="64"
ATTRS{authorized_default}=="1"
ATTRS{busnum}=="1"
ATTRS{devnum}=="1"
ATTRS{configuration}==""
ATTRS{bMaxPower}==" 0mA"
ATTRS{authorized}=="1"
ATTRS{bmAttributes}=="e0"
ATTRS{bNumConfigurations}=="1"
ATTRS{maxchild}=="1"
ATTRS{bcdDevice}=="0308"
ATTRS{avoid_reset_quirk}=="0"
ATTRS{quirks}=="0x0"
ATTRS{serial}=="musb-hdrc.1.auto"
ATTRS{version}==" 2.00"
ATTRS{urbnum}=="28"
ATTRS{ltm_capable}=="no"
ATTRS{manufacturer}=="Linux 3.8.13-bone21 musb-hcd"
ATTRS{removable}=="unknown"
ATTRS{idProduct}=="0002"
ATTRS{bDeviceClass}=="09"
ATTRS{product}=="MUSB HDRC host driver"
looking at parent device '/devices/ocp.2/47400000.usb/musb-hdrc.1.auto':
KERNELS=="musb-hdrc.1.auto"
SUBSYSTEMS=="platform"
DRIVERS=="musb-hdrc"
ATTRS{mode}=="b_peripheral"
ATTRS{vbus}=="Vbus off, timeout 1100 msec"
looking at parent device '/devices/ocp.2/47400000.usb':
KERNELS=="47400000.usb"
SUBSYSTEMS=="platform"
DRIVERS=="musb-dsps"
looking at parent device '/devices/ocp.2':
KERNELS=="ocp.2"
SUBSYSTEMS=="platform"
DRIVERS==""
我哪里出错了?当我插入调制解调器时,我得不到/dev/CDMAModem
。我还尝试了NAME
而不是SYMLINK+
。 /dev/ttyUSB0
是我连接调制解调器时获得的设备文件。我也得到/dev/ttyUSB1,2,3,4
但他们没有回应AT命令。
stackoverflow说要添加更多细节,因为我的问题主要包含代码,所以我输入了这个。我找不到任何可以提供的详细信息。
答案 0 :(得分:1)
以下udev规则可以创建symlink
SUBSYSTEMS=="usb-serial", ACTION=="add", DRIVERS=="option1", SYMLINK+="CDMAModem%n"
SUBSYSTEMS=="usb-serial", ACTION=="remove", DRIVERS=="option1", SYMLINK-="CDMAModem%n"
$ ls /dev/CDMAModem*
/dev/CDMAModem0 /dev/CDMAModem1 /dev/CDMAModem2 /dev/CDMAModem3 /dev/CDMAModem4
我通过期望规则中评估的设备属性应该是同一设备节点来达到此规则。所以我只采用了一个节点/devices/ocp.2/47400000.usb/musb-hdrc.1.auto/usb1/1-1/1-1.4/1-1.4.3/1-1.4.3:1.0/ttyUSB0
的设备属性,我认为它是最好的节点,因为它是从顶部开始加载与调制解调器相对应的特定驱动程序的第一个设备节点(我不是肯定option1
是一个调制解调器驱动程序。我应该重新启动系统以使其工作。
现在我解决了问题,但我想要完全解决方案和理由。什么是option1
驱动程序?我严重怀疑上述规则可以在其他调制解调器中专门识别调制解调器。