Skip to content

Fix M03 spindle-speed recovery for resume-at-line#679

Draft
righteousgambit wants to merge 1 commit into
Carvera-Community:developfrom
righteousgambit:agent/fix-resume-m03-speed
Draft

Fix M03 spindle-speed recovery for resume-at-line#679
righteousgambit wants to merge 1 commit into
Carvera-Community:developfrom
righteousgambit:agent/fix-resume-m03-speed

Conversation

@righteousgambit

@righteousgambit righteousgambit commented Jul 13, 2026

Copy link
Copy Markdown

Closes #670

Summary

Use the controller's existing tokenizer and normalized command matcher for resume-at-line spindle-speed recovery, allowing zero-padded M03 commands to restore their programmed S value.

Changes

  • Add a focused line parser that recognizes normalized M3/M03 tokens and extracts the last valid S token.
  • Reuse that parser for both backward-search passes instead of duplicating literal M3 regular expressions.
  • Add tests for zero-padded, tightly packed, inherited-speed, comment, and M030 boundary cases plus the final resume preview.
  • Add an unreleased changelog entry.

Why

The general resume logic already recognizes M03 as spindle-on, but the speed helper did not. That mismatch caused the final recovery command to omit the programmed RPM and rely on retained firmware state.

Bare M3 is not guaranteed to stop the spindle; it can retain an earlier speed. The correctness and safety concern is nondeterministic stale, wrong, or zero RPM depending on state. This change explicitly restores the file's programmed value.

Validation

  • Regression against the pinned develop implementation: 5 failed, 1 passed; zero-padded cases returned None, and the preview emitted bare buffer M3 instead of buffer M3 S12000.
  • With this change, using the same exact-ref sparse harness: PYTHONDONTWRITEBYTECODE=1 PYTHONPATH=/tmp/carvera-test-stubs:. pytest -q tests/unit/test_resume_m03_speed.py -> 6 passed.
  • ruff check carveracontroller/Controller.py tests/unit -> passed.
  • git diff --check develop...HEAD -> passed.

Real branch verification

The repository's locked Poetry environment was installed from poetry.lock. The targeted suite passed on real fork commit e055b6bfe50c, whose sole parent is pinned upstream develop@2ea66c10e96d88013a04441134d3d4f8e8c88510.

poetry run pytest -q tests/unit/test_resume_m03_speed.py

Result: 6 passed.

Quality gates on the real branch:

  • Ruff check: passed
  • Ruff format --check: passed
  • git diff --check 2ea66c10e96d88013a04441134d3d4f8e8c88510..e055b6bfe50c7b34517e6c2b7a0023f4eb2fec2a: passed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant