Skip to main content

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

Requires uv and just.

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.

Metadata

Release files for marlin-host 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for marlin-host 0.2.1
File Size Uploaded Provenance
marlin_host-0.2.1.tar.gz 46.5 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for marlin-host 0.2.1
File Interpreter ABI Platform
marlin_host-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 70.3 kB

Release files / marlin_host-0.2.1.tar.gz

Download URL marlin_host-0.2.1.tar.gz
Size 46.5 kB
Tags Source
SHA-256 checksum
How to use checksums
6361bfc2e644dfbf53fcad2681dcced6f24c3e5760515e58f01540043a842952
BLAKE2b-256 checksum
How to use checksums
76a9566312b72260f281c426ff36865b133f967519edfe5650117aef058598db
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 28, 2026.

Transparency log

Release files / marlin_host-0.2.1-py3-none-any.whl

Download URL marlin_host-0.2.1-py3-none-any.whl
Size 23.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f11c26843c7376a2c0ab02f730487656639088dd806b1f8d174ad022a0bc1b22
BLAKE2b-256 checksum
How to use checksums
d8a259e396685118c4563f24b9c68a4dd1ed9bfd5ceb5e285cf257fc5609c50f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 28, 2026.

Transparency log

Security for marlin-host 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for marlin_host-0.2.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 28, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page