use "cu" instead of "socat"
[usb-wde1-tools.git] / munin / usb-wde1-log-last.sh
old mode 100644 (file)
new mode 100755 (executable)
index 9fca864..2fd070b
@@ -1,5 +1,32 @@
 #!/bin/sh
 # logs the last line. usable via nohup on the server
+#
+# run this script as follows:
+# $ nohup ./usb-wde1-log-last.sh &
+#
+# Use --dummy-data as parameter to log dummy data only
+#
+# License: http://www.gnu.org/licenses/agpl.html AGPL
+# Author: Christian Weiske <cweiske@cweiske.de>
+#
 # FIXME: send RESET or INIT and M2
-socat /dev/ttyUSB0,b9600 STDOUT\
- | ./log-single-line.sh /tmp/usb-wde1-last
+
+curdir="$(dirname "$0")"
+if [ "$1" = "--dummy-data" ]; then
+    $curdir/../dummy-data-generator.php\
+     | $curdir/log-single-line.sh /tmp/usb-wde1-last
+else
+    if [ ! -r /dev/ttyUSB0 ]; then
+        echo "Device /dev/ttyUSB0 is not readable"
+        exit 1
+    fi
+
+    #socat breaks something that leads to
+    # WRONG VAL, WRONG CMD and FullBuff->Reset
+    # errors
+    #socat /dev/ttyUSB0,b9600 STDOUT\
+
+    # quit cu with "~."
+    cu -l /dev/ttyUSB0 -s 9600\
+     | $curdir/log-single-line.sh /tmp/usb-wde1-last
+fi