fix: address PR review — flash state race, error paths, test robustness, nits

- server.py: claim the flash (state=bootloader) before spawning the task so
  the concurrent-request guard is effective immediately; guard the bundled
  image existence in the flash endpoint; single device.info() call per
  endpoint; 400 for refused flashes (409 stays for already-running);
  remove stale nvcurve-wireview-fw-*.bin temp files at startup
- wireview_firmware.py: drain stderr in its own reader thread (a full pipe
  buffer would have hung the flash until timeout); chunked stdout reads
  instead of per-character read(2); BuildStruct field checks in dataclass
  order
- wireview.py: document the intentional 0xF1 overlap between CMD_BOOTLOADER
  and SCREEN_RESUME_UPDATES (different command namespaces)
- tests: check() now fails loudly under pytest (optional import, standalone
  runs unaffected); explicit reader-thread sync in test_enter_bootloader;
  less brittle flash-progress assertion; self-documenting checksum
  corruption in test_hex_parser
- frontend: refreshFirmware in useCallback + effect deps; NaN% guard on
  flash.progress; explicit clear/keep masks in handleClear; WS firmware
  message reuses WireViewFlashProgress via Pick
- docs: clarify that the dfu-util :leave modifier is what makes the device
  exit the bootloader and reboot; document the 400 vs 409 API contract;
  README now mentions per-pin readings, pin-imbalance gauge and fault
  clearing
This commit is contained in:
ARIA committed 2026-10-05 20:40:05 +02:00
1 parent dbb6856a6d
commit 6e87dcf862
8 files changed
+111 -55

No files matched your search

+4 -6
View File
@@ -249,9 +249,7 @@ export interface WireViewFirmwareState {
export type WireViewWsMessage =
| { type: "unavailable" }
| { type: "sample"; info: WireViewInfo; sample: WireViewSample }
| {
type: "firmware";
state: WireViewFlashProgress["state"];
progress: number;
status: string;
};
// Flat payload: the flash progress fields are re-declared (not nested) to
// match the WS message shape; keep in sync with WireViewFlashProgress.
| ({ type: "firmware" } &
Pick<WireViewFlashProgress, "state" | "progress" | "status">);