Skyward boardcore
Loading...
Searching...
No Matches
Boardcore::MavlinkDriver< PktLength, OutQueueSize, MavMsgLength > Class Template Reference

The MavlinkDriver object offers an interface to send and receive from a Transceiver object using an implementation of the Mavlink protocol. More...

#include <MavlinkDriver.h>

Public Member Functions

 MavlinkDriver (Transceiver *device, MavHandler onReceive=nullptr, uint16_t sleepAfterSend=0, size_t outBufferMaxAge=1000)
 Initializes all data structures.
 
bool start ()
 Start the receiving and sending threads.
 
bool isStarted ()
 Tells whether the driver was started.
 
void stop ()
 Stops sender and receiver threads.
 
bool enqueueMsg (const mavlink_message_t &msg)
 Non-blocking send function, puts the message in a queue. Message is discarded if the queue is full.
 
bool enqueueRaw (uint8_t *msg, size_t size)
 Enqueue a raw packet message into the sync packet queue.
 
MavlinkStatus getStatus ()
 Synchronized status getter.
 
void setSleepAfterSend (uint16_t newSleepTime)
 Setter for the sleep after send value.
 

Detailed Description

template<unsigned int PktLength, unsigned int OutQueueSize, unsigned int MavMsgLength = MAVLINK_MAX_PAYLOAD_LEN>
class Boardcore::MavlinkDriver< PktLength, OutQueueSize, MavMsgLength >

The MavlinkDriver object offers an interface to send and receive from a Transceiver object using an implementation of the Mavlink protocol.

See src/tests/drivers/test-mavlink.cpp for an example.

Template Parameters
PktLengthMaximum length in bytes of each transceiver packet.
OutQueueSizeMax number of transceiver packets in the output queue.
MavMsgLengthMax length of a mavlink message. By default is 255 the maximum possible but can be replaces with MAVLINK_MAX_DIALECT_PAYLOAD_SIZE for a specific protocol.

Definition at line 66 of file MavlinkDriver.h.

Constructor & Destructor Documentation

◆ MavlinkDriver()

template<unsigned int PktLength, unsigned int OutQueueSize, unsigned int MavMsgLength>
Boardcore::MavlinkDriver< PktLength, OutQueueSize, MavMsgLength >::MavlinkDriver ( Transceiver * device,
MavHandler onReceive = nullptr,
uint16_t sleepAfterSend = 0,
size_t outBufferMaxAge = 1000 )

Initializes all data structures.

Parameters
deviceTransceiver used to send and receive messages.
onReceiveFunction to be executed on message rcv.
sleepAfterSendGuaranteed sleep time after each send [ms].
outBufferMaxAgeMax residence time for messages in the queue: after this time the message will be automatically sent [ms].

Definition at line 205 of file MavlinkDriver.h.

Member Function Documentation

◆ enqueueMsg()

template<unsigned int PktLength, unsigned int OutQueueSize, unsigned int MavMsgLength>
bool Boardcore::MavlinkDriver< PktLength, OutQueueSize, MavMsgLength >::enqueueMsg ( const mavlink_message_t & msg)

Non-blocking send function, puts the message in a queue. Message is discarded if the queue is full.

Parameters
msgMessage to send (mavlink struct).
Returns
True if the message could be enqueued.

Definition at line 271 of file MavlinkDriver.h.

◆ enqueueRaw()

template<unsigned int PktLength, unsigned int OutQueueSize, unsigned int MavMsgLength>
bool Boardcore::MavlinkDriver< PktLength, OutQueueSize, MavMsgLength >::enqueueRaw ( uint8_t * msg,
size_t size )

Enqueue a raw packet message into the sync packet queue.

Parameters
msgMessage to send.
sizeLength in bytes.
Returns
True if the message was enqueued.

Definition at line 290 of file MavlinkDriver.h.

◆ getStatus()

template<unsigned int PktLength, unsigned int OutQueueSize, unsigned int MavMsgLength>
MavlinkStatus Boardcore::MavlinkDriver< PktLength, OutQueueSize, MavMsgLength >::getStatus ( )

Synchronized status getter.

Definition at line 433 of file MavlinkDriver.h.

◆ isStarted()

template<unsigned int PktLength, unsigned int OutQueueSize, unsigned int MavMsgLength>
bool Boardcore::MavlinkDriver< PktLength, OutQueueSize, MavMsgLength >::isStarted ( )

Tells whether the driver was started.

Definition at line 254 of file MavlinkDriver.h.

◆ setSleepAfterSend()

template<unsigned int PktLength, unsigned int OutQueueSize, unsigned int MavMsgLength>
void Boardcore::MavlinkDriver< PktLength, OutQueueSize, MavMsgLength >::setSleepAfterSend ( uint16_t newSleepTime)

Setter for the sleep after send value.

Definition at line 442 of file MavlinkDriver.h.

◆ start()

template<unsigned int PktLength, unsigned int OutQueueSize, unsigned int MavMsgLength>
bool Boardcore::MavlinkDriver< PktLength, OutQueueSize, MavMsgLength >::start ( )

Start the receiving and sending threads.

Returns
False if at least one could not start.

Definition at line 216 of file MavlinkDriver.h.

◆ stop()

template<unsigned int PktLength, unsigned int OutQueueSize, unsigned int MavMsgLength>
void Boardcore::MavlinkDriver< PktLength, OutQueueSize, MavMsgLength >::stop ( )

Stops sender and receiver threads.

Definition at line 261 of file MavlinkDriver.h.


The documentation for this class was generated from the following file: