Activation Codes and Methods, Hardware Details, Sniffing
CCTU
Posts: 14
Joined: 02 Jun 2010, 14:23

Post by CCTU » 07 Jul 2010, 19:25

Thanks for your suggestion.
But it still not work.

I do some test below.

test1.
I add "exec /usr/local/startdial.sh $symlinkName & "
in /lib/udev/usb_modeswitch line 617(before "return $symlinkName").
But this action will cause /dev/gsmmodem not be created.

Is it because of that exec will create new process and replace current process?
So current script could not return "gsmmodem" to udev?

test2.
I create a shell script /home/alextu/temp/test2.sh.
"
#!/bin/bash

for i in $(seq 1 100)
do
echo "test2...." > /home/alextu/temp/testlog
sleep 1
done
"
Then I add "/home/alextu/temp/test2.sh &" in line 617.
Then replug-in C170, but /dev/gsmmodem still not be created.
Normally test2.sh should fork a new process and run in background.
I don't understand this situation.....

And could you teach me how to debug in usb_modeswitch script,please?
I try to modify "set logging 1" in line 27, but it not work.
And this action will casuse /dev/gsmmodem not be created, too.


Josh
Site Admin
Posts: 6570
Joined: 03 Nov 2007, 00:30

Post by Josh » 07 Jul 2010, 19:52

First, you might want to try version 1.1.3 and data version 20100623; the C170 is included now.
CCTU wrote:test1.
I add "exec /usr/local/startdial.sh $symlinkName & "
in /lib/udev/usb_modeswitch line 617(before "return $symlinkName").
But this action will cause /dev/gsmmodem not be created.
You must make sure that line executes without any error; you won't get any error feedback from udev if the script fails.
I recommend to feed the command to the tcl shell by running "tclsh" and then pasting the line on the prompt:

Code: Select all

% exec /usr/local/startdial.sh ttyUSB0 & 
This will test if the path is OK and the script starts executing.
CCTU wrote:And could you teach me how to debug in usb_modeswitch script, please?
I try to modify "set logging 1" in line 27, but it not work.
A look onto the usb_modeswitch documentation page would help a great deal. See "Troubleshooting".

Last edited by Josh on 10 Jul 2010, 19:52, edited 1 time in total.

CCTU
Posts: 14
Joined: 02 Jun 2010, 14:23

Post by CCTU » 09 Jul 2010, 20:04

I tested my script in tclsh and it is ok.
This is the script file.
http://dl.dropbox.com/u/2495108/startdial.sh

This is the log.
"
alextu@alextu-nb:/usr/bin$ sudo tclsh
% exec ./startdial.sh ttyUSB3 &
5421
% --> WvDial: Internet dialer version 1.60
--> Cannot get information for serial port.
--> Initializing modem.
--> Sending: AT+CGDCONT=1,"ip","internet"
AT+CGDCONT=1,"ip","internet"
OK
--> Sending: ATZ
ATZ
OK
--> Sending: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
OK
--> Sending: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
OK
--> Modem initialized.
--> Sending: ATDT*99***#
--> Waiting for carrier.
ATDT*99***#
CONNECT
--> Carrier detected. Starting PPP immediately.
--> Starting pppd at Sat Jul 10 01:00:18 2010
--> Pid of pppd: 5425
--> Using interface ppp0
--> local IP address 112.78.70.226
--> remote IP address 202.144.208.130
--> primary DNS address 168.95.1.1
--> secondary DNS address 168.95.192.1
"
But when I add a line

Code: Select all

exec /usr/bin/startdial.sh $symlinkName &
to /lib/udev/usb_modeswitch before

Code: Select all

return $symlinkName
, gsmmodem will never created.
This is the file I modified.
http://dl.dropbox.com/u/2495108/usb_modeswitch_modified
This is the logfile created by startdial.sh.
"
alextu@alextu-nb:~/scripts$ tail -f diallog
dial up on /dev/gsmmodem......
/dev/gsmmodem does not exist....
/dev/gsmmodem does not exist....
/dev/gsmmodem does not exist....
/dev/gsmmodem does not exist....
/dev/gsmmodem does not exist....
/dev/gsmmodem does not exist....
/dev/gsmmodem does not exist....
/dev/gsmmodem does not exist....
"
I think this is because of "exec" will replace the current process(/lib/udev/usb_modeswitch),
so usb_modeswitch could not
return $symlinkName(gsmmodem) to /lib/udev/rules.d/40-usb_modeswitch.rules line 11

