From 818f63a658e0c17b37488c232f99e2e6467e2599 Mon Sep 17 00:00:00 2001 From: Markus Birth Date: Wed, 17 Oct 2018 20:49:57 +0200 Subject: [PATCH] More compact output for repetetive blocks. --- grmn/gcd.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/grmn/gcd.py b/grmn/gcd.py index 0110509..9374dcf 100644 --- a/grmn/gcd.py +++ b/grmn/gcd.py @@ -47,5 +47,15 @@ class Gcd: def print_struct(self): last_tlv = 0xffff tlv_count = 0 + tlv_length = 0 for i, tlv in enumerate(self.struct): - print("#{:03d}: {}".format(i, tlv)) + if tlv.type_id != last_tlv: + if tlv_count > 0: + print(" + {} more ({} Bytes total payload)".format(tlv_count, tlv_length)) + tlv_count = 0 + tlv_length = tlv.length + print("#{:03d}: {}".format(i, tlv)) + else: + tlv_count += 1 + tlv_length += tlv.get_length() + last_tlv = tlv.type_id