PX4 Firmware
PX4 Autopilot Software http://px4.io
|
#include <mavlink_command_sender.h>
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 MavlinkCommandSender & | instance () |
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 |
Definition at line 57 of file mavlink_command_sender.h.
|
privatedefault |
|
private |
Definition at line 63 of file mavlink_command_sender.cpp.
References _lock.
|
privatedelete |
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().
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().
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
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().
|
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().
|
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().
|
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().
|
privatedelete |
|
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().
|
private |
Definition at line 115 of file mavlink_command_sender.h.
Referenced by check_timeout(), handle_mavlink_command_ack(), and handle_vehicle_command().
|
private |
Definition at line 117 of file mavlink_command_sender.h.
|
staticprivate |
Definition at line 102 of file mavlink_command_sender.h.
Referenced by initialize(), and instance().
|
staticprivate |
Definition at line 103 of file mavlink_command_sender.h.
Referenced by initialize(), lock(), unlock(), and ~MavlinkCommandSender().
|
staticprivate |
Definition at line 106 of file mavlink_command_sender.h.
Referenced by check_timeout().
|
staticprivate |
Definition at line 118 of file mavlink_command_sender.h.
Referenced by check_timeout().
|
staticprivate |
Definition at line 119 of file mavlink_command_sender.h.
Referenced by check_timeout().