This commit is contained in:
david rice
2026-04-27 13:58:09 +01:00
parent a1b66906e9
commit 2892ea45ff
2 changed files with 115 additions and 6 deletions

View File

@@ -646,7 +646,7 @@ def _fetch_registers(ts: str, iteration: int) -> None:
print(f" REGISTERS: SN65DSI83 error — {e}")
combined["sn65"] = None
# SN65DSI83 post-restart settling poll
# SN65DSI83 post-restart settling poll + register snapshots
try:
resp = requests.get(f"{DEVICE_BASE}/sn65_settling", timeout=10)
resp.raise_for_status()
@@ -656,13 +656,14 @@ def _fetch_registers(ts: str, iteration: int) -> None:
n = settling.get("n_readings", 0)
n_err = settling.get("n_error", 0)
dur = settling.get("duration_s", 0)
# ── csr_e5 error summary ──────────────────────────────────────────
if n_err:
# Print the first and last error readings for quick diagnosis
err_readings = [r for r in settling.get("readings", []) if r.get("any_error")]
times = [r["t_ms"] for r in err_readings]
print(f" SN65 SETTLING: *** {n_err}/{n} readings had csr_e5 errors "
f"over {dur:.1f} s (t={times[0]:.0f}{times[-1]:.0f} ms) ***")
for r in err_readings[:3]: # show up to first 3 error readings
for r in err_readings[:3]:
print(f" t={r['t_ms']:6.1f} ms csr_0a={r['csr_0a']} "
f"csr_e5={r['csr_e5']} "
f"pll={'Y' if r['pll_lock'] else 'N'} "
@@ -672,6 +673,30 @@ def _fetch_registers(ts: str, iteration: int) -> None:
if r.get("clk_det") is False)
print(f" SN65 SETTLING: no csr_e5 errors in {n} readings over {dur:.1f} s"
+ (f" ({clk_false} readings with clk_det=False)" if clk_false else ""))
# ── Register snapshot: print start values and flag any changes ───
snap_start = settling.get("snapshot_start") or {}
snap_end = settling.get("snapshot_end") or {}
changed = settling.get("changed_regs") or {}
if snap_start:
print(f" SN65 REGS (t=0):", end="")
# Print a compact one-liner of key config registers
_key = ["0x0d", "0x10", "0x11", "0x18", "0x19", "0x1a", "0x1b",
"0x3c", "0xe0", "0xe1"]
parts = []
for r in _key:
info = snap_start.get(r, {})
parts.append(f"{info.get('name','?')}={info.get('value','?')}")
print(" " + " ".join(parts))
if changed:
print(f" SN65 REGS CHANGED during settling window ({len(changed)} registers):")
for reg, diff in changed.items():
print(f" {reg} {diff['name']:16s} {diff['start']}{diff['end']}")
elif snap_start:
print(f" SN65 REGS: stable (no register changes between t=0 and t={dur:.1f}s)")
except requests.exceptions.RequestException as e:
print(f" REGISTERS: settling poll fetch failed — {e}")
combined["sn65_settling"] = None