use "cu" instead of "socat"
[usb-wde1-tools.git] / munin / usb-wde1-log-last.sh
1 #!/bin/sh
2 # logs the last line. usable via nohup on the server
3 #
4 # run this script as follows:
5 # $ nohup ./usb-wde1-log-last.sh &
6 #
7 # Use --dummy-data as parameter to log dummy data only
8 #
9 # License: http://www.gnu.org/licenses/agpl.html AGPL
10 # Author: Christian Weiske <cweiske@cweiske.de>
11 #
12 # FIXME: send RESET or INIT and M2
13
14 curdir="$(dirname "$0")"
15 if [ "$1" = "--dummy-data" ]; then
16     $curdir/../dummy-data-generator.php\
17      | $curdir/log-single-line.sh /tmp/usb-wde1-last
18 else
19     if [ ! -r /dev/ttyUSB0 ]; then
20         echo "Device /dev/ttyUSB0 is not readable"
21         exit 1
22     fi
23
24     #socat breaks something that leads to
25     # WRONG VAL, WRONG CMD and FullBuff->Reset
26     # errors
27     #socat /dev/ttyUSB0,b9600 STDOUT\
28
29     # quit cu with "~."
30     cu -l /dev/ttyUSB0 -s 9600\
31      | $curdir/log-single-line.sh /tmp/usb-wde1-last
32 fi