mavlink: add class for command retransmission

This adds a class to allow for retransmission of outgoing commands.
The sent commands are kept in a timestamped list to check if they are
acked as required by the mavlink protocol.
If they are not acked within a timeout, they can be retransmitted.
This commit is contained in:
Julian Oes
2017-07-08 11:52:23 +02:00
committed by Lorenz Meier
parent 9854fc0d84
commit af0107ae0a
7 changed files with 527 additions and 18 deletions
+7 -17
View File
@@ -44,6 +44,7 @@
#include "mavlink_main.h"
#include "mavlink_messages.h"
#include "mavlink_command_sender.h"
#include <commander/px4_custom_mode.h>
#include <drivers/drv_pwm_output.h>
@@ -453,25 +454,14 @@ protected:
struct vehicle_command_s cmd;
if (_cmd_sub->update(&_cmd_time, &cmd)) {
/* only send commands for other systems/components */
if (cmd.target_system != mavlink_system.sysid || cmd.target_component != mavlink_system.compid) {
mavlink_command_long_t msg = {};
msg.target_system = cmd.target_system;
msg.target_component = cmd.target_component;
msg.command = cmd.command;
msg.confirmation = cmd.confirmation;
msg.param1 = cmd.param1;
msg.param2 = cmd.param2;
msg.param3 = cmd.param3;
msg.param4 = cmd.param4;
msg.param5 = cmd.param5;
msg.param6 = cmd.param6;
msg.param7 = cmd.param7;
mavlink_msg_command_long_send_struct(_mavlink->get_channel(), &msg);
}
//if (cmd.target_system != mavlink_system.sysid || cmd.target_component != mavlink_system.compid) {
MavlinkCommandSender::instance().handle_vehicle_command(cmd, _mavlink->get_channel());
//}
}
MavlinkCommandSender::instance().check_timeout(_mavlink->get_channel());
}
};