This repository has been archived on 2024-01-26. You can view files and clone it, but cannot push or open issues or pull requests.
hackerspace-status-arduino/push.sh
2016-05-01 13:53:10 +02:00

28 lines
521 B
Bash
Executable file

#!/bin/sh -e
DEV='/dev/ttyUSB0'
DIR='push.d'
stty -F "$DEV" 9600 -brkint -icrnl -imaxbel -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke
# Warte bis Device $DEV vorhanden ist
while [ ! -c "$DEV" ]; do
sleep 2
done
# sende beliebiges Zeichen an $DEV
echo '?' >> "$DEV" &
while true; do
# wenn $DEV vorhanden
if [ -c "$DEV" ]; then
# dann lese zustand
read -r state < "$DEV"
case "$state" in
ON|HALF|OFF)
run-parts --arg="$state" "$DIR"
;;
esac
else
# sonst warte
sleep 10
fi
done