How I made script for action by pressing a button.

Post new topic   Reply to topic    DD-WRT Forum Forum Index -> Contributions Upload
Author Message
strelok-ac
DD-WRT Novice


Joined: 04 Aug 2011
Posts: 2

PostPosted: Thu Aug 04, 2011 12:30    Post subject: How I made script for action by pressing a button. Reply with quote
Intro:
I need make script for USB-Drive mount led indication and unmount drive by pressing button. So i find this page: and read it. But the way about unmount by button that I’m find at this page not work for me, because by pressing any button just no action. On my router have 2 programmable buttons+1reset+poweroff, and i want have different action on it Sad . So I spend 6hours and at finally find some simple way to resolve my problem! Very Happy

What going not right?
I don’t know why "myscript.sesbutton" script not working, i put it at
Quote:
/jffs/etc/config/
folder and correct permission to executable with command
Quote:
chmod +x /jffs/etc/config/myscript.sesbutton

but in my situation this way is not right because i need action for fixed button. So i find other way at this site.

Let's begin!

1.Find GPIO's
Enable Telnet Management at Administration=>Management
At first we need find address of our programmable button (GPIO), so open terminal(for example putty), login, and detect button address with command:
Quote:
gpio poll /number/

(try numbers from 0 to 8 for example(how many gpio's have your router can find at Google)).

And press the button, if address is right, you will see this for example:
Quote:
gpio poll 7
01
00
01
00
01

if not right, just:
Quote:
gpio poll 7
01

Terminate this command by pressing Ctrl+C.

My gpio's is:
Quote:
wlan button gpio 4
wps button gpio 7

And better detect your led, how-too?

2. Turn on jffs, share /jffs volume(for example by ftp)

3.Install patched gpio program
Download the package archive at attach, put "gpio" program to some directory for example:
Quote:
/opt/sbin/

and correct permission with command at terminal:
Quote:
chmod +x /jffs/opt/sbin/gpio

Why? DDWR already have build-in gpio?
Because build-in gpio i cannot use with code:
Quote:
$gpio poll $button | while read value;do

build-in just freeze and cannot output anything.

4.The script
Extract scripts from attach, correct it for your gpio’s, for example:
At unmount.startup:
Quote:

#!/bin/sh
mp="/`nvram get usb_mntpoint`"
proftpd_enable="`nvram get proftpd_enable`"
smbd_enable="`nvram get samba3_enable`"
gpio=/jffs/opt/sbin/gpio
button=7

correct your button gpio at button=7 string;
At mounted_status.startup:
Quote:

#!/bin/sh
mp="/`nvram get usb_mntpoint`"
RED_ON='gpio disable 3'
RED_OFF='gpio enable 3'

Correct 'gpio disable 3' and 'gpio enable 3' to your led’s gpio,
Save it and put at:
Quote:
/etc/config/

Correct permissions with command at terminal:
Quote:
chmod +x /jffs/etc/config/mounted_status.startup

Quote:
chmod +x /jffs/etc/config/unmount.startup

Go to router's Web-GUI, services=>USB, at the Run-on-mount Script Name form paste:
Quote:
/jffs/etc/config/unmount.startup

Save changes, and reboot your router!
If all make right, when you insert your USB Drive at port and router successfully mount it, the LED must turn on, when you press the button, your drive must unmount, and led must turn off!
Sponsor
user99
DD-WRT Novice


Joined: 17 Sep 2012
Posts: 15

PostPosted: Sun Sep 30, 2012 16:10    Post subject: Reply with quote
Where I can find patched gpio program for build 19519?
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Forum Index -> Contributions Upload All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum