PDA

Bekijk de volledige versie : Use copy-button to spin down hdd?



dome
23-01-2007, 09:37
Hi,

I think I just got a great idea :) Since I don't need the copy-button at all (does anybody?), it would be great to give it a better function e.g. to spin down the internal hdd. I don't even know if this is possible, but here are many clever people :D so if somebody reads this and manages to do so, let me know ;)

kfurge
24-01-2007, 02:26
It's 100% possible. I've tinkered with the gpio configuration on the box and was able to read the state of the copy button as well as blink the power light.

To blink the power LED:

1. First get it's i/o state and value so it can be put back. I stored them in variables to put them back later:

DIRECTION=`cat /proc/miscio/gpio_1_config | grep direction`
VALUE=`cat /proc/miscio/gpio_1`

2. Set the direction to "out"

echo "direction=out" > /proc/miscio/gpio_1_config

3. Set to 0/1 to turn on/off respectively

echo "0" > /proc/miscio/gpio_1
echo "1" > /proc/miscio/gpio_1

4. Reset the gpio settings to the values from step 1

echo ${VALUE} > /proc/miscio/gpio_1
echo ${DIRECTION} > /proc/miscio/gpio_1_config

To find the copy button, cycle through the various /proc/miscio/gpio_X (similar to step #1) while you press the button. You'll find it quickly.

I had the copy, ez-setup, and power pins mapped out, but unfortunately I lost my notes... ;-(

- K.C.

scriptman
24-01-2007, 08:49
It's 100% possible. I've tinkered with the gpio configuration on the box and was able to read the state of the copy button as well as blink the power light.

To blink the power LED:

1. First get it's i/o state and value so it can be put back. I stored them in variables to put them back later:

DIRECTION=`cat /proc/miscio/gpio_1_config | grep direction`
VALUE=`cat /proc/miscio/gpio_1`

2. Set the direction to "out"

echo "direction=out" > /proc/miscio/gpio_1_config

3. Set to 0/1 to turn on/off respectively

echo "0" > /proc/miscio/gpio_1
echo "1" > /proc/miscio/gpio_1

4. Reset the gpio settings to the values from step 1

echo ${VALUE} > /proc/miscio/gpio_1
echo ${DIRECTION} > /proc/miscio/gpio_1_config

To find the copy button, cycle through the various /proc/miscio/gpio_X (similar to step #1) while you press the button. You'll find it quickly.

I had the copy, ez-setup, and power pins mapped out, but unfortunately I lost my notes... ;-(

- K.C.

This is exactly what I’m trying to do with the wl500gP, unfortunately the paths you have specified don’t exist on the WL500gP? I’m running Olegs firmware.

Has anyone been able to do this with the WL500gP?

SM

luckynuts
25-01-2007, 23:20
That is a pretty good idea but i don´t know how to change that?!...is there a manual for dummies? :p

iwat
22-08-2007, 09:39
It's 100% possible. I've tinkered with the gpio configuration on the box and was able to read the state of the copy button as well as blink the power light.

To blink the power LED:

1. First get it's i/o state and value so it can be put back. I stored them in variables to put them back later:

DIRECTION=`cat /proc/miscio/gpio_1_config | grep direction`
VALUE=`cat /proc/miscio/gpio_1`

2. Set the direction to "out"

echo "direction=out" > /proc/miscio/gpio_1_config

3. Set to 0/1 to turn on/off respectively

echo "0" > /proc/miscio/gpio_1
echo "1" > /proc/miscio/gpio_1

4. Reset the gpio settings to the values from step 1

echo ${VALUE} > /proc/miscio/gpio_1
echo ${DIRECTION} > /proc/miscio/gpio_1_config

To find the copy button, cycle through the various /proc/miscio/gpio_X (similar to step #1) while you press the button. You'll find it quickly.

I had the copy, ez-setup, and power pins mapped out, but unfortunately I lost my notes... ;-(

- K.C.

Dear K.C.,

Is it possible to use it to control the WiFi? I want to turn it off when no one @ home...


:-) IWAT

kfurge
23-08-2007, 00:25
Dear K.C.,

Is it possible to use it to control the WiFi? I want to turn it off when no one @ home...


:-) IWAT

I'm not aware of a command line utility available in the Asus firmware (or my derived image) that is capable of turning wireless on and off.

I think I remember someone mentioning an OpenWRT binary that does this.

- K.C.

milky
09-10-2007, 00:24
I wrote this script for the purpose. Note that:

0) Just a quick hack but works quite well
1) You have to keep the button pressed for at least 1s
2) The Ready LED keeps blinking when wlan is on
3) If you don't have the bash, !#/bin/sh works as well


