From b471d9cab803f4d9d28aec6b86e20457a784f6cb Mon Sep 17 00:00:00 2001 From: LongHairedHacker Date: Sat, 20 Oct 2018 20:20:27 +0200 Subject: [PATCH] Added full code for serial handling --- update.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/update.py b/update.py index 7f6cd7f..943c450 100644 --- a/update.py +++ b/update.py @@ -12,17 +12,16 @@ calc_crc = crcmod.predefined.mkCrcFun(CRC_TYPE) def parse_line(line): if line[-2:] != "\r\n": - print("newline fucked") + print("Failed to parse: newline broken") return {key : None for key in FORMAT} line = line[:-2] crc_str = line[-4:] - print(crc_str) payload = line[0:-4] crc = int(crc_str, 16) calced_crc = calc_crc(payload.encode('ascii')) if crc != calc_crc(payload.encode('ascii')): - print("CRC fucked") + print("Failed to parse: CRC broken") return {key : None for key in FORMAT} parts = payload.split(';') @@ -121,10 +120,13 @@ def main(): while True: line = ser.readline().decode('ascii') - print(line) if len(line) > 0: + print(line) parsed = parse_line(line) update_database(parsed) + update_graphs() + upload_graphs() +