raydriver.marlin.parser
Pure parsers for Marlin response data: ok/error classification, boot banners, M114 positions, M115 firmware info and M149 units. All functions are side-effect free.
Functions
detect_unit_system_from_m149()
detect_unit_system_from_m149(lines: Sequence[str]) -> Optional[str]
Infer the device unit system from M149 response lines ("metric"/"imperial"), or None.
| Parameter | Type | Description |
|---|---|---|
lines | Sequence[str] | |
| Returns | Optional[str] |
extract_marlin_banner_from_output()
extract_marlin_banner_from_output(data: Sequence[int]) -> Optional[str]
Extract the first boot message line from raw serial output, or None.
| Parameter | Type | Description |
|---|---|---|
data | Sequence[int] | |
| Returns | Optional[str] |
extract_marlin_device_name()
extract_marlin_device_name(
m115_lines: Sequence[str],
boot_lines: Optional[Sequence[str]],
) -> str
Extract a human-readable device name from M115 and boot output.
| Parameter | Type | Description |
|---|---|---|
m115_lines | Sequence[str] | |
boot_lines | Optional[Sequence[str]] | |
| Returns | str |
is_boot_message()
is_boot_message(line: str) -> bool
True when line is a Marlin boot/startup message.
| Parameter | Type | Description |
|---|---|---|
line | str | |
| Returns | bool |
is_error_response()
is_error_response(line: str) -> bool
True when line is a Marlin error response (Error:...).
| Parameter | Type | Description |
|---|---|---|
line | str | |
| Returns | bool |
is_m114_position()
is_m114_position(line: str) -> bool
True when line carries an M114 position report.
| Parameter | Type | Description |
|---|---|---|
line | str | |
| Returns | bool |
is_marlin_output()
is_marlin_output(data: Sequence[int]) -> bool
True when raw serial output identifies a Marlin device.
| Parameter | Type | Description |
|---|---|---|
data | Sequence[int] | |
| Returns | bool |
is_ok_response()
is_ok_response(line: str) -> bool
True when line is a Marlin ok acknowledgement (plain or with temperature payload).
| Parameter | Type | Description |
|---|---|---|
line | str | |
| Returns | bool |
parse_error_message()
parse_error_message(line: str) -> str
Extract the message portion of an Error:... line.
| Parameter | Type | Description |
|---|---|---|
line | str | |
| Returns | str |
parse_m114_line()
parse_m114_line(line: str) -> Optional[tuple[float, float, float]]
Parse a single M114 position line, or None.
| Parameter | Type | Description |
|---|---|---|
line | str | |
| Returns | Optional[tuple[float, float, float]] |
parse_m114_position()
parse_m114_position(
lines: Sequence[str],
) -> Optional[tuple[float, float, float]]
Parse M114 output lines into an (x, y, z) position, or None.
| Parameter | Type | Description |
|---|---|---|
lines | Sequence[str] | |
| Returns | Optional[tuple[float, float, float]] |
parse_m115_firmware_info()
parse_m115_firmware_info(lines: Sequence[str]) -> dict[str, str]
Parse M115 response lines into firmware name and machine type.
| Parameter | Type | Description |
|---|---|---|
lines | Sequence[str] | |
| Returns | dict[str, str] |
parse_m211_endstops()
parse_m211_endstops(lines: Sequence[str]) -> Optional[tuple[float, float]]
Parse M211 output into (x_max, y_max) software endstop travel, or None.
| Parameter | Type | Description |
|---|---|---|
lines | Sequence[str] | |
| Returns | Optional[tuple[float, float]] |
parse_m503_settings()
parse_m503_settings(lines: Sequence[str]) -> dict[str, float]
Parse M503 output into key motion settings.
| Parameter | Type | Description |
|---|---|---|
lines | Sequence[str] | |
| Returns | dict[str, float] |
parse_marlin_version()
parse_marlin_version(line: str) -> Optional[str]
Extract the Marlin version from a boot line like Marlin 2.1.2.7, or None.
| Parameter | Type | Description |
|---|---|---|
line | str | |
| Returns | Optional[str] |