Files
hulk 2f43efb94b Tools: PID debug toolchain from V0.1.x bring-up
test_run.py: judged closed-loop test over COM5 (fixed sequence, J1~J4
2026-10-15 20:55:29 +08:00

30 lines
1019 B
Python

# -*- coding: utf-8 -*-
"""Decode the LAST N raw rows of obs_samples.txt (guaranteed current writer)."""
import struct
import sys
def f(w):
w = int(w) & 0xFFFFFFFF
return struct.unpack("<f", struct.pack("<I", w))[0]
def u8(w, b):
return (int(w) >> (8 * b)) & 0xFF
n = int(sys.argv[1]) if len(sys.argv) > 1 else 400
stride = int(sys.argv[2]) if len(sys.argv) > 2 else 10
lines = open("obs_samples.txt", encoding="utf-8").read().splitlines()
rows = [l.split() for l in lines if len(l.split()) == 11 and l.split()[0].isdigit()]
rows = rows[-n:]
t0 = int(rows[0][0])
print(f"{len(rows)} rows (last), stride {stride}:")
for r in rows[::stride]:
print(f"t={(int(r[0])-t0)/1000:7.1f} temp={f(r[10]):6.2f} duty={u8(r[6],1)*5:3d}% "
f"integ={f(r[5]):6.2f} fault={u8(r[3],0)} en={u8(r[9],0)}")
temps = [f(r[10]) for r in rows]
ints = [f(r[5]) for r in rows]
print(f"window: temp[{min(temps):.2f},{max(temps):.2f}] p2p={max(temps)-min(temps):.2f} "
f"integ[{min(ints):.1f},{max(ints):.1f}]")