From 1c7e2f509421bca4e34e22c0ef09a655f552330d Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Fri, 5 Aug 2022 09:31:57 +1000 Subject: [PATCH] AP_HAL_SITL: correct bind-value SIM_RC_FAIL handling If SITL is not receiving any sitl rc input (so _sitl_rc_in.recv(...) is allways returns -1 then the bind-values code would never be crossed so the RC input values would remain at their initialisation values rather than honouring the SIM_RC_FAIL setting which says they should go to bind values (notably throttle-to-950) --- libraries/AP_HAL_SITL/SITL_State.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/libraries/AP_HAL_SITL/SITL_State.cpp b/libraries/AP_HAL_SITL/SITL_State.cpp index f5a4ca0ca5..176d41922d 100644 --- a/libraries/AP_HAL_SITL/SITL_State.cpp +++ b/libraries/AP_HAL_SITL/SITL_State.cpp @@ -440,6 +440,17 @@ bool SITL_State::_read_rc_sitl_input() } pwm_pkt; const ssize_t size = _sitl_rc_in.recv(&pwm_pkt, sizeof(pwm_pkt), 0); + + if (_sitl->rc_fail == SITL::SIM::SITL_RCFail_Throttle950) { + // discard anything we just read from the "receiver" and set + // values to bind values: + for (uint8_t i=0; irc_fail == SITL::SIM::SITL_RCFail_Throttle950) { - if (i == 2) { - // set throttle (assumed to be on channel 3...) - pwm = 950; - } else { - // centre all other inputs - pwm = 1500; - } - } pwm_input[i] = pwm; } }