Table of Contents

Class MavlinkSchema

Namespace
Pamoja.Mavlink
Assembly
Pamoja.Mavlink.dll

The shape of one message: its id, name, seed, and fields.

public sealed class MavlinkSchema : IDisposable
Inheritance
MavlinkSchema
Implements
Inherited Members

MavlinkFrame carries any message's bytes, which is enough to move traffic but leaves the caller hand-packing payloads against a message definition. A schema is the layer above: it states a message's fields, so a MavlinkMessage works in custom_mode and lat rather than byte offsets. Every message the engine types is published, and a message from ArduPilot's dialect, PX4's, or a vendor's private one is described through MavlinkSchemaBuilder.

Properties

The seed a frame carrying this message folds into its checksum.

public byte CrcExtra { get; }

Property Value

byte

The fields in wire order: the base fields largest first, then extensions.

public IReadOnlyList<MavlinkFieldInfo> Fields { get; }

Property Value

IReadOnlyList<MavlinkFieldInfo>

The id of the message this schema describes.

public uint MessageId { get; }

Property Value

uint

The name of the message this schema describes.

public string Name { get; }

Property Value

string

The length of the message on the wire, in bytes, extensions included.

public int WireLength { get; }

Property Value

int

Methods

Creates a message with every field zero.

public MavlinkMessage CreateMessage()

Returns

MavlinkMessage

The zeroed message, ready for its fields to be set.

Exceptions

PamojaException

The shape does not fit a MAVLink payload.

Reads a message out of a frame payload.

public MavlinkMessage Decode(ReadOnlySpan<byte> payload)

Parameters

payload ReadOnlySpan<byte>

The frame payload.

Returns

MavlinkMessage

The decoded message.

A shorter payload is zero-extended, as MAVLink 2 truncation requires, so a frame from a peer that trimmed trailing zeros or predates an extension field decodes.

Exceptions

PamojaException

The payload is longer than this shape describes.

Releases the schema.

public void Dispose()

Returns the shape of a message the engine types, by id.

public static MavlinkSchema ForId(uint msgid)

Parameters

msgid uint

The message id to look up.

Returns

MavlinkSchema

The shape.

Exceptions

PamojaException

This build does not type that id, which is what MavlinkSchemaBuilder is for.

Returns the shape of a message the engine types, by name.

public static MavlinkSchema ForName(string name)

Parameters

name string

The message name, such as GLOBAL_POSITION_INT.

Returns

MavlinkSchema

The shape.

Exceptions

PamojaException

This build does not type that name.

Returns the names of every message this build types, in id order.

public static IReadOnlyList<string> KnownMessages()

Returns

IReadOnlyList<string>

The message names, each usable with ForName(string).