Skip to content

watlowlib.firmware

FirmwareVersion — orderable major.minor.patch wrapper used for min_firmware gates on Command specs.

Public surface

watlowlib.firmware

Firmware version parsing + comparison.

Watlow exposes firmware identity as parameter 1002 (S32); the user- facing version is derived from the build / branch / prototype triple (parameters 1004 / 1006 / 1002 in PM Map 1) but a simple major.minor form is enough for command gating.

:class:FirmwareVersion is the type stored on :attr:watlowlib.commands.base.Command.min_firmware. The session compares the device-reported version against the command's minimum before dispatch.

FirmwareVersion dataclass

FirmwareVersion(major, minor=0, patch=0)

Semantic firmware version (major.minor.patch).

order=True makes the dataclass orderable on its tuple of fields, which matches the major.minor.patch precedence callers expect.

parse classmethod

parse(text)

Parse a string like "1", "1.2", "1.2.3", or "v1.2".

Source code in src/watlowlib/firmware.py
@classmethod
def parse(cls, text: str) -> Self:
    """Parse a string like ``"1"``, ``"1.2"``, ``"1.2.3"``, or ``"v1.2"``."""
    m = _PARSE_RE.match(text)
    if m is None:
        raise ValueError(f"invalid firmware version: {text!r}")
    major = int(m.group(1))
    minor = int(m.group(2) or 0)
    patch = int(m.group(3) or 0)
    return cls(major, minor, patch)