PX4 Firmware
PX4 Autopilot Software http://px4.io
MavlinkCommandSender Class Reference

#include <mavlink_command_sender.h>

Collaboration diagram for MavlinkCommandSender:

Classes

struct  command_item_t
 

Public Member Functions

int handle_vehicle_command (const struct vehicle_command_s &command, mavlink_channel_t channel)
 Send a command on a channel and keep it in a queue for retransmission. More...
 
void check_timeout (mavlink_channel_t channel)
 Check timeouts to verify if an commands need retransmission. More...
 
void handle_mavlink_command_ack (const mavlink_command_ack_t &ack, uint8_t from_sysid, uint8_t from_compid, uint8_t channel)
 Handle mavlink command_ack. More...
 

Static Public Member Functions

static void initialize ()
 initialize: call this once on startup (this function is not thread-safe!) More...
 
static MavlinkCommandSenderinstance ()
 

Private Member Functions

 MavlinkCommandSender ()=default
 
 ~MavlinkCommandSender ()
 
 MavlinkCommandSender (const MavlinkCommandSender &)=delete
 
MavlinkCommandSender operator= (const MavlinkCommandSender &)=delete
 

Static Private Member Functions

static void lock ()
 
static void unlock ()
 

Private Attributes

TimestampedList< command_item_t_commands {3}
 
bool _debug_enabled = false
 

Static Private Attributes

static MavlinkCommandSender_instance = nullptr
 
static px4_sem_t _lock
 
static const unsigned MAX_MAVLINK_CHANNEL = 4
 
static constexpr uint8_t RETRIES = 3
 
static constexpr uint64_t TIMEOUT_US = 500000
 

Detailed Description

Definition at line 57 of file mavlink_command_sender.h.

Constructor & Destructor Documentation

◆ MavlinkCommandSender() [1/2]

MavlinkCommandSender::MavlinkCommandSender ( )
privatedefault

Referenced by initialize().

Here is the caller graph for this function:

◆ ~MavlinkCommandSender()

MavlinkCommandSender::~MavlinkCommandSender ( )
private

Definition at line 63 of file mavlink_command_sender.cpp.

References _lock.

◆ MavlinkCommandSender() [2/2]

MavlinkCommandSender::MavlinkCommandSender ( const MavlinkCommandSender )
privatedelete

Member Function Documentation

◆ check_timeout()

void MavlinkCommandSender::check_timeout ( mavlink_channel_t  channel)

Check timeouts to verify if an commands need retransmission.

thread-safe

Definition at line 137 of file mavlink_command_sender.cpp.

References _commands, CMD_DEBUG, hrt_absolute_time(), hrt_elapsed_time(), lock(), MAX_MAVLINK_CHANNEL, RETRIES, TIMEOUT_US, and unlock().

Referenced by MavlinkStreamCommandLong::send().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_mavlink_command_ack()

void MavlinkCommandSender::handle_mavlink_command_ack ( const mavlink_command_ack_t &  ack,
uint8_t  from_sysid,
uint8_t  from_compid,
uint8_t  channel 
)

Handle mavlink command_ack.

thread-safe

Definition at line 114 of file mavlink_command_sender.cpp.

References _commands, CMD_DEBUG, lock(), and unlock().

Referenced by MavlinkReceiver::handle_message_command_ack().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_vehicle_command()

int MavlinkCommandSender::handle_vehicle_command ( const struct vehicle_command_s command,
mavlink_channel_t  channel 
)

Send a command on a channel and keep it in a queue for retransmission.

thread-safe

Returns
0 on success, <0 otherwise

Definition at line 68 of file mavlink_command_sender.cpp.

References _commands, CMD_DEBUG, MavlinkCommandSender::command_item_t::command, vehicle_command_s::command, vehicle_command_s::confirmation, hrt_absolute_time(), MavlinkCommandSender::command_item_t::last_time_sent_us, lock(), msg, MavlinkCommandSender::command_item_t::num_sent_per_channel, vehicle_command_s::param1, vehicle_command_s::param2, vehicle_command_s::param3, vehicle_command_s::param4, vehicle_command_s::param5, vehicle_command_s::param6, vehicle_command_s::param7, vehicle_command_s::target_component, vehicle_command_s::target_system, vehicle_command_s::timestamp, MavlinkCommandSender::command_item_t::timestamp_us, and unlock().

Referenced by MavlinkStreamCommandLong::send(), and MavlinkStreamCameraTrigger::send().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ initialize()

void MavlinkCommandSender::initialize ( )
static

initialize: call this once on startup (this function is not thread-safe!)

Definition at line 49 of file mavlink_command_sender.cpp.

References _instance, _lock, and MavlinkCommandSender().

Referenced by Mavlink::start().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ instance()

MavlinkCommandSender & MavlinkCommandSender::instance ( )
static

Definition at line 58 of file mavlink_command_sender.cpp.

References _instance.

Referenced by MavlinkReceiver::handle_message_command_ack(), MavlinkStreamCommandLong::send(), and MavlinkStreamCameraTrigger::send().

Here is the caller graph for this function:

◆ lock()

static void MavlinkCommandSender::lock ( )
inlinestaticprivate

Definition at line 92 of file mavlink_command_sender.h.

References _lock.

Referenced by check_timeout(), handle_mavlink_command_ack(), and handle_vehicle_command().

Here is the caller graph for this function:

◆ operator=()

MavlinkCommandSender MavlinkCommandSender::operator= ( const MavlinkCommandSender )
privatedelete

◆ unlock()

static void MavlinkCommandSender::unlock ( )
inlinestaticprivate

Definition at line 97 of file mavlink_command_sender.h.

References _lock.

Referenced by check_timeout(), handle_mavlink_command_ack(), and handle_vehicle_command().

Here is the caller graph for this function:

Member Data Documentation

◆ _commands

TimestampedList<command_item_t> MavlinkCommandSender::_commands {3}
private

◆ _debug_enabled

bool MavlinkCommandSender::_debug_enabled = false
private

Definition at line 117 of file mavlink_command_sender.h.

◆ _instance

MavlinkCommandSender * MavlinkCommandSender::_instance = nullptr
staticprivate

Definition at line 102 of file mavlink_command_sender.h.

Referenced by initialize(), and instance().

◆ _lock

px4_sem_t MavlinkCommandSender::_lock
staticprivate

Definition at line 103 of file mavlink_command_sender.h.

Referenced by initialize(), lock(), unlock(), and ~MavlinkCommandSender().

◆ MAX_MAVLINK_CHANNEL

const unsigned MavlinkCommandSender::MAX_MAVLINK_CHANNEL = 4
staticprivate

Definition at line 106 of file mavlink_command_sender.h.

Referenced by check_timeout().

◆ RETRIES

constexpr uint8_t MavlinkCommandSender::RETRIES = 3
staticprivate

Definition at line 118 of file mavlink_command_sender.h.

Referenced by check_timeout().

◆ TIMEOUT_US

constexpr uint64_t MavlinkCommandSender::TIMEOUT_US = 500000
staticprivate

Definition at line 119 of file mavlink_command_sender.h.

Referenced by check_timeout().


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