From e0488b19e573e4e016a8066ad00164099a22e46c Mon Sep 17 00:00:00 2001 From: Marko T Date: Fri, 29 May 2026 13:43:33 +0200 Subject: [PATCH] fix(commander): size ArmingCheckReply queue to MAX_NUM_REGISTRATIONS The ArmingCheckReply uORB queue was sized to 4 (ORB_QUEUE_LENGTH) while ExternalChecks supports up to MAX_NUM_REGISTRATIONS (8) external modes, each of which publishes a reply for every ArmingCheckRequest. With more than 4 registered modes the replies from the 5th+ mode overwrote earlier ones within a single request cycle, so those modes were flagged "unresponsive" and silently failed to activate. Increase ORB_QUEUE_LENGTH to 8 to match MAX_NUM_REGISTRATIONS, and add a static_assert so the two limits cannot drift apart again. Fixes #27271 Signed-off-by: Marko T --- msg/versioned/ArmingCheckReply.msg | 5 ++++- .../HealthAndArmingChecks/checks/externalChecks.cpp | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/msg/versioned/ArmingCheckReply.msg b/msg/versioned/ArmingCheckReply.msg index 78cb015308a..604539e4906 100644 --- a/msg/versioned/ArmingCheckReply.msg +++ b/msg/versioned/ArmingCheckReply.msg @@ -40,4 +40,7 @@ bool mode_req_home_position # Requires a home position (such as RTL/Return mode) bool mode_req_prevent_arming # Prevent arming (such as in Land mode) bool mode_req_manual_control # Requires a manual controller -uint8 ORB_QUEUE_LENGTH = 4 +# Must be >= ExternalChecks::MAX_NUM_REGISTRATIONS so replies from all registered +# modes fit in the queue within a single request cycle (otherwise replies from the +# 5th+ mode overwrite earlier ones, causing spurious "unresponsive mode" failures). +uint8 ORB_QUEUE_LENGTH = 8 diff --git a/src/modules/commander/HealthAndArmingChecks/checks/externalChecks.cpp b/src/modules/commander/HealthAndArmingChecks/checks/externalChecks.cpp index c5de25278da..95e7aa497e0 100644 --- a/src/modules/commander/HealthAndArmingChecks/checks/externalChecks.cpp +++ b/src/modules/commander/HealthAndArmingChecks/checks/externalChecks.cpp @@ -33,6 +33,10 @@ #include "externalChecks.hpp" +// The reply queue must hold one reply from every registered mode within a single request cycle (https://github.com/PX4/PX4-Autopilot/issues/27271) +static_assert(arming_check_reply_s::ORB_QUEUE_LENGTH >= ExternalChecks::MAX_NUM_REGISTRATIONS, + "ArmingCheckReply ORB_QUEUE_LENGTH must be >= ExternalChecks::MAX_NUM_REGISTRATIONS"); + static void setOrClearRequirementBits(bool requirement_set, int8_t nav_state, int8_t replaces_nav_state, uint32_t &bits) { if (requirement_set) {