2

在我的 linux 机器上(uname -a Linux gate 3.2.0-0.bpo.2-amd64 #1 SMP Fri Jun 29 20:42:29 UTC 2012 x86_64 GNU/Linux)我有 USB 调制解调器 WeTelecom WM-D300有“zeroCD”选项。ZeroCD USB id 为 22de:6803,调制解调器设备的 USB id 为 22de:6801。我已经为它创建了 usb_modeswitch 规则并测试了这个规则运行良好:

Aug 11 23:03:14 gate kernel: [  609.832373] usb 1-1: usbfs: process 6081 (usb_modeswitch) did not claim interface 0 before use                  
Aug 11 23:03:14 gate kernel: [  609.949352] usb 1-1: USB disconnect, device number 2                                                            
Aug 11 23:03:15 gate kernel: [  610.596344] usb 1-1: new high-speed USB device number 5 using ehci_hcd                                          
Aug 11 23:03:15 gate kernel: [  610.759964] usb 1-1: New USB device found, idVendor=22de, idProduct=6801                                        
Aug 11 23:03:15 gate kernel: [  610.759978] usb 1-1: New USB device strings: Mfr=3, Product=2, SerialNumber=0                                   
Aug 11 23:03:15 gate kernel: [  610.759987] usb 1-1: Product: Wetelecom Mobile Products                                                         
Aug 11 23:03:15 gate kernel: [  610.759994] usb 1-1: Manufacturer: WeTelecom Incorporated                                                       
Aug 11 23:03:16 gate kernel: [  611.820404] option 1-1:1.0: GSM modem (1-port) converter detected                                               
Aug 11 23:03:16 gate kernel: [  611.820760] usb 1-1: GSM modem (1-port) converter now attached to ttyUSB3                                       
Aug 11 23:03:16 gate kernel: [  611.820876] option 1-1:1.1: GSM modem (1-port) converter detected                                               
Aug 11 23:03:16 gate kernel: [  611.821095] usb 1-1: GSM modem (1-port) converter now attached to ttyUSB4                                       
Aug 11 23:03:16 gate kernel: [  611.821204] option 1-1:1.2: GSM modem (1-port) converter detected                                               
Aug 11 23:03:16 gate kernel: [  611.821418] usb 1-1: GSM modem (1-port) converter now attached to ttyUSB5

所以,我做了一个小的 udev 配置来允许这个设备的自动热插拔:

ACTION!="add|change", GOTO="modem_rules_end"                                                                                                    
SUBSYSTEM!="usb", GOTO="modem_rules_end"

LABEL="modem_rules_begin"                                                                                                                 

# WeTelecom WM-D300                                                                                                                             
ATTRS{idVendor}=="22de", ATTRS{idProduct}=="6803", RUN+="usb_modeswitch '%b/%k'"                                                                
LABEL="modem_rules_end"

它不工作。重新连接调制解调器后,它变得完全不可用。usb-devices 显示它具有 usbfs 驱动程序,并且 usb_modeswitch 即使从命令行也无法切换它。udev 也无法切换,但重新启动后它工作得很好 - 直到下一次物理重新连接。这是我插入调制解调器时的 udev 日志:

Aug 11 22:42:11 gate logger: usb_modeswitch: using overriding config file /etc/usb_modeswitch.d/22de:6803; make sure this is intended           
Aug 11 22:42:11 gate logger: usb_modeswitch: please report any new or corrected settings; otherwise, check for outdated files                   
Aug 11 22:42:11 gate logger: usb_modeswitch: using overriding config file /etc/usb_modeswitch.d/22de:6803; make sure this is intended           
Aug 11 22:42:11 gate logger: usb_modeswitch: please report any new or corrected settings; otherwise, check for outdated files                   
Aug 11 22:42:11 gate usb_modeswitch: switching device 22de:6803 on 001/006                                                                      
Aug 11 22:42:11 gate usb_modeswitch: switching device 22de:6803 on 001/006                                                                      
Aug 11 22:42:11 gate kernel: [ 1495.864235] usb 1-1: usbfs: process 8485 (usb_modeswitch) did not claim interface 0 before use                  
Aug 11 22:42:11 gate kernel: [ 1495.864309] usb 1-1: usbfs: process 8485 (usb_modeswitch) did not claim interface 0 before use                  
Aug 11 22:42:16 gate logger: usb_modeswitch: switched to 22de:6803 on 001/006            
Aug 11 22:42:19 gate logger: usb_modeswitch: switched to 22de:6803 on 001/006  

所以,我的问题是:为什么以及如何?为什么它从命令行工作以及如何通过 udev 使其工作?请帮忙。提前谢谢!

4

0 回答 0