Skip to main content

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

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

marlin_host-0.1.0.tar.gz (44.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

marlin_host-0.1.0-py3-none-any.whl (22.8 kB view details)

Uploaded Python 3

File details

Details for the file marlin_host-0.1.0.tar.gz.

File metadata

  • Download URL: marlin_host-0.1.0.tar.gz
  • Upload date:
  • Size: 44.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for marlin_host-0.1.0.tar.gz
Algorithm Hash digest
SHA256 edbdbfbd869409613e9b827111cf9fdec9286f4cb5928406f7360897db4c8431
MD5 68fa52f74feabfb9d57567b7f1d8f826
BLAKE2b-256 abe18b2fbfbfa83f110bdeb41ebb5fea8dc74809cdbc4811f3273c2f1fab41d7

See more details on using hashes here.

Provenance

The following attestation bundles were made for marlin_host-0.1.0.tar.gz:

Publisher: release.yml on fiberpath/marlin-host

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file marlin_host-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: marlin_host-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 22.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for marlin_host-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d6e608956981c3fc9b7641fea8cff5071558c41d7336bf9fd5474eac88ca432e
MD5 dbe0d556c2ea994f8b5a2faa7f15a4e0
BLAKE2b-256 904d0e4660012a6d34823b2ab1e090cf76fb339e552eac97355c29eddd2139d5

See more details on using hashes here.

Provenance

The following attestation bundles were made for marlin_host-0.1.0-py3-none-any.whl:

Publisher: release.yml on fiberpath/marlin-host

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page