AP_ICEngine: sanity check param values

This commit is contained in:
tom pittenger 2019-04-17 10:14:26 -07:00 committed by Tom Pittenger
parent 3b9125956e
commit cd920c7609

View File

@ -217,7 +217,7 @@ void AP_ICEngine::update(void)
// reset initial height while disarmed
initial_height = -pos.z;
}
} else if (idle_percent == 0) { // check if we should idle
} else if (idle_percent <= 0) { // check if we should idle
// force ignition off when disarmed
state = ICE_OFF;
}
@ -265,8 +265,11 @@ bool AP_ICEngine::throttle_override(uint8_t &percentage)
return false;
}
uint8_t current_throttle = SRV_Channels::get_output_scaled(SRV_Channel::k_throttle);
if (idle_percent > current_throttle && state == ICE_RUNNING) {
if (state == ICE_RUNNING &&
idle_percent > 0 &&
idle_percent < 100 &&
(int16_t)idle_percent > SRV_Channels::get_output_scaled(SRV_Channel::k_throttle))
{
percentage = (uint8_t)idle_percent;
return true;
}