<div dir="ltr"><div><div><div>Thanks for the reply.<br><br>I have change the script as below:<br><br>#!/bin/sh /etc/rc.common<br><br>START=19<br>start() {        <br>        echo in > /sys/class/gpio/gpio16/direction 2> /dev/null       <br>        echo 16 > /sys/class/gpio/export 2> /dev/null<br>        if [ "$(cat /sys/class/gpio/gpio16/value)" == "1" ] ; then<br>            echo "255" > /sys/devices/platform/leds-gpio/leds/db120:green:status/brightness     <br>        else<br>            echo "0" > /sys/devices/platform/leds-gpio/leds/db120:green:status/brightness     <br>        fi<br>}<br><br></div>I need to monitor the LED on/off all the time during runtime. <br><br></div>During start of this script its working, but not getting how to make it work run time. <br><br></div>Could you please explain how i can do it in gpio-button.</div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Oct 16, 2015 at 3:38 AM, Hartmut Knaack <span dir="ltr"><<a href="mailto:knaack.h@gmx.de" target="_blank">knaack.h@gmx.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">Afkar Rafique schrieb am 15.10.2015 um 04:07:<br>
> Thanks for the reply.<br>
><br>
> i have Create /etc/init.d/buttons and written below script:<br>
><br>
> #!/bin/sh /etc/rc.common<br>
> START=19<br>
> start() {<br>
>         /bin/umount /etc/config 2>/dev/null<br>
>         echo out > /sys/class/gpio/gpio16/direction 2> /dev/null<br>
>         echo 16 > /sys/class/gpio/export 2> /dev/null<br>
>         if [ "$(cat /sys/class/gpio/gpio16/value)" == "1" ] ; then<br>
>             echo "255" > /sys/devices/platform/leds-gpio/leds/db120:green:status/brightness<br>
>         else<br>
>             echo "0" > /sys/devices/platform/leds-gpio/leds/db120:green:status/brightness<br>
>         fi<br>
> }<br>
><br>
> and restart .<br>
><br>
> chmod +x /etc/init.d/buttons<br>
> /etc/init.d/buttons enable<br>
> /etc/init.d/buttons start<br>
><br>
> Now i am able to read the GPIO 16 value 1/0 based on GPIO state, but as above script i have written to ON/OFF the Status LED based on GPIO value, Status LED is not getting OFF even if GPIO16 value is "0".<br>
><br>
> Can anyone please help on this<br>
><br>
<br>
</span>Quite a mess you've got there. No idea why you need to umount /etc/config,<br>
but anyway: First thing in GPIO setup is exporting, then you set its direction.<br>
If you intend to read the GPIO status, then better use "in" as direction.<br>
Now, do you just want to do an action (LED on/off) just during start of this<br>
script, or all the time during runtime, when the GPIO status changes? In the<br>
latter case, you should look into gpio-button.<br>
<br>
><br>
><br>
> On Thu, Oct 15, 2015 at 12:37 AM, Martin Blumenstingl <<a href="mailto:martin.blumenstingl@googlemail.com">martin.blumenstingl@googlemail.com</a> <mailto:<a href="mailto:martin.blumenstingl@googlemail.com">martin.blumenstingl@googlemail.com</a>>> wrote:<br>
<span class="im HOEnZb">><br>
>     On Wed, Oct 14, 2015 at 12:19 PM, Afkar Rafique <<a href="mailto:afkar.ec@gmail.com">afkar.ec@gmail.com</a> <mailto:<a href="mailto:afkar.ec@gmail.com">afkar.ec@gmail.com</a>>> wrote:<br>
>     > Could anyone please explain how i can configure and read GPIO value.<br>
>     There's an article on the wiki which explains how to set a GPIO to a<br>
>     specific value: [0]<br>
>     If you want to read a GPIO value then you use direction "in" and then<br>
>     simply cat to read the "value".<br>
><br>
>     The only thing that you might have to do is doing a bit of maths to<br>
>     get the correct GPIO number.<br>
>     When you are trying to read GPIO #16 then it's GPIO #16 of a specific<br>
>     chip -> /sys/class/gpio/ should contain a file gpiochipNNN.<br>
>     What you do is take NNN (let's assume it's 456) and add your GPIO<br>
>     number to it: 456 + 16 = 472 -> this is the number needef to "export"<br>
>     the GPIO.<br>
><br>
><br>
>     [0] <a href="http://wiki.openwrt.org/doc/hardware/port.gpio#software" rel="noreferrer" target="_blank">http://wiki.openwrt.org/doc/hardware/port.gpio#software</a><br>
><br>
><br>
><br>
><br>
</span><div class="HOEnZb"><div class="h5">> _______________________________________________<br>
> openwrt-devel mailing list<br>
> <a href="mailto:openwrt-devel@lists.openwrt.org">openwrt-devel@lists.openwrt.org</a><br>
> <a href="https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel" rel="noreferrer" target="_blank">https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel</a><br>
><br>
<br>
</div></div></blockquote></div><br></div>