From 500a896a5663cce744dd672bab06086917b74c87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20K=C3=BCng?= Date: Mon, 5 Sep 2022 08:21:04 +0200 Subject: [PATCH] commander: print reason for mode rejection & report for GCS switches as well --- src/modules/commander/Commander.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/modules/commander/Commander.cpp b/src/modules/commander/Commander.cpp index 7bd61084d5..69334360fa 100644 --- a/src/modules/commander/Commander.cpp +++ b/src/modules/commander/Commander.cpp @@ -814,6 +814,10 @@ Commander::handle_command(const vehicle_command_s &cmd) main_ret = TRANSITION_CHANGED; } else { + if (cmd.from_external && cmd.source_component == 190) { // MAV_COMP_ID_MISSIONPLANNER + print_reject_mode(desired_nav_state); + } + main_ret = TRANSITION_DENIED; } } @@ -2420,11 +2424,13 @@ Commander::print_reject_mode(uint8_t nav_state) mavlink_log_critical(&_mavlink_log_pub, "Switching to %s is currently not available\t", mode_util::nav_state_names[nav_state]); + px4_custom_mode custom_mode = get_px4_custom_mode(nav_state); + uint32_t mavlink_mode = custom_mode.data; /* EVENT - * @description Check for a valid position estimate + * @type append_health_and_arming_messages */ - events::send(events::ID("commander_modeswitch_not_avail"), {events::Log::Critical, events::LogInternal::Info}, - "Switching to mode '{1}' is currently not possible", mode_util::navigation_mode(nav_state)); + events::send(events::ID("commander_modeswitch_not_avail"), {events::Log::Critical, events::LogInternal::Info}, + "Switching to mode '{2}' is currently not possible", mavlink_mode, mode_util::navigation_mode(nav_state)); /* only buzz if armed, because else we're driving people nuts indoors they really need to look at the leds as well. */