blob: 5c447d34df3924a15108d5eea1d45d9327c0b66a [file] [log] [blame]
#!/bin/sh
usage()
{
echo "Usage: $0 <milliseconds>" >&2
echo " Returns zero if the reset button is held for >= millseconds." >&2
exit 9
}
[ "$#" = 1 ] || usage
[ "$1" -gt 1 ] || usage
# wait until gpio-mailbox has had at least one loop
wait-until-created /tmp/gpio/ready
retval=1 # not pressed
while [ -e /tmp/gpio/reset_button_msecs ]; do
# reset button is pressed at boot time; wait to see if the user
# holds it for $1 msec
usleep 100000
if [ -e /tmp/gpio/reset_button_msecs ]; then
msecs=
read msecs </tmp/gpio/reset_button_msecs
echo "reset button held for $msecs msecs so far"
if [ "$msecs" -gt "$1" ]; then
retval=0 # pressed for long enough
break
fi
fi
done
exit $retval