Olimex Support Forum

OLinuXino Android / Linux boards and System On Modules => iMX233 => Topic started by: flavigny on October 07, 2012, 11:46:19 AM

Title: How I report return code by led blinking
Post by: flavigny on October 07, 2012, 11:46:19 AM
Hello,

in some circumtances it is convenient to report information to user, without any more hardware or terminal connected.
Read below a script doing that.

suggestion for use in your own script
....
mycommand
retval=$?
if [ $retval -eq 0 ]
then
else
./morseled 1 3 1
fi


of course, you may complicate that, reporting specific return code.

cat morseled
#!/bin/sh
nbargs=$#
if [ ${nbargs} -eq 0 ]
then
  echo appel: morseled list of "bip" durations in second
else
port=65
echo blink led on gpio${port} hit ^C to stop
echo out > /sys/class/gpio/gpio${port}/direction
while [ 1 -eq 1 ]
do
  echo led off for 5\" \(pause\)
  echo 0 > /sys/class/gpio/gpio${port}/value
  sleep 5
  for duration in $*
     do
       echo  Led ON ${duration}\"
       echo 1 > /sys/class/gpio/gpio${port}/value
       sleep ${duration}
       echo Led Off for 1\"
       echo 0 > /sys/class/gpio/gpio${port}/value
       sleep 1
     done
  done
fi