मुख्य सामग्री पर जाएँ

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.

ParameterTypeDescription
linesSequence[str]
ReturnsOptional[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.

ParameterTypeDescription
dataSequence[int]
ReturnsOptional[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.

ParameterTypeDescription
m115_linesSequence[str]
boot_linesOptional[Sequence[str]]
Returnsstr

is_boot_message()​

is_boot_message(line: str) -> bool

True when line is a Marlin boot/startup message.

ParameterTypeDescription
linestr
Returnsbool

is_error_response()​

is_error_response(line: str) -> bool

True when line is a Marlin error response (Error:...).

ParameterTypeDescription
linestr
Returnsbool

is_m114_position()​

is_m114_position(line: str) -> bool

True when line carries an M114 position report.

ParameterTypeDescription
linestr
Returnsbool

is_marlin_output()​

is_marlin_output(data: Sequence[int]) -> bool

True when raw serial output identifies a Marlin device.

ParameterTypeDescription
dataSequence[int]
Returnsbool

is_ok_response()​

is_ok_response(line: str) -> bool

True when line is a Marlin ok acknowledgement (plain or with temperature payload).

ParameterTypeDescription
linestr
Returnsbool

parse_error_message()​

parse_error_message(line: str) -> str

Extract the message portion of an Error:... line.

ParameterTypeDescription
linestr
Returnsstr

parse_m114_line()​

parse_m114_line(line: str) -> Optional[tuple[float, float, float]]

Parse a single M114 position line, or None.

ParameterTypeDescription
linestr
ReturnsOptional[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.

ParameterTypeDescription
linesSequence[str]
ReturnsOptional[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.

ParameterTypeDescription
linesSequence[str]
Returnsdict[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.

ParameterTypeDescription
linesSequence[str]
ReturnsOptional[tuple[float, float]]

parse_m503_settings()​

parse_m503_settings(lines: Sequence[str]) -> dict[str, float]

Parse M503 output into key motion settings.

ParameterTypeDescription
linesSequence[str]
Returnsdict[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.

ParameterTypeDescription
linestr
ReturnsOptional[str]