Installation-gpio-BBB

This revision is from 2014/09/01 12:44. You can Restore it.

open

vim /etc/init.d/gpio

and paste

#!/bin/sh
### BEGIN INIT INFO
# Provides:        gpio
# Required-Start:  $local_fs $syslog
# Required-Stop:   $local_fs $syslog
# Default-Start:   2 3 4 5
# Default-Stop:
# Short-Description: Start gpio
### END INIT INFO

# RPI board revision
#REV=$(cat /sys/module/bcm2708/parameters/boardrev)

for GPIO in 38 39 34 35 66 67 69 68 45 44 23 26 47 46 27 65 22 63 62 37 36 33 32 61 86 88 87 89 10 11 9 81 8 80 78 79 76 77 74 75 72 73 70 71; do
	echo $GPIO > /sys/class/gpio/export
	chmod 666 /sys/class/gpio/gpio$GPIO/value
	chmod 666 /sys/class/gpio/gpio$GPIO/direction
	echo "out" > /sys/class/gpio/gpio$GPIO/direction
done

#if [ $REV -lt 4 ]; then #rev 1-3 GPIO 21
#else		#rev 4- GPIO 27
#fi


DIR=$(cat /etc/remoteqth-path)
# Restore the current gpio settings
SAVE=$(cat $DIR/cfg/s-relay-save)
if [ $SAVE -eq 1 ]; then
	# echo SAVE
	NRGPIO='44'
	for NR in `seq 1 $NRGPIO`; do
		if [ -r $DIR/cfg/s-relay-$NR-save ]; then
			SET=$(cat $DIR/cfg/s-relay-$NR-save)
			if [ -w $DIR/cfg/gpio$NR ]; then
				echo $SET > $DIR/cfg/gpio$NR
			fi
		fi
	done
fi
exit 0

enabled with

chmod 774 /etc/init.d/gpio
update-rc.d gpio defaults