Class MavlinkSchema
The shape of one message: its id, name, seed, and fields.
public sealed class MavlinkSchema : IDisposable
- Inheritance
-
MavlinkSchema
- Implements
- Inherited Members
Remarks
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
CrcExtra
The seed a frame carrying this message folds into its checksum.
public byte CrcExtra { get; }
Property Value
Fields
The fields in wire order: the base fields largest first, then extensions.
public IReadOnlyList<MavlinkFieldInfo> Fields { get; }
Property Value
MessageId
The id of the message this schema describes.
public uint MessageId { get; }
Property Value
Name
The name of the message this schema describes.
public string Name { get; }
Property Value
WireLength
The length of the message on the wire, in bytes, extensions included.
public int WireLength { get; }
Property Value
Methods
CreateMessage()
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.
Decode(ReadOnlySpan<byte>)
Reads a message out of a frame payload.
public MavlinkMessage Decode(ReadOnlySpan<byte> payload)
Parameters
payloadReadOnlySpan<byte>The frame payload.
Returns
- MavlinkMessage
The decoded message.
Remarks
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.
Dispose()
Releases the schema.
public void Dispose()
ForId(uint)
Returns the shape of a message the engine types, by id.
public static MavlinkSchema ForId(uint msgid)
Parameters
msgiduintThe message id to look up.
Returns
- MavlinkSchema
The shape.
Exceptions
- PamojaException
This build does not type that id, which is what MavlinkSchemaBuilder is for.
ForName(string)
Returns the shape of a message the engine types, by name.
public static MavlinkSchema ForName(string name)
Parameters
namestringThe message name, such as
GLOBAL_POSITION_INT.
Returns
- MavlinkSchema
The shape.
Exceptions
- PamojaException
This build does not type that name.
KnownMessages()
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).