From dcd1ac89df3a2bc4af1e41592419025857938817 Mon Sep 17 00:00:00 2001 From: Martin Kompf Date: Fri, 15 Feb 2019 19:00:13 +0100 Subject: [PATCH] Utility to receive raw data values from Arduino and print them to stdout --- catserial.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100755 catserial.py diff --git a/catserial.py b/catserial.py new file mode 100755 index 0000000..e60397f --- /dev/null +++ b/catserial.py @@ -0,0 +1,32 @@ +#!/usr/bin/python -u +# +# catserial.py +# +# Utility to receive raw data values from Arduino and print them to stdout +# + +import serial +import sys + +# Serial port of arduino +#port = '/dev/ttyAMA0' +port = '/dev/serial0' + +# Main +def main(): + # Open serial line + ser = serial.Serial(port, 9600) + if not ser.isOpen(): + print "Unable to open serial port %s" % port + sys.exit(1) + # set data mode + ser.write(b'C\r\n') + ser.write(b'D\r\n') + while(1==1): + # Read line from arduino and print it + line = ser.readline() + line = line.strip() + print(line) + +if __name__ == '__main__': + main()