From c29dc5401f95fbcf96fa7c42a545d110baed486c Mon Sep 17 00:00:00 2001 From: Ray Morris Date: Sun, 2 Aug 2026 23:21:38 -0500 Subject: [PATCH] Fix MSP2_INAV_WIND returning stale non-zero values when invalid getEstimatedHorizontalWindSpeed() was called unconditionally, so once the wind estimate becomes invalid (e.g. the 15-minute stationary-altitude timeout in wind_estimator.c), MSP2_INAV_WIND kept sending the last computed windSpeed/windAngle instead of zero. estimatedWind[] is never reset when hasValidWindEstimate clears, only the flags byte reflected validity. This contradicted the message's own documentation ("returns zeroes when wind estimation is not compiled in or not yet valid") and diverged from every other consumer of this API (gps.c, osd.c, rth_estimator.c, navigation.c, imu.c, mavlink_streams.c, logic_condition.c, pitotmeter.c), all of which check isEstimatedWindSpeedValid() before reading the value rather than relying on the estimator to self-zero. Reported by Qodo's automated review on PR #11761 (a release/9.1 -> maintenance-10.x merge that carried this pre-existing bug forward, unrelated to that merge itself). Fixed at the source (release/9.1) so it flows forward on the next maintenance-10.x sync. --- src/main/fc/fc_msp.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/fc/fc_msp.c b/src/main/fc/fc_msp.c index 92eecfc88b5..961d1737c95 100644 --- a/src/main/fc/fc_msp.c +++ b/src/main/fc/fc_msp.c @@ -1604,8 +1604,12 @@ static bool mspFcProcessOutCommand(uint16_t cmdMSP, sbuf_t *dst, mspPostProcessF #ifdef USE_WIND_ESTIMATOR { uint16_t windAngle = 0; - uint16_t windSpeed = (uint16_t)getEstimatedHorizontalWindSpeed(&windAngle); - uint8_t windFlags = isEstimatedWindSpeedValid() ? 1 : 0; + uint16_t windSpeed = 0; + uint8_t windFlags = 0; + if (isEstimatedWindSpeedValid()) { + windSpeed = (uint16_t)getEstimatedHorizontalWindSpeed(&windAngle); + windFlags = 1; + } sbufWriteU16(dst, windSpeed); sbufWriteU16(dst, windAngle / 100); sbufWriteU8(dst, windFlags);