Repository navigation
Description
Tracking/research issue. Not yet actionable — capturing decisions and considerations so we can pick this up with context. Related: epic #187 (esp. #180, #182, #184).
Goal
Extract the machine-I/O protocol (fiberpath/execution/marlin.* + the new parser/transport from Phase 3) into a standalone, Apache-2.0, PyPI-published library under the fiberpath org. FiberPath then consumes it as a dependency.
Approach (agreed)
Build in-repo, extract at the seam. Implement Phases 1–3 of #187 inside fiberpath/fiberpath, but structure the protocol code as if it were already a package: pure transport + protocol + parser, zero deps on fiberpath.config, the GUI, or the IPC layer (those stay on the consumer side). Extract to its own repo + publish at the end of Phase 3 (before #183), when the API has stabilized — a near-mechanical move because the boundary was respected from day one.
License
Apache-2.0 (permissive → maximizes community reuse; fits the org's open ethos).
⚠️ License-compat consideration: Marlin firmware is GPL-3.0, and MarlinDocumentation has its own license. Any codegen that derives data from Marlin source/docs must be checked for compatibility with shipping that derived data under Apache-2.0 (derivative-work question). Resolve before doing codegen from GPL sources — may need to generate from a permissively-licensed/neutral source, or keep generated data in a separate, appropriately-licensed data file.
Naming (neutral — not fiberpath-marlin)
PyPI availability checked: pymarlin = taken; available: marlin-host, marlink, marlinlink, marlin-serial, reprap-host, gcode-host. Leaning marlin-host / marlink. (Pick alongside scope — see below.)
Source-of-truth / codegen ideas
- Runtime capability negotiation (preferred, version-proof): parse Marlin's
M115Cap:report at connect (Cap:EEPROM,Cap:AUTOREPORT_TEMP,Cap:HOST_ACTION_COMMANDS,Cap:PROGRESS, …) and adapt behavior to the actual firmware instead of assuming. Likely higher value than static codegen, since it survives version drift. (Feeds fix(execution): robust connection lifecycle — DTR/reset and readiness handshake #182.) - Partial codegen — G-code/M-code registry: generate a structured registry (code, brief, params) from
MarlinFirmware/MarlinDocumentation_gcode/*.mdfront-matter → JSON. Useful for validation, console help (feat(cli): human interactive machine console with serial TX/RX tracing #178), and dialect awareness. (Strongest codegen candidate — but see license note.) - Response taxonomy: the emitted strings (
ok/ok …,echo:busy,Resend:,Error:,T:, banner) are scattered/conditional in the C++ and not cleanly auto-extractable → hand-curate a documented taxonomy and validate it against the conformance corpus (test(execution): replay serial transport + recorded-trace conformance corpus #179/feat(execution): formal Marlin response taxonomy + state-machine parser #180) rather than codegen. - Config-flag → wire-behavior map: curate which
Configuration*.hflags change the wire protocol (ADVANCED_OK,HOST_KEEPALIVE_FEATURE,AUTO_REPORT_*,HOST_ACTION_COMMANDS,EMERGENCY_PARSER,EEPROM_SETTINGS, line-numbering) so the lib can reason about a given firmware build.
Other considerations to weigh
- Host Action Commands: handle
//action:messages (pause/paused/resume/cancel/prompt_*) — a proper host responds to firmware-initiated requests. (Taxonomy/feat(execution): formal Marlin response taxonomy + state-machine parser #180.) - Marlin version matrix / drift: tag the corpus and any generated registry by firmware version; prefer runtime detection over version assumptions; test against traces from multiple Marlin versions/configs.
- Transport abstraction + simulator: formalize the
SerialTransportProtocol (serial / RFC2217 / socket), and add aMarlinSimulatorfake that behaves like Marlin (acks, busy, temps, resend) for interactive tests beyond recorded replay. - API shape: sync core (current) vs async (asyncio) vs both. Decide the public surface deliberately; it affects the IPC layer (refactor: unify GUI<->subprocess IPC contract (single source of truth) #184) and the console (feat(cli): human interactive machine console with serial TX/RX tracing #178).
- Scope vs name: Marlin-only now, but keep the transport/protocol seam so a RepRapFirmware/Grbl backend could be added later. Broader scope ⇒ broader name (
reprap-host/gcode-host); Marlin-only ⇒marlin-host. - Packaging:
py.typed(typed lib), minimal deps (pyserial; optional extras), min Python version, SBOM, PyPI trusted publishing (org flow already proven on 0.7.3/0.7.4). - Docs: the normative protocol doc (feat(execution): formal Marlin response taxonomy + state-machine parser #180) becomes the lib's docs, aggregated by the existing multi-repo docs hub.
- Hardware-in-the-loop: an optional
@pytest.mark.hardwaresuite the maintainer runs at the lab, complementing the hardware-free corpus.
Decisions to resolve when picked up
- Final name + scope breadth (Marlin-only vs RepRap-general).
- Codegen depth (G-code registry: yes/no) and its license path (the GPL/Apache question above).
- Sync vs async public API.
- Min Python version + dependency surface.
Activity
CameronBrooks11 commentedon Jun 26, 2026
Plan-review verdict (2026-06-25): KEEP as a dormant gate. Build-in-repo-then-extract stands. Drop the codegen-from-Marlin-docs idea (license tarpit) until a concrete second consumer exists. Publish only when a 2nd consumer appears (the CLI console + the API job runner) rather than on a fixed date.
CameronBrooks11 commentedon Jun 26, 2026
Name decided (locked):
marlin-host(PyPI/repomarlin-host, importmarlin_host).Rationale: in the 3D-printing domain, host is the established term for the PC-side software that drives the firmware (OctoPrint, Pronterface are "hosts"), so
marlin-hostprecisely names a host-side implementation of the Marlin serial protocol — not firmware tooling. It is neutral (not fiberpath-branded), avoids the datedpyprefix, and sidesteps the PyPI-collision risk of a baremarlin/pymarlin. Fallback if unavailable at publish time:marlinhost.Approach (per decisions doc §4–6): build-in-repo-then-extract, Apache-2.0, hardware-free now (modeled from verified Marlin docs/source, synthetic conformance corpus), validate against real hardware next week. Build order: #180 (taxonomy/parser) → #179 (replay + corpus) → #181 (reliable transfer) → #182 (lifecycle) → extract here.
CameronBrooks11 commentedon Jun 28, 2026
Done.
marlin-hostexists and is published:marlin-host==0.1.0on PyPI (MVP, hardware-validated on RAMPS 1.4 / Marlin bugfix-2.1.x; mock/hardware-separated test suite). The extraction goal of this issue (standalone Apache-2.0, PyPI-published Marlin host-protocol library) is achieved. The consumer-side cutover — fiberpath depending on it and retiring the in-repo machine code — is tracked in the new epic #259. Closing.