#!/opt/bin/bash

on=1

if wl radio | grep 1 &> /dev/null
then
radio=off
else
radio=on
fi

while true
do
if [ $radio = "on" ]
then
echo "direction=out" > /proc/miscio/gpio_1_config
echo $on > /proc/miscio/gpio_1
if [ $on = 1 ]
then
on=0
else
on=1
fi
fi

if grep 1 /proc/miscio/gpio_6 &> /dev/null
then
if wl radio | grep 1 &> /dev/null
then
wl radio on
radio=on
else
wl radio off
echo "direction=out" > /proc/miscio/gpio_1_config
echo "0" > /proc/miscio/gpio_1
radio=off
fi
fi

sleep 1
done



--milky

kfurge
09-10-2007, 02:21
Great script. The wl binary was the one I was thinking of.

- K.C.

Gizmo1007
16-10-2007, 15:56
K.C
Any luck getting the mapping for the E-setup, Copy Buttons?

What script does the system run when the copy button is pressed normally?

Could this script be modified to read the contents of a CD on a USB cd player and upload contents that way as well?

Or would you use the one of the two back USB and get it executed through a PHP page? anythoughts?

kfurge
17-10-2007, 02:55
K.C
Any luck getting the mapping for the E-setup, Copy Buttons?

Yes, I found my notes again. Here's what I mapped:

GPIO0 BTN_SHUTDOWN
GPIO1 BTN_RESET
GPIO4 BTN_SETUP
GPIO6 BTN_USBCOPY



What script does the system run when the copy button is pressed normally?


/sbin/miscio_input_change

It's a symlink to one of the Asus binaries.



Could this script be modified to read the contents of a CD on a USB cd player and upload contents that way as well?

It can be modified, but it's tricky. You first have clone /sbin to somewhere on the HDD. In my case, I cloned it to /opt/asus/sbin. You can then mount /opt/asus/sbin over sbin with:

mount -o bind /opt/asus/sbin /sbin

After this, you can replace the Asus binary with whatever you want. A serial console is helpful in debugging replacement scripts.

I needed to hook into the power button to properly unmount my filesystems. To do this, I had to perform the following scriptland backflips:

-------------------------------
/sbin/miscio_input_change
#!/bin/sh

/bin/cp /shares/MYVOLUME1/shutdown.sh /tmp
/bin/cp /bin/busybox /tmp/sh

sync
sync
sync

/tmp/shutdown.sh &
--------------------------
/shares/MYVOLUME1/shutdown.sh
#!/tmp/sh

/opt/bin/umount -l /sbin
/opt/bin/umount -l /bin
/opt/bin/umount -l /opt

/bin/mkdir -p /tmp/miscio
/bin/ln -s /sbin/rc /tmp/miscio/miscio_input_change

sync
sync
sync

/tmp/miscio/miscio_input_change &

exit 0
------------------
I use the following in rc.local to use the copy button to skip the execution of rc.local:

# If the copy button is pressed, bypass rc.local
bypass=`/bin/cat /proc/miscio/gpio_6`
if test $bypass -eq "1"; then
exit -1
fi
--------------------

I'm sure all of this could be put together to have GPIO6 perform something other than what Asus intended.

Please let us know if you get it working.



Or would you use the one of the two back USB and get it executed through a PHP page? anythoughts?

Sure, this would work also.

- K.C.