"""Dump all blocks in segment 1 of each event with their data.""" import sys sys.path.insert(0, ".") from minimateplus.waveform_codec import walk_body, find_data_start def main(): for stem in ("M529LL1A.SP0", "M529LL1L.JQ0", "M529LL1L.V70"): path = f"tests/fixtures/5-11-26/{stem}" with open(path, "rb") as f: body = f.read()[43:-26] blocks = walk_body(body, find_data_start(body)) # Find segment 1 (between first and second 40 02) seg40_indices = [i for i, b in enumerate(blocks) if b.tag_hi == 0x40] if len(seg40_indices) < 2: print(f"\n{stem}: only {len(seg40_indices)} segment headers found") seg1_blocks = blocks[seg40_indices[0]:] if seg40_indices else [] else: seg1_blocks = blocks[seg40_indices[0]:seg40_indices[1]+1] print(f"\n=== {stem} segment 1 ({len(seg1_blocks)} blocks) ===") for b in seg1_blocks[:25]: tag = f"{b.tag_hi:02x}{b.tag_lo:02x}" print(f" off={b.offset:>5} {tag} NN=0x{b.tag_lo:02x}({b.tag_lo:>3}) len={b.length:>3} data={b.data[:16].hex(' ')}{'...' if len(b.data)>16 else ''}") if __name__ == "__main__": main()