1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Linksys WRTSL54GS on Tomato Firmware v1.27.8747 ND USB: Script Help Required

Discussion in 'Tomato Firmware' started by Aquafire, Jul 7, 2010.

  1. Aquafire

    Aquafire LI Guru Member

    Hello,

    Continuing the effort to trigger the power cycling shut down for the DSL modem via a router script as mentioned in my earlier post below.

    http://www.linksysinfo.org/forums/showpost.php?p=365239&postcount=13

    The power circuit socket board (with appropriate relay and transistor) is almost finished.

    Have read the original article in the earlier post (mentioned above) to make a shell script to control the GPIO pins of Linksys WRTSL54GS.

    This can be added to the Administration -> Scheduler section as a custom script to be triggered every minute to check the status of the internet connection.

    I have copied the script more or less as similar, and need some help in order to understand the commands used.

    As a sample I have tried to control the state of GPIO ping 5 (SES White Light), which I further plan to use ( to connect a transistor and relay to control state of modem power).

    The script runs correctly in the background as a cron job every minute. If the ping reply is not received from the mentioned IP address then the SES light (in the front of router) turns white and then stays this way.

    Note:
    As a default when the router starts the white light is off, but maybe the internal state of GPIO Pin 5 is enabled. So for commands

    I have the following queries and own understandings, please reply where much clarification / correction is needed :

    1. What are meanings of line no. 3 - 5

    2. If ping is active (DSL connection is up) reply received from the IP (66.102.7.104/www.google.com), then the avg response time would be greater than 1 and maybe nothing will happen. I don't know the meaning of GREP 100% command in line 3.

    3. If a ping is not received then it will disable GPIO pin 5 ( the white light turns on). What does the echo commands 1 and 0 means and why are they needed (they just add a 0 or 1 in a text file in the mentioned file in the JFFS partition).

    4. What does the sleep 1 command means and what sleep time does it denotes.

    5. I guess we manually have to control the state of the relay to switch OFF and then ON (to power cycle the DSL modem). But even in the original script and (of course in my copied version) there is only one command for GPIO disable 5 which can presumably turn OFF the relay to shut down power.

    How to turn the power back ON (maybe after a delay of 10 seconds). The status of script should be reset again to keep checking the connection for any subsequent connection failures to repeat the same procedure.

    6. The script is reporting the time/date of Modem failures in a text file (which maybe called in a router hosted web page to show log , with a custom button to manually reset the modem), as done by the original author.

    7. How can we also add the time/date of Modem Startup (after a failure) to the same text file.

    Anything else to improve the efficiency of the script.

    Thanks a lot for reading through and any possible guidance.
     
  2. karogyoker

    karogyoker Addicted to LI Member

    line 3: ping google.com one time and if loss is 100% then x variable will be the line which contains the 100%, else it will be a null string: ""

    imho it should be more than one time, like 3 times, and if all ping fails, then the WAN is down
     
  3. Aquafire

    Aquafire LI Guru Member

    Ok how shouid I write the code for the ping to be checked for 3 times. To be honest I dont know the command line syntax of linux.

    What is the meaning of Echo commands in the original script. Does the "Sleep 1" means a gap of 1 second between echo 0 and 1.

    The GPIO 5 has been enabled but not toggled in the original script (I copied the same).

    However now I think that the original script was for a Fonera router running DD-WRT and maybe the command GPIO enable 5 only binds to PIN 5 and then echo 0 and echo 1 changes the state of the pin to off and on.

    But the same command Tomato over linksys does not do anything similar, rather the command GPIO enable / disable itself does the same thing of toggling the pin state.

    So I guess i can write the command GPIO enable 5 after the sleep command to switch the pin ON again.

    Any further help is appreciated.
     
  4. karogyoker

    karogyoker Addicted to LI Member

    change ping -c1 to ping -c3 and it will ping 3 times

    sleep 1 is waits 1 second

    i have no idea what's the point of writing a 1 to a text file and then overwrite it to a 0 one second later

    what router are you using?
    in WRT54GL you can enable and disable the cisco button's light by using:
    led white on
    led white off
    led amber on
    led amber off

    amber is the orange light, you can enable white and orange in the same time

    in digital electronics state 1 disables a led, and state 0 light it up maybe this is why gpio disable 5 turns on the led
     

Share This Page