Documentation
¶
Overview ¶
Package frame contains frame definitions and a frame parser.
Index ¶
- Constants
- type Frame
- type ReadError
- type ReadWriter
- type ReadWriterConf
- type Reader
- type ReaderConf
- type V1Frame
- type V2Frame
- func (f V2Frame) GenerateChecksum(crcExtra byte) uint16
- func (f V2Frame) GenerateSignature(key *V2Key) *V2Signature
- func (f V2Frame) GetChecksum() uint16
- func (f V2Frame) GetComponentID() byte
- func (f V2Frame) GetMessage() message.Message
- func (f V2Frame) GetSystemID() byte
- func (f V2Frame) IsSigned() bool
- type V2Key
- type V2Signature
- type Writer
- type WriterConf
- type WriterOutVersion
Constants ¶
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 )
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 { // returns the system id of the author of the frame. GetSystemID() byte // returns the component id of the author of the frame. GetComponentID() byte // returns the message wrapped in the frame. GetMessage() message.Message // returns the checksum of the frame. GetChecksum() uint16 // generates the checksum of the frame. GenerateChecksum(byte) uint16 // contains filtered or unexported methods }
Frame is the interface implemented by frames of every supported version.
type ReadError ¶
type ReadError struct {
// contains filtered or unexported fields
}
ReadError is the error returned in case of non-fatal parsing errors.
type ReadWriter ¶
ReadWriter is a Frame Reader and Writer.
func NewReadWriter ¶
func NewReadWriter(conf ReadWriterConf) (*ReadWriter, error)
NewReadWriter allocates a ReadWriter.
type ReadWriterConf ¶
type ReadWriterConf struct { // the underlying bytes ReadWriter. ReadWriter io.ReadWriter // (optional) the dialect which contains the messages that will be read. // If not provided, messages are decoded into the MessageRaw struct. DialectRW *dialect.ReadWriter // (optional) the secret key used to validate incoming frames. // Non-signed frames are discarded. This feature requires v2 frames. InKey *V2Key // Mavlink version used to encode messages. OutVersion WriterOutVersion // the system id, added to every outgoing frame and used to identify this // node in the network. OutSystemID byte // (optional) the component id, added to every outgoing frame, defaults to 1. OutComponentID byte // (optional) the value to insert into the signature link id. // This feature requires v2 frames. OutSignatureLinkID byte // (optional) the secret key used to sign outgoing frames. // This feature requires v2 frames. OutKey *V2Key }
ReadWriterConf is the configuration of a ReadWriter.
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader is a Frame reader.
type ReaderConf ¶
type ReaderConf struct { // the underlying bytes reader. Reader io.Reader // (optional) the dialect which contains the messages that will be read. // If not provided, messages are decoded into the MessageRaw struct. DialectRW *dialect.ReadWriter // (optional) the secret key used to validate incoming frames. // Non-signed frames are discarded. This feature requires v2 frames. InKey *V2Key }
ReaderConf is the configuration of a Reader.
type V1Frame ¶
type V1Frame struct { SequenceID byte SystemID byte ComponentID byte Message message.Message Checksum uint16 }
V1Frame is a Mavlink V1 frame.
func (V1Frame) GenerateChecksum ¶ added in v1.1.0
GenerateChecksum implements Frame.
func (V1Frame) GetComponentID ¶
GetComponentID implements Frame.
func (V1Frame) GetMessage ¶
GetMessage implements Frame.
type V2Frame ¶
type V2Frame struct { IncompatibilityFlag byte CompatibilityFlag byte SequenceID byte SystemID byte ComponentID byte Message message.Message Checksum uint16 SignatureLinkID byte SignatureTimestamp uint64 Signature *V2Signature }
V2Frame is a Mavlink V2 frame.
func (V2Frame) GenerateChecksum ¶ added in v1.1.0
GenerateChecksum implements Frame.
func (V2Frame) GenerateSignature ¶ added in v1.1.0
func (f V2Frame) GenerateSignature(key *V2Key) *V2Signature
GenerateSignature generates the frame signature.
func (V2Frame) GetComponentID ¶
GetComponentID implements Frame.
func (V2Frame) GetMessage ¶
GetMessage implements Frame.
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer is a Frame writer.
func (*Writer) WriteFrame ¶
WriteFrame writes a Frame. It must not be called by multiple routines in parallel. This function is intended only for routing pre-existing frames to other nodes, since all frame fields must be filled manually.
type WriterConf ¶
type WriterConf struct { // the underlying bytes writer. Writer io.Writer // (optional) the dialect which contains the messages that will be written. DialectRW *dialect.ReadWriter // Mavlink version used to encode messages. OutVersion WriterOutVersion // the system id, added to every outgoing frame and used to identify this // node in the network. OutSystemID byte // (optional) the component id, added to every outgoing frame, defaults to 1. OutComponentID byte // (optional) the value to insert into the signature link id. // This feature requires v2 frames. OutSignatureLinkID byte // (optional) the secret key used to sign outgoing frames. // This feature requires v2 frames. OutKey *V2Key }
WriterConf is the configuration of a Writer.
type WriterOutVersion ¶
type WriterOutVersion int
WriterOutVersion is a Mavlink version.
const ( // V1 is Mavlink 1.0 V1 WriterOutVersion = 1 // V2 is Mavlink 2.0 V2 WriterOutVersion = 2 )
func (WriterOutVersion) String ¶
func (v WriterOutVersion) String() string
String implements fmt.Stringer.