improve parse()
This commit is contained in:
@@ -96,17 +96,18 @@ class InfosG3P(Infos):
|
|||||||
mtype = (idx >> 24) & 0xff
|
mtype = (idx >> 24) & 0xff
|
||||||
if ftype != rcv_ftype or mtype != msg_type:
|
if ftype != rcv_ftype or mtype != msg_type:
|
||||||
continue
|
continue
|
||||||
if isinstance(row, dict):
|
if not isinstance(row, dict):
|
||||||
info_id = row['reg']
|
continue
|
||||||
fmt = row['fmt']
|
info_id = row['reg']
|
||||||
res = struct.unpack_from(fmt, buf, addr)
|
fmt = row['fmt']
|
||||||
result = res[0]
|
res = struct.unpack_from(fmt, buf, addr)
|
||||||
if isinstance(result, (bytearray, bytes)):
|
result = res[0]
|
||||||
result = result.decode('utf-8')
|
if isinstance(result, (bytearray, bytes)):
|
||||||
if 'eval' in row:
|
result = result.decode('utf-8')
|
||||||
result = eval(row['eval'])
|
if 'eval' in row:
|
||||||
if 'ratio' in row:
|
result = eval(row['eval'])
|
||||||
result = round(result * row['ratio'], 2)
|
if 'ratio' in row:
|
||||||
|
result = round(result * row['ratio'], 2)
|
||||||
|
|
||||||
keys, level, unit, must_incr = self._key_obj(info_id)
|
keys, level, unit, must_incr = self._key_obj(info_id)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user