From 0582ddce4b6ccbf05c11e630bd4cc250a6c4899a Mon Sep 17 00:00:00 2001 From: Markus Birth Date: Sun, 2 May 2021 01:34:47 +0200 Subject: [PATCH] Use (un)hexlify for Field 4007. Fixes #13. Recipes need to be dumped again. --- grmn/tlv.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/grmn/tlv.py b/grmn/tlv.py index e704c4d..28c03ef 100644 --- a/grmn/tlv.py +++ b/grmn/tlv.py @@ -354,7 +354,10 @@ class TLV7(TLV): continue elif k[0:2] != "0x": continue - numval = int(v, 0) + if v[0:2] == "0x": + numval = int(v, 0) + else: + numval = unhexlify(v) new_values.append(numval) if not self.tlv6.is_parsed: # Make sure we have the structure analysed (need format attr) @@ -386,7 +389,7 @@ class TLVbinary(TLV): elif valtype == "Q": valstr = "0x{:08x}".format(v) elif valtype == "31s": - valstr = repr(v) + valstr = hexlify(v).decode("utf-8") else: valstr = "0x{:08x}".format(v) data.append(("0x{:04x}".format(fid), valstr, fdesc))