This articles shows how to write a simple CGI to set via Web an output line
By default it is available on the FOX Board the command setbits that allows the control of each general purpose output line.
The syntax of this commad is:
setbits [OPTIONS]
Where OPTIONS are:
-p port Which port to use, valid values are a,b or g -b bit Bit number to change -s state Change selected bit to state (0/1)
For example with setbit command it is possible to turn on the RED led DL1 on the FOX Board (see the FOX pinout to locate it). This LED turn on when the line 3 of the port A goes low.
To turn on red led DL1 type:
# setbits -p a -b 3 -s 0
To turn off red led DL1 type:
# setbits -p a -b 3 -s 1
To execute these commands remotely via web use this CGI:
#!/bin/sh echo "Content-type: text/html\n" # read in our parameters PORT=`echo "$QUERY_STRING" | sed -n 's/^.*port=\([^&]*\).*$/\1/p' | sed "s/%20/ /g"` LINE=`echo "$QUERY_STRING" | sed -n 's/^.*line=\([^&]*\).*$/\1/p' | sed "s/%20/ /g"` STATE=`echo "$QUERY_STRING" | sed -n 's/^.*state=\([^&]*\).*$/\1/p' | sed "s/%20/ /g"` # test if any parameters were passed if [ $PORT ] && [ $LINE ] && [ $STATE ] then setbits -p $PORT -b $LINE -s $STATE fi
Save it in the cgi folder (see Setting up BOA to accept CGI) and call it from your browser using these URLs: