Documentation
¶
Overview ¶
Package frame contains frame definitions and a frame parser.
Index ¶
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 {
// generates a clone of the frame.
Clone() Frame
// 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 encapsuled in the frame.
GetMessage() message.Message
// returns the checksum of the frame.
GetChecksum() 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) GetChecksum ¶
GetChecksum implements the Frame interface.
func (V1Frame) GetComponentID ¶
GetComponentID implements the Frame interface.
func (V1Frame) GetMessage ¶
GetMessage implements the Frame interface.
func (V1Frame) GetSystemID ¶
GetSystemID implements the Frame interface.
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) GetChecksum ¶
GetChecksum implements the Frame interface.
func (V2Frame) GetComponentID ¶
GetComponentID implements the Frame interface.
func (V2Frame) GetMessage ¶
GetMessage implements the Frame interface.
func (V2Frame) GetSystemID ¶
GetSystemID implements the Frame interface.
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.