Medius - BindingsInstall

Install

pip install medius

Install with pip. No compile step:

pip install medius

Prebuilt wheels cover Linux, macOS, and 64-bit Windows. The Bindings overview shows how the Python package, the C ABI, and the Rust medius crate fit together.

Requirements

What you need
RequirementValue
Python3.8 or newer
Platforms with a prebuilt wheelLinux (glibc / manylinux), macOS, Windows x64
Rust toolchainnot needed
Other Python packagesnone; it uses the standard library's ctypes

On musl Linux or 32-bit Windows there's no prebuilt wheel, so pip builds from source and needs a Rust toolchain. Those users follow Build & features.

Verify

Print the version

If this prints a version, you're ready for your first program.

python -c "import medius; print(medius.version_string(), 'abi', medius.abi_version())"
# 3.0.0 abi 3

An OSError on import means the native library didn't load: you're on an unsupported platform, or MEDIUS_LIB points somewhere bad. See how the library is found.

Connect

Find the box, then hand it back

Here it is in three lines, so you can check the box is reachable. Device.find() opens the first box it sees and runs the handshake; the with block closes the link on exit.

from medius import Device

with Device.find() as dev:
    v = dev.query_version()
    print(f"firmware {v.fw_major}.{v.fw_minor}.{v.fw_patch}, proto {v.proto_ver}")

No port? find() raises NotFoundError. Pass an explicit path with Device.open("/dev/ttyACM0") (Windows: "COM3"), or list what's present with medius.find_ports(). Errors are covered on Calls & errors.