[plug] Automatic connect to net when mobile plugged in.

Mike Holland michael.holland at gmail.com
Mon Apr 7 08:50:47 WST 2008


Hi,
I wanted my Ubuntu laptop to just automatically get an internet connect 
when the 3G phone is connected via USB. Previously, it recognised the 
phone and created /dev/ttyACM0, so I just needed wvdial or pon.

   I'm vaguely aware that something called "udev" is running the 
devices, but rather than RTFM, I just looked for an example to copy.
   Found   /etc/udev/rules.d  and created a file

  88-blah.rules :
	SYSFS{idVendor}=="0421", SYSFS{idProduct}=="002f", RUN+="/usr/bin/pon 
three"


So mapping the USB-ID from my particular phone to the pon command to 
start a PPP session.
But it works too well and launches more than a dozen sessions.


Apr  7 08:30:34 tamar kernel: [ 4986.804625] usb 1-1: new full speed USB 
device using uhci_hcd and address 49
Apr  7 08:30:34 tamar kernel: [ 4987.041347] usb 1-1: configuration #1 
chosen from 1 choice
Apr  7 08:30:34 tamar kernel: [ 4987.051390] cdc_acm 1-1:1.8: ttyACM0: 
USB ACM device
Apr  7 08:30:34 tamar kernel: [ 4987.059234] rndis_host: probe of 
1-1:1.10 failed with error -32
Apr  7 08:30:34 tamar pppd[9306]: pppd 2.4.4 started by root, uid 0
Apr  7 08:30:35 tamar pppd[9323]: pppd 2.4.4 started by root, uid 0
Apr  7 08:30:35 tamar pppd[9323]: Device ttyACM0 is locked by pid 9306
Apr  7 08:30:35 tamar pppd[9323]: Exit.
Apr  7 08:30:35 tamar pppd[9327]: pppd 2.4.4 started by root, uid 0
Apr  7 08:30:35 tamar pppd[9327]: Device ttyACM0 is locked by pid 9306
Apr  7 08:30:35 tamar pppd[9327]: Exit.
Apr  7 08:30:35 tamar pppd[9330]: pppd 2.4.4 started by root, uid 0
Apr  7 08:30:35 tamar pppd[9330]: Device ttyACM0 is locked by pid 9306
Apr  7 08:30:35 tamar pppd[9330]: Exit.
...

Thanks to locking, the first pppd succeeds. But some questions:
Is udev the correct way to do this?
  and how can I make it trigger only once?

regards, Mike




More information about the plug mailing list