Repository navigation
fix(host): robust connect handshake + correct DTR reset sequence - #10
Merged
Merged
Conversation
Harden the two surfaces that drive a real controller, grounded in the Marlin 2.1.x source and printrun/OctoPrint conventions (research in working/serial-reset.md): connect(): - Wait for Marlin's unconditional `start` boot line as the positive ready signal, then drain the banner until quiet. - Fall back to an active framed `M110 N0` probe (accepting the `ok`, which also syncs line numbering) for an already-running board, one that ignored a DTR reset, or a missed `start`. - Raise HostError when the controller never responds, instead of the old "drain until quiet" silently reporting ready on a dead port. - Detect a fatal/halt line during boot. SerialTransport.reset(): - Use the printrun sequence (assert DTR, hold, release) so the line is never left asserted (the previous toggle ended with dtr=True). - Stop flushing the input buffer so connect() can match `start`. - Expose dtr/rts/assert_hold knobs; RTS untouched by default. All logic is tested hardware-free via FakeTransport / mocked pyserial. The board-specific timings remain knobs; hardware verification is tracked in #4.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hardens the two hardware-boundary surfaces (the only parts of the MVP not yet hardware-validated), grounded in the Marlin 2.1.x source and printrun/OctoPrint conventions (research in
working/serial-reset.md). Toward #4.MarlinHost.connect()Replaces "drain until quiet, then always report ready" with a real handshake:
startboot line (MarlinCore.cpp:1223) as the positive ready signal, then drain the banner until quiet.ok/temperature/position line → ready outright.wait/busykeepalive → sign of life: ready if the banner was already seen, else break to the probe. (This is the fix for the review-found hang below.)M110 N0up toconnect_probestimes and accept theok— which also syncs line numbering on an already-running board.HostErrorif the controller never responds, instead of silently reporting ready on a dead port.SerialTransport.reset()assert_hold, release — so the line is never left asserted (the previous code ended withdtr=True).connect()can matchstart.dtr/rts/assert_holdknobs; RTS untouched by default.Review gate
Independent adversarial review (verdict NEEDS-WORK → fixed) caught a real bug: an idle board emitting
waitkeepalives (NO_TIMEOUTS) every ~1s would spin Phase 1 forever (it only exited on silence) and never reach the probe — the exact already-running case the probe exists for. Fixed by treating keepalives as a sign of life, plus two regression tests (wait→probe, banner+wait→ready). Reviewer verified line-numbering, reset polarity, and halt handling correct.Hardware
All logic is tested hardware-free (88 tests;
FakeTransport/ mocked pyserial). The board-specific timings remain knobs; the hardware-verification checklist is tracked in #4.just checkclean (ruff + pyright 0 errors) ·just test88 passed.