Table of Contents

Class MavlinkFrame

Namespace
Pamoja.Mavlink
Assembly
Pamoja.Mavlink.dll

One MAVLink frame, assembled or received.

public sealed class MavlinkFrame : IDisposable
Inheritance
MavlinkFrame
Implements
Inherited Members

Properties

The whole frame, ready to put on the wire.

public byte[] Bytes { get; }

Property Value

byte[]

The addressing fields the frame carries.

public MavlinkHeader Header { get; }

Property Value

MavlinkHeader

The incompatibility flags a v2 frame declares.

public byte IncompatFlags { get; }

Property Value

byte

The id of the message the frame carries.

public uint MessageId { get; }

Property Value

uint

The message payload.

public byte[] Payload { get; }

Property Value

byte[]

A v2 frame drops trailing zero bytes, so a payload can arrive shorter than the message's full length; a decoder zero-extends it.

The signature block, or null when the frame is not signed.

public byte[]? Signature { get; }

Property Value

byte[]

Whether the frame carries a signature.

public bool Signed { get; }

Property Value

bool

This says only that the frame was signed, not that the signature is good; Verify(MavlinkFrame) decides that.

Which wire format this frame uses.

public MavlinkVersion Version { get; }

Property Value

MavlinkVersion

Methods

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

Assembles a v1 frame, for a peer that predates MAVLink 2.

public static MavlinkFrame EncodeV1(MavlinkHeader header, uint msgid, ReadOnlySpan<byte> payload, byte crcExtra)

Parameters

header MavlinkHeader

The addressing fields to stamp on the frame.

msgid uint

The message id; a v1 frame only carries ids below 256.

payload ReadOnlySpan<byte>

The message payload.

crcExtra byte

The seed for this message id.

Returns

MavlinkFrame

The frame ready to send.

Exceptions

PamojaException

The id or payload does not fit a v1 frame.

Assembles a v2 frame carrying a message.

public static MavlinkFrame EncodeV2(MavlinkHeader header, uint msgid, ReadOnlySpan<byte> payload, byte crcExtra)

Parameters

header MavlinkHeader

The addressing fields to stamp on the frame.

msgid uint

The message id.

payload ReadOnlySpan<byte>

The message payload.

crcExtra byte

The seed for this message id.

Returns

MavlinkFrame

The frame ready to send.

This is the current wire format and what a modern autopilot expects.

Exceptions

PamojaException

The payload does not fit a frame.

Parses one frame, checking it against a known CRC_EXTRA.

public static MavlinkFrame Parse(ReadOnlySpan<byte> bytes, byte crcExtra)

Parameters

bytes ReadOnlySpan<byte>

The frame as received.

crcExtra byte

The seed for the message the frame carries.

Returns

MavlinkFrame

The parsed frame.

Exceptions

PamojaException

The bytes are not a whole frame or the checksum does not match, which is what rejects a frame mangled in transit.

Parses one frame, looking its CRC_EXTRA up as it goes.

public static MavlinkFrame ParseKnown(ReadOnlySpan<byte> bytes, MavlinkDialect? dialect = null)

Parameters

bytes ReadOnlySpan<byte>

The frame as received.

dialect MavlinkDialect

The dialect to prefer, or null for the common one.

Returns

MavlinkFrame

The parsed frame.

This is what a receiver holding many message types uses: the id comes out of the frame, and the seed comes from the dialect or the common registry.

Exceptions

PamojaException

The bytes are not a whole frame, the checksum does not match, or no dialect here knows the message id.

Assembles a v2 frame carrying a message this build does not type.

public static MavlinkFrame Raw(MavlinkHeader header, uint msgid, byte crcExtra, ReadOnlySpan<byte> payload)

Parameters

header MavlinkHeader

The addressing fields to stamp on the frame.

msgid uint

The message id.

crcExtra byte

The seed for this message id.

payload ReadOnlySpan<byte>

The message payload.

Returns

MavlinkFrame

The frame ready to send.

The escape hatch a private dialect needs: supply the id, the payload, and the seed, and the frame is built and checked like any other.

Exceptions

PamojaException

The payload does not fit a frame.