From 11751dfe26f9d209d426d22ab5d8edd09bf2ac1a Mon Sep 17 00:00:00 2001 From: Philipp Klaus Date: Fri, 21 Nov 2014 16:36:47 +0100 Subject: [PATCH] python_hld_unpacker: introduce event_chunker() into read() --- .../hld_unpacker/unpacker.py | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/tools/python_hld_unpacker/hld_unpacker/unpacker.py b/tools/python_hld_unpacker/hld_unpacker/unpacker.py index b28e205..151a3ce 100644 --- a/tools/python_hld_unpacker/hld_unpacker/unpacker.py +++ b/tools/python_hld_unpacker/hld_unpacker/unpacker.py @@ -115,20 +115,22 @@ class SubSubEvent(object): #### ------ Generator Functions to read the HLD into the (sub)event classes ------ #### def read(hld_stream): + for (header_bytes, data_bytes) in event_chunker(hld_stream): + yield Event(header_bytes, data_bytes) + +def event_chunker(hld_stream): while True: header_bytes = hld_stream.read(Event.HEADERSIZE) if len(header_bytes) < Event.HEADERSIZE: break # The size of the event in bytes is given in the first data word of the event. - # The size also includes the 4 bytes of its own data word: + # The size also includes the 4 bytes of its own data word. size = struct.unpack('