import struct import json import argparse from dataclasses import dataclass, asdict # --- IDL Structure Definitions (Translated to Python dataclasses) --- # Assuming little-endian ('<') # L: unsigned long (4 bytes) # f: float (4 bytes) # I: unsigned int (4 bytes) - used for 0L # F: float (4 bytes) - used for 0. @dataclass class PACKETDESCR_t: NPRI: int NRBIN: int NUMOFCHANNELS: int BLOCKDIMENSION: int SIGNALORDERING: int _format = ' dict: """ Reads a DSPHDRIN block from the file at the given offset. Returns a dictionary of the extracted data. """ file_handle.seek(offset) # Read enough bytes to cover the entire Header structure (based on header_gen_v1.pro) # This is a rough estimate; a more robust solution would calculate exact size # by summing up all struct sizes. For now, let's read a generous amount. # A typical header might be a few hundred bytes. Let's assume 1024 bytes for safety. # In a real scenario, you'd calculate the exact size of the Header class. # Calculate the total size of the Header structure for header_gen_v1.pro total_header_size = ( struct.calcsize(header_sw_part1._format) + struct.calcsize(header_sw_chank._format) + struct.calcsize(header_info_t._format) + header_info_t._vuoto_len * struct.calcsize('