frame

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 28, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package frame contains frames and utilities to encode and decode them.

Index

Constants

View Source
const (
	// V2MagicByte is the magic byte of a V2 frame.
	V2MagicByte = 0xFD

	// V2FlagSigned is the flag of a V2 frame that indicates that the frame is signed.
	V2FlagSigned = 0x01
)
View Source
const (
	// V1MagicByte is the magic byte of a V1 frame.
	V1MagicByte = 0xFE
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Frame

type Frame interface {
	// the system id of the author of the frame.
	GetSystemID() byte

	// the component id of the author of the frame.
	GetComponentID() byte

	// the message encapsuled in the frame.
	GetMessage() msg.Message

	// the frame checksum.
	GetChecksum() uint16

	// generate a clone of the frame
	Clone() Frame

	// decode the frame
	Decode(*bufio.Reader) error

	// encode the frame
	Encode([]byte, []byte) ([]byte, error)

	// generate the checksum
	GenChecksum(byte) uint16
}

Frame is the interface implemented by frames of every supported version.

type V1Frame

type V1Frame struct {
	SequenceID  byte
	SystemID    byte
	ComponentID byte
	Message     msg.Message
	Checksum    uint16
}

V1Frame is a Mavlink V1 frame.

func (*V1Frame) Clone

func (f *V1Frame) Clone() Frame

Clone implements the Frame interface.

func (*V1Frame) Decode

func (f *V1Frame) Decode(br *bufio.Reader) error

Decode implements the Frame interface.

func (*V1Frame) Encode

func (f *V1Frame) Encode(buf []byte, msgEncoded []byte) ([]byte, error)

Encode implements the Frame interface.

func (*V1Frame) GenChecksum

func (f *V1Frame) GenChecksum(crcExtra byte) uint16

GenChecksum implements the Frame interface.

func (*V1Frame) GetChecksum

func (f *V1Frame) GetChecksum() uint16

GetChecksum implements the Frame interface.

func (*V1Frame) GetComponentID

func (f *V1Frame) GetComponentID() byte

GetComponentID implements the Frame interface.

func (*V1Frame) GetMessage

func (f *V1Frame) GetMessage() msg.Message

GetMessage implements the Frame interface.

func (*V1Frame) GetSystemID

func (f *V1Frame) GetSystemID() byte

GetSystemID implements the Frame interface.

type V2Frame

type V2Frame struct {
	IncompatibilityFlag byte
	CompatibilityFlag   byte
	SequenceID          byte
	SystemID            byte
	ComponentID         byte
	Message             msg.Message
	Checksum            uint16
	SignatureLinkID     byte
	SignatureTimestamp  uint64
	Signature           *V2Signature
}

V2Frame is a Mavlink V2 frame.

func (*V2Frame) Clone

func (f *V2Frame) Clone() Frame

Clone implements the Frame interface.

func (*V2Frame) Decode

func (f *V2Frame) Decode(br *bufio.Reader) error

Decode implements the Frame interface.

func (*V2Frame) Encode

func (f *V2Frame) Encode(buf []byte, msgEncoded []byte) ([]byte, error)

Encode implements the Frame interface.

func (*V2Frame) GenChecksum

func (f *V2Frame) GenChecksum(crcExtra byte) uint16

GenChecksum implements the Frame interface.

func (*V2Frame) GenSignature

func (f *V2Frame) GenSignature(key *V2Key) *V2Signature

GenSignature generates a signature with the given key.

func (*V2Frame) GetChecksum

func (f *V2Frame) GetChecksum() uint16

GetChecksum implements the Frame interface.

func (*V2Frame) GetComponentID

func (f *V2Frame) GetComponentID() byte

GetComponentID implements the Frame interface.

func (*V2Frame) GetMessage

func (f *V2Frame) GetMessage() msg.Message

GetMessage implements the Frame interface.

func (*V2Frame) GetSystemID

func (f *V2Frame) GetSystemID() byte

GetSystemID implements the Frame interface.

func (*V2Frame) IsSigned

func (f *V2Frame) IsSigned() bool

IsSigned checks whether the frame contains a signature. It does not validate the signature.

type V2Key

type V2Key [32]byte

V2Key is a key able to sign and validate V2 frames.

func NewV2Key

func NewV2Key(in []byte) *V2Key

NewV2Key allocates a V2Key.

type V2Signature

type V2Signature [6]byte

V2Signature is a V2 frame signature.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL