### Raspberry Pi GPIO Setup

To be able to use the GPIO, install JNA first.
Install JNA
$sudo apt-get install libjna-java
Add to openHAB start.sh located in /opt/openhab
-Djna.boot.library.path=/usr/lib/jni
Bindings required
The bindings used are
org.openhab.io.gpio
org.openhab.binding.gpio
Copy these to the openhab addons folder /opt/openhab/addons
Unexport Pins
Add to the script /etc/init.d/openhab the GPIO pins to export in the do_stop function:
do_stop()
{
# Return
# 0 if daemon has been stopped
# 1 if daemon was already stopped
# 2 if daemon could not be stopped
# other if a failure occurred
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
#unexport all gpio's
echo 22 > /sys/class/gpio/unexport
echo 23 > /sys/class/gpio/unexport
echo 24 > /sys/class/gpio/unexport
echo 10 > /sys/class/gpio/unexport
echo 9 > /sys/class/gpio/unexport
echo 25 > /sys/class/gpio/unexport
echo 11 > /sys/class/gpio/unexport
echo 12 > /sys/class/gpio/unexport
echo 8 > /sys/class/gpio/unexport
RETVAL="$?"
[ "$RETVAL" = 2 ] && return 2
# Wait for children to finish too if this is a daemon that forks
# and if the daemon is only ever run from this initscript.
# If the above conditions are not satisfied then add some other code
# that waits for the process to drop all resources that could be
# needed by services started subsequently. A last resort is to
# sleep for some time.
start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
[ "$?" = 2 ] && return 2
# Many daemons don't delete their pidfiles when they exit.
rm -f $PIDFILE
return "$RETVAL"
}

Changed: , Category: WebApps openHAB, File: T6C228M1680.htm, ID: 1680