From d8be547b0694cfb1d7def95c5d894274f4748c5e Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Tue, 22 Oct 2024 14:32:24 +1300 Subject: [PATCH] mavlink: drop acks early that aren't for us This fixes an issue where we dropped acks that we should have sent out just because the queue was clogged with acks that have nothing to do with us and just happen to be sent to us. We should just ignore them and not publish them to uORB. --- src/modules/mavlink/mavlink_receiver.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/modules/mavlink/mavlink_receiver.cpp b/src/modules/mavlink/mavlink_receiver.cpp index 0ddafa5f2a..7a1d3b3df7 100644 --- a/src/modules/mavlink/mavlink_receiver.cpp +++ b/src/modules/mavlink/mavlink_receiver.cpp @@ -803,6 +803,16 @@ MavlinkReceiver::handle_message_command_ack(mavlink_message_t *msg) mavlink_command_ack_t ack; mavlink_msg_command_ack_decode(msg, &ack); + // We should not clog the command_ack queue with acks that are not for us. + // Therefore, we drop them early and move on. + bool target_ok = evaluate_target_ok(0, ack.target_system, ack.target_component); + + if (!target_ok) { + PX4_DEBUG("Drop ack %d for %d from %d/%d to %d/%d\n", + ack.result, ack.command, msg->sysid, msg->compid, ack.target_system, ack.target_component); + return; + } + MavlinkCommandSender::instance().handle_mavlink_command_ack(ack, msg->sysid, msg->compid, _mavlink.get_channel()); vehicle_command_ack_s command_ack{};