How to read gpio button status in shell script ?

Discussion in 'General Discussion' started by Nalinux, Sep 16, 2018.

  1. Nalinux

    Nalinux New Member Member

    Hello all !
    I have a stupid problem. The routeur I use is a Belkin N600 DB f9k1102v1 , running "Tomato Version 1.28 by shibby".
    I know it's an old version, but it's not my main routeur, and not even sure a more recent Tomato version would run on it :)
    Here's my (simple) problem.
    I plan to use it for electronic experiments. I want to use the buttons status to activate a device I will plug in parallel with the leds.
    I can activate / desactivate leds with gpio enable/disable, and can also see when I press a button with gpio poll. So the goal is to use an external captor, plug it in // with a button, and activate a relay with a transistor in // with the led. Basic stuff.
    There's an option with the web interface "Administration -- Buttons/LED", but it doesn't work I'm not sure the firmware I use is for this exact routeur model, and don't remember where I got it :)

    root@belkin:/tmp/home/root# gpio poll
    Enable gpio mask: 0x0000
    60F03EAF 0123.5.7.9ABCD..
    60F03EAF 0123.5.7.9ABCD..
    60F03EA7 012..5.7.9ABCD.. <--button reset pressed
    60F03EAF 0123.5.7.9ABCD..
    60F03E2F 0123.5...9ABCD.. <--button wds pressed
    60F03EAF 0123.5.7.9ABCD..
    I'm not so good for programming, and don't manage to get those changes with a shell script. I've tried without success :
    - gpio poll | grep 7 --> blank output
    - gpio poll >> status.log& --> empty file
    - export STATUS=`gpio poll`&; echo $STATUS --> blank $STATUS

    What's the trick ?
    I also couldn't find documentation about /sbin/gpio and /sbin/buttons/ relative to Tomato.
    Thanks a lot.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice