import struct
from collections import defaultdict

# Set your target hex ID here (as an integer). For example, 0x0D = 13.
TARGET_ID = 0x19

def analyze_specific_id(filename="Test.B162"):
    id_counts = defaultdict(int)
    try:
        with open(filename, "rb") as f:
            while True:
                id_byte = f.read(1)
                data_bytes = f.read(4)

                if not id_byte or len(data_bytes) < 4:
                    break

                data_id = id_byte[0]
                if data_id != TARGET_ID:
                    continue

                id_counts[data_id] += 1
                raw_hex = ' '.join(f"{b:02X}" for b in data_bytes)

                try:
                    value = struct.unpack('<f', data_bytes)[0]
                    calculated = f"{value:.4f}"
                except struct.error:
                    calculated = "N/A"

                print(f"ID 0x{data_id:02X} | Raw: {raw_hex} | Value: {calculated}")

        print(f"\nTotal entries for ID 0x{TARGET_ID:02X}: {id_counts[TARGET_ID]}")

    except FileNotFoundError:
        print(f"File '{filename}' not found.")

if __name__ == "__main__":
    analyze_specific_id()
