From 72a8be538a2e6963d88199dffeeaafbffab32099 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20K=C3=BCng?= Date: Mon, 14 Oct 2019 12:23:02 +0200 Subject: [PATCH] mixer_module: more robust logic to set 'stop_motors' flag Checking the first output_limited for a disarmed value is fragile. For example a disarmed value might be within the range of min/max output values and could then be triggered while armed. --- src/lib/mixer_module/mixer_module.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/lib/mixer_module/mixer_module.cpp b/src/lib/mixer_module/mixer_module.cpp index 5e631820ce..d2a50ba2f0 100644 --- a/src/lib/mixer_module/mixer_module.cpp +++ b/src/lib/mixer_module/mixer_module.cpp @@ -285,18 +285,15 @@ bool MixingOutput::update() } } + bool stop_motors = mixed_num_outputs == 0 || !_throttle_armed; + /* overwrite outputs in case of lockdown or parachute triggering with disarmed values */ if (_armed.lockdown || _armed.manual_lockdown) { for (size_t i = 0; i < mixed_num_outputs; i++) { output_limited[i] = _disarmed_value[i]; } - } - - bool stop_motors = true; - if (mixed_num_outputs > 0) { - /* assume if one (here the 1.) motor is disarmed, all of them should be stopped */ - stop_motors = (output_limited[0] == _disarmed_value[0]); + stop_motors = true; } /* apply _param_mot_ordering */