From 6097f1aa61c0e154b6e97fb759cf5761934c8efd Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Wed, 21 Jun 2023 17:25:06 +1000 Subject: [PATCH] GCS_MAVLink: allow removal of preflight commands to fail the autopilot --- libraries/GCS_MAVLink/GCS_Common.cpp | 3 +++ libraries/GCS_MAVLink/GCS_config.h | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/libraries/GCS_MAVLink/GCS_Common.cpp b/libraries/GCS_MAVLink/GCS_Common.cpp index c5a3fe29aa..592ae2274a 100644 --- a/libraries/GCS_MAVLink/GCS_Common.cpp +++ b/libraries/GCS_MAVLink/GCS_Common.cpp @@ -3100,6 +3100,7 @@ MAV_RESULT GCS_MAVLINK::handle_preflight_reboot(const mavlink_command_long_t &pa if (is_equal(packet.param1, 42.0f) && is_equal(packet.param2, 24.0f) && is_equal(packet.param3, 71.0f)) { +#if AP_MAVLINK_FAILURE_CREATION_ENABLED if (is_equal(packet.param4, 93.0f)) { // this is a magic sequence to force the main loop to // lockup. This is for testing the stm32 watchdog @@ -3153,6 +3154,8 @@ MAV_RESULT GCS_MAVLINK::handle_preflight_reboot(const mavlink_command_long_t &pa INTERNAL_ERROR(AP_InternalError::error_t::flow_of_control); return MAV_RESULT_ACCEPTED; } +#endif // AP_MAVLINK_FAILURE_CREATION_ENABLED + #if HAL_ENABLE_DFU_BOOT if (is_equal(packet.param4, 99.0f)) { #if AP_SIGNED_FIRMWARE diff --git a/libraries/GCS_MAVLink/GCS_config.h b/libraries/GCS_MAVLink/GCS_config.h index ef687e8ef3..8837515d5e 100644 --- a/libraries/GCS_MAVLink/GCS_config.h +++ b/libraries/GCS_MAVLink/GCS_config.h @@ -44,3 +44,8 @@ #ifndef AP_MAVLINK_MSG_RELAY_STATUS_ENABLED #define AP_MAVLINK_MSG_RELAY_STATUS_ENABLED HAL_GCS_ENABLED && AP_RELAY_ENABLED #endif + +// allow removal of developer-centric mavlink commands +#ifndef AP_MAVLINK_FAILURE_CREATION_ENABLED +#define AP_MAVLINK_FAILURE_CREATION_ENABLED 1 +#endif