44 lines
710 B
Bash
Executable File
44 lines
710 B
Bash
Executable File
#!/bin/sh
|
|
|
|
|
|
# [1] If empty pin number
|
|
#========================================================#
|
|
if [ -z "$1" ]; then
|
|
|
|
echo 127;
|
|
exit 127;
|
|
fi;
|
|
|
|
|
|
|
|
# [2] Check if valid pin number (integer)
|
|
#========================================================#
|
|
test $1 -ge 0 2> /dev/null;
|
|
|
|
if [ $? -gt 1 ]; then
|
|
|
|
echo 127;
|
|
exit 127;
|
|
|
|
fi;
|
|
|
|
|
|
|
|
# [3] Activate (if not already)
|
|
#========================================================#
|
|
test -d /sys/class/gpio/gpio$1 || echo $1 > /sys/class/gpio/export;
|
|
|
|
|
|
|
|
# [4] Set mode to OUT
|
|
#========================================================#
|
|
echo "0" > /sys/class/gpio/gpio$1/value;
|
|
|
|
|
|
|
|
|
|
# [5] EXIT_CODE
|
|
#========================================================#
|
|
echo 0;
|
|
exit 0;
|