From 557a158a9cd5000a2e999c194d944974e3d6460b Mon Sep 17 00:00:00 2001 From: LongHairedHacker Date: Sat, 20 Oct 2018 20:13:23 +0200 Subject: [PATCH] Added serial code --- config.py | 2 -- update.py | 12 +++++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/config.py b/config.py index af05ebf..5203ba3 100644 --- a/config.py +++ b/config.py @@ -4,8 +4,6 @@ from configutils import * SERIAL = '/dev/ttyUSB0' BAUD_RATE = 4800 -STOP_BITS = 1 -PARITY = None SFTP_HOST = 'rc-club-albersweiler.de' SFTP_PORT = 22 diff --git a/update.py b/update.py index c7bc6c4..7f6cd7f 100644 --- a/update.py +++ b/update.py @@ -63,6 +63,8 @@ def create_database(): def update_database(line): update_values = [] for name, _, _ in STORED_VALUES: + if line[name] == None: + return update_values += ["%f" % float(line[name])] now = time.time() @@ -115,7 +117,15 @@ def upload_graphs(): print("Unexpected error while uploading:", sys.exc_info()[1]) def main(): - pass + ser = serial.Serial(SERIAL, BAUD_RATE, timeout=10.0) + + while True: + line = ser.readline().decode('ascii') + print(line) + if len(line) > 0: + parsed = parse_line(line) + update_database(parsed) + if __name__ == '__main__':