Code: Select all

KERNEL=="ttyUSB*", PROGRAM="/usr/bin/tclsh /lib/udev/usb_modeswitch symlink name %p", SYMLINK="%c"
.
The infomation is in "Example 15-24. Effects of exec" in http://tldp.org/LDP/abs/html/internal.html#EX54
It says
"exec,this shell builtin replaces the current process with a specified command."
I have no idea about how to avoid blocking original script(usb_modeswitch).

Could you help me again, please?


Josh
Site Admin
Posts: 6570
Joined: 03 Nov 2007, 00:30

Post by Josh » 11 Jul 2010, 10:17

The "exec" command in Tcl is different from the Bash command with the same name. In Tcl you always need it to launch any external program, script or no script. And the "&" operator makes the execution independent from the calling script, it will not be blocked.

I can see no real error in your modifications. One thing worth trying is to explicitly add the interpreting program for the script:

Code: Select all

exec /bin/sh /usr/bin/startdial.sh $symlinkName &

CCTU
Posts: 14
Joined: 02 Jun 2010, 14:23

Post by CCTU » 11 Jul 2010, 14:07

The same situation,it still not create gsmmodem in /dev after I add

Code: Select all

exec /bin/sh /usr/bin/startdial.sh $symlinkName &
in /lib/udev/usb_modeswitch line 618.

Then after I kill the process
root 2867 1 0 20:03 ? 00:00:00 /bin/sh /usr/bin/startdial.sh gsmmodem
/dev/gsmmodem created!!

So I think usb_modeswitch is blocked by my script.

Could it work on your side?
Josh wrote:The "exec" command in Tcl is different from the Bash command with the same name. In Tcl you always need it to launch any external program, script or no script. And the "&" operator makes the execution independent from the calling script, it will not be blocked.

I can see no real error in your modifications. One thing worth trying is to explicitly add the interpreting program for the script:

Code: Select all

exec /bin/sh /usr/bin/startdial.sh $symlinkName &

CCTU
Posts: 14
Joined: 02 Jun 2010, 14:23

Post by CCTU » 05 Aug 2010, 17:55

Excuse me, is there someone meet the same situation like me?
If someone could auto dial to 3.5G by this usb_modeswitch utility?
CCTU wrote:The same situation,it still not create gsmmodem in /dev after I add

Code: Select all

exec /bin/sh /usr/bin/startdial.sh $symlinkName &
in /lib/udev/usb_modeswitch line 618.

Then after I kill the process
root 2867 1 0 20:03 ? 00:00:00 /bin/sh /usr/bin/startdial.sh gsmmodem
/dev/gsmmodem created!!

So I think usb_modeswitch is blocked by my script.

Could it work on your side?
Josh wrote:The "exec" command in Tcl is different from the Bash command with the same name. In Tcl you always need it to launch any external program, script or no script. And the "&" operator makes the execution independent from the calling script, it will not be blocked.

I can see no real error in your modifications. One thing worth trying is to explicitly add the interpreting program for the script:

Code: Select all

exec /bin/sh /usr/bin/startdial.sh $symlinkName &

Josh
Site Admin
Posts: 6570
Joined: 03 Nov 2007, 00:30

Post by Josh » 10 Aug 2010, 15:16

I think the best solution for automatic dialing is to use the Sakis3g package (ask Google). It has usb_modeswitch built in. There was a video which showed the automatic handling from plugging to dialing.

CCTU
Posts: 14
Joined: 02 Jun 2010, 14:23

Post by CCTU » 11 Aug 2010, 08:08

Thanks for your response.
It's really a great tip~
:D
Josh wrote:I think the best solution for automatic dialing is to use the Sakis3g package (ask Google). It has usb_modeswitch built in. There was a video which showed the automatic handling from plugging to dialing.

Post Reply