pamoja-mavlink
MAVLink v1 and v2 framing, signing, named message fields and enum values, and the mission, command, and offboard protocols. One capability of pamoja, one memory-safe Rust core with bindings for TypeScript, Python, and C#.
Install
pip install pamoja-mavlink
from pamoja import mavlink
This pulls in pamoja-native, the compiled engine. pip install pamoja is the whole framework in one package.
Example
The script the test suite runs, spliced here as it ran.
From bindings/python/guides/mavlink.py:
from pamoja.mavlink import (
MavlinkHeader,
MavlinkMessage,
MavlinkParser,
enum_entry,
enum_names,
enum_value,
from_dict,
schema_for,
)
VEHICLE = 1
AUTOPILOT = 1
STATION = 255
PLANNER = 190
# An enum field travels as a number, and the dialect names each number. Printing the name
# keeps a reader from looking up what 2 or 81 means.
def name(enumeration: str, value: int) -> str:
return enum_entry(enumeration, value) or str(value)
# Every node broadcasts a heartbeat to say what it is and that it is alive. The frame wraps
# the payload in a header and a checksum seeded with the message's own value.
heartbeat_shape = schema_for("HEARTBEAT")
announce = from_dict(
heartbeat_shape,
{
"type": enum_value("MAV_TYPE_GCS"),
"autopilot": enum_value("MAV_AUTOPILOT_INVALID"),
"system_status": enum_value("MAV_STATE_ACTIVE"),
"mavlink_version": 3,
},
)
sent = announce.to_frame(MavlinkHeader(STATION, PLANNER, 0))
print(f"sent {heartbeat_shape.name} in {len(sent.bytes)} bytes")
# The vehicle answers with its own heartbeat, which reaches the station behind some noise and
# a copy with its last byte flipped in flight.
vehicle = from_dict(
heartbeat_shape,
{
"type": enum_value("MAV_TYPE_QUADROTOR"),
"autopilot": enum_value("MAV_AUTOPILOT_ARDUPILOTMEGA"),
"base_mode": enum_value("MAV_MODE_FLAG_CUSTOM_MODE_ENABLED")
| enum_value("MAV_MODE_FLAG_STABILIZE_ENABLED")
| enum_value("MAV_MODE_FLAG_MANUAL_INPUT_ENABLED"),
"system_status": enum_value("MAV_STATE_STANDBY"),
"mavlink_version": 3,
},
)
good = vehicle.to_frame(MavlinkHeader(VEHICLE, AUTOPILOT, 0))
garbled = bytearray(good.bytes)
garbled[-1] ^= 0xFF
delivered = b"???" + bytes(garbled) + good.bytes
# The parser skips whatever does not start a frame and drops a frame whose checksum fails, so
# only the good copy comes out.
frames = MavlinkParser().push(delivered)
print(
f"parsed {len(frames)} frame out of {len(delivered)} bytes,"
" past the noise and the garbled copy"
)
heard = MavlinkMessage.decode(heartbeat_shape, frames[0].payload)
print(
f"heard {name('MAV_TYPE', heard.get_int('type'))} on"
f" {name('MAV_AUTOPILOT', heard.get_int('autopilot'))},"
f" in {name('MAV_STATE', heard.get_int('system_status'))}"
)
# The base mode is a bitmask, so it names a set of flags rather than one value.
base_mode = heard.get_int("base_mode")
print(f"flags {' | '.join(enum_names('MAV_MODE_FLAG', base_mode))}")
if base_mode & enum_value("MAV_MODE_FLAG_SAFETY_ARMED") == 0:
print("disarmed MAV_MODE_FLAG_SAFETY_ARMED is not among them")
The same capability in every language
| Language | Package | Reference |
|---|---|---|
| Rust | pamoja-mavlink |
reference, docs.rs, install |
| TypeScript | @pamoja/mavlink |
reference, install |
| Python | pamoja-mavlink |
reference, install |
| C# | Pamoja.Mavlink |
reference, install |
Documentation
pamoja.mavlinkreference, every class and function in this module.- The MAVLink guide, with the same example in Rust, TypeScript, and C#.
- Every capability, and the install page.
License
MIT
Metadata
Release files for pamoja-mavlink 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pamoja_mavlink-0.2.1.tar.gz | 8.6 kB | Without provenance | Details for pamoja_mavlink-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pamoja_mavlink-0.2.1-py3-none-any.whl | Python 3 | none | any | Details for pamoja_mavlink-0.2.1-py3-none-any.whl |
Total release size: 18.1 kB
Release files / pamoja_mavlink-0.2.1.tar.gz
| Download URL | pamoja_mavlink-0.2.1.tar.gz |
|---|---|
| Size | 8.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7c9e0ab9a96571d5f33b48a3bd18ceb9fc0ac33ca464296ceb149c391967adbe
|
|
BLAKE2b-256 checksum How to use checksums |
704397d93bd8078878bb3e8bcdf7b370b03987a7f1bc99e94905b1882c68ae5c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.18
|
Release files / pamoja_mavlink-0.2.1-py3-none-any.whl
| Download URL | pamoja_mavlink-0.2.1-py3-none-any.whl |
|---|---|
| Size | 9.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f91c94fb8740df772d3063c13fb43c7bda91b4236e976b8421f865f2fcde059d
|
|
BLAKE2b-256 checksum How to use checksums |
794bd09e7423e78d6bd66aba0dacadf21063d04f5dc855d0e8490391701972ce
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.18
|
Security for pamoja-mavlink 0.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.