You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(host): resend recovery returns the request-ack early; wait for the resent line's real ok #11
On a reliable-mode checksum / line-number recovery, Marlin's flush_and_request_resend() emits Resend: N+1 then a trailing ok
(gcode/queue.cpp:275-276). That ok acks the resend request — it is emitted
before the controller processes the resent line; the resent line's real ok
arrives afterward.
In MarlinHost._await_terminal (marlin_host/host.py:299-306), on needs_resend
the host reframes + resends and continues, then reads that trailing ok and
returns it as the command's terminal ack (host.py:292-293). So in reliable mode
the host returns one ack early on every recovery, desyncing the stream by one
command (the resent line's real ok is then misread as the next command's ack).
Current resend tests only prove the host reacts to a canned Resend:; the
synthetic corpus drops the trailing ok, hiding this. FakeTransport.from_trace
is indexed by write count, not content (transport.py:75), so it structurally
cannot reproduce a real checksum-driven recovery.
Fix
After resending, swallow exactly the one trailing ok that accompanies the Resend: request, and keep waiting for the resent line's real ok (e.g. a awaiting_resend_ack flag set when we resend, cleared by the next ok).
Regression test — a stateful resend responder (where a behavioral mock earns its keep)
Add a small stateful responder callable passed to the existing FakeTransport(responder=...) — no new Transport, no printer emulator. It:
parses N + *checksum from the written line, recomputes XOR via framing.checksum, compares N to an expected counter;
on mismatch emits Error:<err><last_N> + Resend: <last_N+1> + ok (the real
double-terminal, queue.cpp:320-327,275-276); on match emits ok and increments;
handles framed M110 Nn resync.
Acceptance criteria
A reliable-mode round-trip with a deliberately corrupted checksum drives the host
through Error: → Resend: → <resend> → ok, and send() returns only the
resent line'sok — stream stays in sync, no off-by-one.
The responder lives in tests / a tiny test helper; banner/M115/M105/M114/busy/halt
stay on existing traces + synthetic corpus (not re-implemented).
Activity