From: Philipp Klaus Date: Fri, 21 Nov 2014 15:36:47 +0000 (+0100) Subject: python_hld_unpacker: introduce event_chunker() into read() X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=11751dfe26f9d209d426d22ab5d8edd09bf2ac1a;p=mvdsensorcontrol.git python_hld_unpacker: introduce event_chunker() into read() --- 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('