From e5a8acb2272286ddea45f7322bc7426d8677c425 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Wed, 24 Feb 2021 20:48:15 +1100 Subject: [PATCH] RC_Channel: return MAV_RESULT_FAILED from do_aux_function if invalid function --- libraries/RC_Channel/RC_Channel.cpp | 6 ++++-- libraries/RC_Channel/RC_Channel.h | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/libraries/RC_Channel/RC_Channel.cpp b/libraries/RC_Channel/RC_Channel.cpp index 84883d72e2..b6fd3ee246 100644 --- a/libraries/RC_Channel/RC_Channel.cpp +++ b/libraries/RC_Channel/RC_Channel.cpp @@ -893,7 +893,7 @@ void RC_Channel::do_aux_function_mission_reset(const AuxSwitchPos ch_flag) mission->reset(); } -void RC_Channel::do_aux_function(const aux_func_t ch_option, const AuxSwitchPos ch_flag) +bool RC_Channel::do_aux_function(const aux_func_t ch_option, const AuxSwitchPos ch_flag) { switch(ch_option) { case AUX_FUNC::CAMERA_TRIGGER: @@ -1150,8 +1150,10 @@ void RC_Channel::do_aux_function(const aux_func_t ch_option, const AuxSwitchPos default: gcs().send_text(MAV_SEVERITY_INFO, "Invalid channel option (%u)", (unsigned int)ch_option); - break; + return false; } + + return true; } void RC_Channel::init_aux() diff --git a/libraries/RC_Channel/RC_Channel.h b/libraries/RC_Channel/RC_Channel.h index 658aa3de88..3a38d590fc 100644 --- a/libraries/RC_Channel/RC_Channel.h +++ b/libraries/RC_Channel/RC_Channel.h @@ -241,7 +241,7 @@ public: bool read_6pos_switch(int8_t& position) WARN_IF_UNUSED; AuxSwitchPos get_aux_switch_pos() const; - virtual void do_aux_function(aux_func_t ch_option, AuxSwitchPos); + virtual bool do_aux_function(aux_func_t ch_option, AuxSwitchPos); #if !HAL_MINIMIZE_FEATURES const char *string_for_aux_function(AUX_FUNC function) const; @@ -482,8 +482,8 @@ public: uint32_t last_input_ms() const { return last_update_ms; }; - void do_aux_function(RC_Channel::AUX_FUNC ch_option, RC_Channel::AuxSwitchPos pos) { - rc_channel(0)->do_aux_function(ch_option, pos); + bool do_aux_function(RC_Channel::AUX_FUNC ch_option, RC_Channel::AuxSwitchPos pos) { + return rc_channel(0)->do_aux_function(ch_option, pos); } protected: