RC_Channel: return MAV_RESULT_FAILED from do_aux_function if invalid function

This commit is contained in:
Peter Barker 2021-02-24 20:48:15 +11:00 committed by Peter Barker
parent 115e895c82
commit e5a8acb227
2 changed files with 7 additions and 5 deletions

View File

@ -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()

View File

@ -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: