import struct, sys, os path = r"C:\Project\MAG160C\analysis\ida\Core160043865.ddt" b = open(path, "rb").read() print(f"size: {len(b)}") def u32(o): return struct.unpack_from(">1)*2 if False else thr_off + (nsegs-1)*npix*2 + (c5c//2)*2 print(f"EP{e}: thr@{thr_off:#x} gain@{g_off:#x} T={T[e]}") t0 = i16(thr_off), i16(thr_off+2), i16(thr_off+4), i16(thr_off+19200*2) g0 = u16(g_off), u16(g_off+2), u16(g_off+4), u16(g_off+19200*2), u16(g_off+2*19200*2) print(f" thr[0..3]={t0} thr[1st pix row start]={t0[3]}") print(f" gain seg0[0..3]={g0[0:4]} gain seg1[0]={g0[4]}") ep += u26 # blind records: after all endpoint blocks blind_off = ep print(f"blind records at 0x{blind_off:x}, total {blind_total} bytes") for e in range(count-1): n = D[e] print(f"EP{e} blind count={n}") for i in range(min(n, 8)): r = blind_off + e*0 + i*40 target, typ = u32(r), u32(r+4) neigh = [u32(r + 8 + j*4) for j in range(8)] print(f" rec[{i}]: target={target} type={typ} neigh={neigh[:typ-2 if typ>=3 else 8]}") blind_off += n*40 # check: what's after blind records (trailer) print(f"trailer at 0x{blind_off:x}:") for i in range(8): print(f" +{i*4}: {u32(blind_off+i*4):#010x}") # compare with the captured working tables gain = open(r"C:\Project\MAG160C\build-artifacts\mag160c_official_nuc_gain.bin", "rb").read() thr = open(r"C:\Project\MAG160C\build-artifacts\mag160c_official_nuc_thr.bin", "rb").read() print(f"\ncaptured working tables: gain={len(gain)} thr={len(thr)}") print(f"thr[0:4]={[i16(i*2) for i in range(4)]} (from thr.bin)") print(f"gain[0:4]={[u16(i*2) for i in range(4)]}") print(f"gain[19200*2:19200*2+4]={[u16(19200*2+i*2) for i in range(4)]} (seg1)") # find which endpoint the working table corresponds to: interpolate check later in C