Skip to content

feat(api): Marlin machine-control surface on the sidecar (#190, #199) - #260

Merged
CameronBrooks11 merged 2 commits into
mainfrom
feat/api-machine-routes
Jun 28, 2026
Merged

CameronBrooks11 merged 2 commits into
mainfrom
feat/api-machine-routes

Conversation

@CameronBrooks11

Copy link
Copy Markdown
Member

First backend slice of the machine cutover (epic #195): the API sidecar now owns the serial port via the published marlin-host library, replacing the bespoke streamer for the API path.

New /machine routes

GET /ports, POST|DELETE /connection, POST /commands, POST /jobs, GET /jobs/{id}?since= (polled cursor), POST /jobs/{id}/pause|resume|cancel, POST /estop.

A MachineService singleton holds a MarlinHost and runs a background job worker; a lock serializes manual /commands against the streaming job; /estop writes M112 out-of-band bypassing the lock (#196).

Dependency

marlin-host[serial]>=0.2.1 — its io lock makes send/query/stream mutually thread-safe (closes a paused-manual-send race), and py.typed lets mypy type-check the integration (the override is gone).

Validation

  • Backend gate green: ruff, format, mypy (real marlin_host types), 129 tests (12 new /machine tests, hardware-free via FakeTransport).
  • Validated end-to-end against a real RAMPS 1.4 board: ports → connect (firmware banner) → manual M114 → stream a job (cursor-polled progress → completed) → estop → disconnect.
  • OpenAPI spec + generated TS client regenerated (both CI drift gates).

Scope

Additive — does not yet wire the GUI (still on the stdio subprocess) or delete execution/marlin.py (still used by interactive.py). Those are the later cutover slices (#193/#194 GUI, then the deletes). Implements the backend of #190/#199.

The sidecar now owns the serial port via marlin-host. New /machine routes:
ports, connection (connect/disconnect), commands (manual), jobs (start +
polled GET /jobs/{id}?since= cursor + pause/resume/cancel), and estop.

A MachineService singleton holds a MarlinHost and runs a background job
worker; a lock serializes manual commands against the streaming job, and
emergency_stop() writes M112 out-of-band bypassing the lock (#196).

Depends on marlin-host[serial]>=0.2.1 (its io lock makes send/stream
mutually thread-safe; py.typed lets mypy check the integration). OpenAPI
spec + generated TS client regenerated. Backend gate green (ruff/mypy/
129 tests); /machine validated end-to-end against a real RAMPS board.

Does not yet wire the GUI (still on the stdio subprocess) or remove the
old execution/marlin.py — those are later cutover slices. Part of #195.
The sidecar now owns the serial port, so the frozen binary needs the
machine route, marlin_host, and pyserial's dynamically-imported platform
backend (serialposix/serialwin32 + list_ports) — mirroring the existing
serial collection in freeze_cli.py.
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