import struct

DUMP = r"C:/Users/vikto/Documents/Claude/rt-4d/radio-spi-dump.bin"
with open(DUMP, "rb") as f:
    f.seek(0)
    cal = f.read(0x1000)

print("len", len(cal))
# occupancy: find 0xFF runs
ff = sum(1 for b in cal if b == 0xff)
zero = sum(1 for b in cal if b == 0)
print("0xFF bytes:", ff, "0x00 bytes:", zero, "other:", 0x1000-ff-zero)

# hex dump first 0x400
def dump(off, length):
    for i in range(off, off+length, 16):
        row = cal[i:i+16]
        hexs = " ".join(f"{b:02x}" for b in row)
        asc = "".join(chr(b) if 32<=b<127 else "." for b in row)
        print(f"{i:04x}  {hexs}  {asc}")

dump(0, 0x200)
