From 0e63c45302a6e5f3344ae89f25b6ed11be88f362 Mon Sep 17 00:00:00 2001 From: Stefan Allius Date: Sun, 14 Apr 2024 14:24:32 +0200 Subject: [PATCH] improve parse() --- app/src/gen3plus/infos_g3p.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/app/src/gen3plus/infos_g3p.py b/app/src/gen3plus/infos_g3p.py index c92bdb2..5d3c6b7 100644 --- a/app/src/gen3plus/infos_g3p.py +++ b/app/src/gen3plus/infos_g3p.py @@ -96,17 +96,18 @@ class InfosG3P(Infos): mtype = (idx >> 24) & 0xff if ftype != rcv_ftype or mtype != msg_type: continue - if isinstance(row, dict): - info_id = row['reg'] - fmt = row['fmt'] - res = struct.unpack_from(fmt, buf, addr) - result = res[0] - if isinstance(result, (bytearray, bytes)): - result = result.decode('utf-8') - if 'eval' in row: - result = eval(row['eval']) - if 'ratio' in row: - result = round(result * row['ratio'], 2) + if not isinstance(row, dict): + continue + info_id = row['reg'] + fmt = row['fmt'] + res = struct.unpack_from(fmt, buf, addr) + result = res[0] + if isinstance(result, (bytearray, bytes)): + result = result.decode('utf-8') + if 'eval' in row: + result = eval(row['eval']) + if 'ratio' in row: + result = round(result * row['ratio'], 2) keys, level, unit, must_incr = self._key_obj(info_id)