Hi everyone.
I've been trying to connect to my 3g usb modem for some time, and now i have problems trying to have things started on boot.
basically, the procedure is like this:
start option which i compiled myself with a little modification to support the HUAWEI EC122 i am using
then,prepare the modem.
Code:
usb_modeswitch -v 12d1 -p 1505 -c /usr/share/usb_modeswitch/12d1:1505
after this several devices are made in /dev ,USB0,USB1and etc
Question1, these devices do not show up immediately after usb_modeswitch returns,but after several seconds. Why does this happen? Is the gap caused by option.ko not detecting the modem? Anyway, this makes it difficult to automate the whole procedure in a shell script,i have to use sleep until device are ready,which does not seem to be the right way.(maybe i need something like select() in c?,or should i load the module after modeswitching?)
next,connect using pppd.
Code:
pppd connect 'nohup chat -v "" "AT" "OK" "ATZ" "OK" "ATDT#777 CONNECT"' user card password card /dev/ttyUSB0 115200 nodetach noauth nocrtscts modem noipdefault debug usepeerdns defaultroute ipcp-accept-local noccp
it takes a couple seconds to connect, during which i can monitor the procedure on terminal.but after that,it does not return because it is running as a daemon.So it occupies a terminal.
to over come this ,i tried this
Code:
nohup pppd connect 'nohup chat -v "" "AT" "OK" "ATZ" "OK" "ATDT#777 CONNECT"' user card password card /dev/ttyUSB0 115200 nodetach noauth nocrtscts modem noipdefault debug usepeerdns defaultroute ipcp-accept-local noccp 2>&1 >/root/pppd.log </dev/null
and things work OK,but i have to type ENTER once before re prompt reappears.and here comes Question 2: i can not put it in a script because the following commands depend on network connecting which it has no way of knowing when is ready.Also, even after it is ready, the following commands can not be executed because pppd does not return. How to fix this?
finally, i need to run some other command(streaming video to a specific IP address)
----------------------------
this is the script i call in rc.local.
Code:
#!/bin/sh
modprobe option
echo "------------switching mode..."
usb_modeswitch -v 12d1 -p 1505 -c /usr/share/usb_modeswitch/12d1:1505
#wait for device to be ready, how to fix?
sleep 5
echo "modeswitch succeed!"
#this script sleeps for some time to wait for ppd's completion
/root/videostream.sh&
echo "--------------connecting via 3G..."
nohup pppd connect 'nohup chat -v "" "AT" "OK" "ATZ" "OK" "ATDT#777 CONNECT"' user card password card /dev/ttyUSB0 115200 nodetach noauth nocrtscts modem noipdefault debug usepeerdns defaultroute ipcp-accept-local noccp 2>&1 >/root/pppd.log </dev/null
# i think this is never reached
exit 0
this is a poor solution , and i still get problems afterwards.
in pppd.log, i discovered that the connecting procedure is killed by a mysterious SIGHUP. this is strange because 1nohup should block SIGHUP 2 nobody is sending the signal.
Question 3 who send the signal and how to fix it?
(may be SIGHUP is blocked for pppd, but isn't for 'chat -v' it calls?)
That's my problem, which may be confusing as a result of my inferior expression,but please help! any information that may help is also welcomed.