From 60ba82c3a015076c1d19f2975649e112e6b771d1 Mon Sep 17 00:00:00 2001 From: Philipp Klaus Date: Wed, 15 Oct 2014 17:40:35 +0200 Subject: [PATCH] Textual representation of unpacked data improved --- tools/python_hld_unpacker/hld_unpacker/unpacker.py | 7 +++++-- tools/python_hld_unpacker/hld_unpacker/utils.py | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/tools/python_hld_unpacker/hld_unpacker/unpacker.py b/tools/python_hld_unpacker/hld_unpacker/unpacker.py index 0314ed9..b28e205 100644 --- a/tools/python_hld_unpacker/hld_unpacker/unpacker.py +++ b/tools/python_hld_unpacker/hld_unpacker/unpacker.py @@ -88,7 +88,7 @@ class SubEvent(object): class SubSubEvent(object): - # The SubSubEvent header consists of a single words + # The SubSubEvent header consists of a single word HEADERSIZE = WORDSIZE * 1 HEADER_FMT = '>HH' @@ -106,7 +106,10 @@ class SubSubEvent(object): fmt = " |-> size: 0x{:04x} address: 0x{:04x}\n" out = fmt.format(self.size, self.address) out += "\n" - out += str_32bit_chunks(self.payload_bytes) + if len(self.payload_bytes): + out += " " + out += str_32bit_chunks(self.payload_bytes).replace('\n','\n ') + out += "\n\n" return out #### ------ Generator Functions to read the HLD into the (sub)event classes ------ #### diff --git a/tools/python_hld_unpacker/hld_unpacker/utils.py b/tools/python_hld_unpacker/hld_unpacker/utils.py index 93057fb..099c0cb 100644 --- a/tools/python_hld_unpacker/hld_unpacker/utils.py +++ b/tools/python_hld_unpacker/hld_unpacker/utils.py @@ -26,5 +26,5 @@ def str_32bit_chunks(data): for line_words in split_by_n(words, words_per_line): out += "{:04x}: {}\n".format(i, " ".join(line_words)) i += int(wordlength/2) * words_per_line - return out + return out.strip() -- 2.43.0