diff --git a/config.py b/config.py index 7190b56..af05ebf 100644 --- a/config.py +++ b/config.py @@ -21,7 +21,7 @@ ARCHIVE_KEEP_INTERVAL = 365 * 24 * 60 * 60 # 1 year MAX_MISSING = 0.5 # Manual claims poly should be 0x8404, internet says xmodem -CRC_TYPE = 'xmodem' +CRC_TYPE = 'crc-aug-ccitt' STORED_VALUES = [ diff --git a/update.py b/update.py index f873da6..c7bc6c4 100644 --- a/update.py +++ b/update.py @@ -12,13 +12,17 @@ calc_crc = crcmod.predefined.mkCrcFun(CRC_TYPE) def parse_line(line): if line[-2:] != "\r\n": + print("newline fucked") return {key : None for key in FORMAT} line = line[:-2] - crc_str = line[-2:] - payload = line[0:-2] - crc = (ord(crc_str[0]) << 8) | ord(crc_str[1]) + 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") return {key : None for key in FORMAT} parts = payload.split(';') @@ -74,7 +78,7 @@ def update_graphs(): # Render current data graph_params = ['%s.png' % graph_name, '-a', 'PNG', '-s', 'n-%d' % ARCHIVE_INTERVAL] - + for name, lable, color in lines: graph_params += ['DEF:%s=%s:%s:LAST' % (name, DATA_FILE, name)] graph_params += ['LINE1:%s%s:%s' % (name, color, lable)]