Class MavlinkFrame
One MAVLink frame, assembled or received.
public sealed class MavlinkFrame : IDisposable
- Inheritance
-
MavlinkFrame
- Implements
- Inherited Members
Properties
Bytes
The whole frame, ready to put on the wire.
public byte[] Bytes { get; }
Property Value
- byte[]
Header
The addressing fields the frame carries.
public MavlinkHeader Header { get; }
Property Value
IncompatFlags
The incompatibility flags a v2 frame declares.
public byte IncompatFlags { get; }
Property Value
MessageId
The id of the message the frame carries.
public uint MessageId { get; }
Property Value
Payload
The message payload.
public byte[] Payload { get; }
Property Value
- byte[]
Remarks
A v2 frame drops trailing zero bytes, so a payload can arrive shorter than the message's full length; a decoder zero-extends it.
Signature
The signature block, or null when the frame is not signed.
public byte[]? Signature { get; }
Property Value
- byte[]
Signed
Whether the frame carries a signature.
public bool Signed { get; }
Property Value
Remarks
This says only that the frame was signed, not that the signature is good; Verify(MavlinkFrame) decides that.
Version
Which wire format this frame uses.
public MavlinkVersion Version { get; }
Property Value
Methods
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
EncodeV1(MavlinkHeader, uint, ReadOnlySpan<byte>, byte)
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
headerMavlinkHeaderThe addressing fields to stamp on the frame.
msgiduintThe message id; a v1 frame only carries ids below 256.
payloadReadOnlySpan<byte>The message payload.
crcExtrabyteThe seed for this message id.
Returns
- MavlinkFrame
The frame ready to send.
Exceptions
- PamojaException
The id or payload does not fit a v1 frame.
EncodeV2(MavlinkHeader, uint, ReadOnlySpan<byte>, byte)
Assembles a v2 frame carrying a message.
public static MavlinkFrame EncodeV2(MavlinkHeader header, uint msgid, ReadOnlySpan<byte> payload, byte crcExtra)
Parameters
headerMavlinkHeaderThe addressing fields to stamp on the frame.
msgiduintThe message id.
payloadReadOnlySpan<byte>The message payload.
crcExtrabyteThe seed for this message id.
Returns
- MavlinkFrame
The frame ready to send.
Remarks
This is the current wire format and what a modern autopilot expects.
Exceptions
- PamojaException
The payload does not fit a frame.
Parse(ReadOnlySpan<byte>, byte)
Parses one frame, checking it against a known CRC_EXTRA.
public static MavlinkFrame Parse(ReadOnlySpan<byte> bytes, byte crcExtra)
Parameters
bytesReadOnlySpan<byte>The frame as received.
crcExtrabyteThe 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.
ParseKnown(ReadOnlySpan<byte>, MavlinkDialect?)
Parses one frame, looking its CRC_EXTRA up as it goes.
public static MavlinkFrame ParseKnown(ReadOnlySpan<byte> bytes, MavlinkDialect? dialect = null)
Parameters
bytesReadOnlySpan<byte>The frame as received.
dialectMavlinkDialectThe dialect to prefer, or
nullfor the common one.
Returns
- MavlinkFrame
The parsed frame.
Remarks
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.
Raw(MavlinkHeader, uint, byte, ReadOnlySpan<byte>)
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
headerMavlinkHeaderThe addressing fields to stamp on the frame.
msgiduintThe message id.
crcExtrabyteThe seed for this message id.
payloadReadOnlySpan<byte>The message payload.
Returns
- MavlinkFrame
The frame ready to send.
Remarks
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.