Host-side Python library for the Marlin firmware serial protocol.
Project description
marlin-host
A host-side Python library for the Marlin firmware serial protocol — the
PC/host end of the line-numbered, checksummed, ok-acknowledged G-code
conversation that hosts like OctoPrint and Pronterface speak to a printer or
CNC running Marlin. Neutral and standalone; not tied to any one application.
Status: MVP. Connect, M115 negotiation, reliable framed send, streaming, queries, and out-of-band e-stop are implemented and validated against real hardware (RAMPS 1.4 / Marlin
bugfix-2.1.x, logic level — motion/thermal validation under power is ongoing). Developed against the Marlin firmware source and official docs. Licensed Apache-2.0.
Repository conventions
A few top-level directories are gitignored (local-only) and used while developing — they are intentionally not version-controlled:
working/— scratch material we generate: protocol references, design notes, research write-ups. Local working files, not shipped._reference/— external material pulled in to build against: Marlin firmware source, docs, and other technical references. Third-party, large, and in flux, so kept out of the repo.planning/— planning notes and task breakdowns.
Anything intended to ship — the library, its tests, and curated docs — lives in
tracked directories, never in working/, _reference/, or planning/.
Develop
just setup # uv sync
just check # ruff format-check + lint + pyright (CI-equivalent)
just test # pytest
Usage
Parse a single response line:
from marlin_host import parse_response
resp = parse_response("ok N12 P15 B3")
resp.is_ack # True
resp.fields # {'N': 12.0, 'P': 15.0, 'B': 3.0}
parse_response("Resend: 13").resend_line # 13
parse_response("echo:busy: processing").is_keepalive # True
Drive a real controller (pip install 'marlin-host[serial]'):
from marlin_host import MarlinHost, SerialTransport
host = MarlinHost(SerialTransport("/dev/ttyUSB0", 250000), reliable=True)
host.connect() # resets the board, drains the startup banner
print(host.capabilities().firmware)
host.send("G28") # homes; returns when the controller acks `ok`
for progress in host.stream(open("part.gcode")):
print(f"{progress.commands_sent}/{progress.total_commands}")
host.emergency_stop() # M112, out-of-band
Develop and test against FakeTransport — no hardware required.
Console
An interactive console for hands-on bring-up:
marlin-host --port /dev/ttyUSB0 --reliable --log session.trace
# then type G-code, or :caps :stream part.gcode :estop :quit
--log records every TX/RX line (via TracingTransport) — a captured session
that can seed the conformance corpus.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file marlin_host-0.2.0.tar.gz.
File metadata
- Download URL: marlin_host-0.2.0.tar.gz
- Upload date:
- Size: 45.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c91c52b9a84d4499ec403df8a7a2f47483867cba371786224cde50cab7b1a951
|
|
| MD5 |
35e343618533e0568c50b87973be7786
|
|
| BLAKE2b-256 |
451334d925c05c7253e0a78eff7788bbd4bbb533e0dadeb3c5bb509903e4db97
|
Provenance
The following attestation bundles were made for marlin_host-0.2.0.tar.gz:
Publisher:
release.yml on fiberpath/marlin-host
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
marlin_host-0.2.0.tar.gz -
Subject digest:
c91c52b9a84d4499ec403df8a7a2f47483867cba371786224cde50cab7b1a951 - Sigstore transparency entry: 1988230076
- Sigstore integration time:
-
Permalink:
fiberpath/marlin-host@4daccff069ac5cbd51a03386754edf8895a3d1d0 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/fiberpath
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@4daccff069ac5cbd51a03386754edf8895a3d1d0 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file marlin_host-0.2.0-py3-none-any.whl.
File metadata
- Download URL: marlin_host-0.2.0-py3-none-any.whl
- Upload date:
- Size: 23.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e7343822e74d0ac0ce0654fe265c3433979c6ceb840c2645412f2d0c404f2d9b
|
|
| MD5 |
6b414a68a61f8f57f04cbb97e01be7a8
|
|
| BLAKE2b-256 |
7eae415546b0a027e66c8013fc7f0da8067604d9e3fcd8c5ab54c599e944b349
|
Provenance
The following attestation bundles were made for marlin_host-0.2.0-py3-none-any.whl:
Publisher:
release.yml on fiberpath/marlin-host
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
marlin_host-0.2.0-py3-none-any.whl -
Subject digest:
e7343822e74d0ac0ce0654fe265c3433979c6ceb840c2645412f2d0c404f2d9b - Sigstore transparency entry: 1988230178
- Sigstore integration time:
-
Permalink:
fiberpath/marlin-host@4daccff069ac5cbd51a03386754edf8895a3d1d0 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/fiberpath
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@4daccff069ac5cbd51a03386754edf8895a3d1d0 -
Trigger Event:
workflow_dispatch
-
Statement type: