From 402c2d5f15b2ec17d162b583de5beba34ac55f40 Mon Sep 17 00:00:00 2001 From: Ray Morris Date: Wed, 31 Dec 2025 02:23:06 -0600 Subject: [PATCH] Fix blackbox MOTORS condition mismatch causing null byte padding MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Problem: - Field definitions use AT_LEAST_MOTORS_N (checks motorCount AND flag) - I-frame write used MOTORS (checks flag only) - When motorCount=0 and flag=true: header declares 0 fields, I-frame writes 1 byte - motor[0] - getThrottleIdleValue() = 0 - 0 = 0 → encodes as 0x00 - Decoder expects frame marker, finds null byte → catastrophic failure Fix: - Change I-frame write from FLIGHT_LOG_FIELD_CONDITION_MOTORS to FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_MOTORS_1 - Change P-frame write for consistency - Now matches field definition condition exactly Testing: - Board with motorCount=0, MOTORS flag enabled - Before: 207 decoder failures (0.050s duration) - After: 3 decoder failures (12s duration) - matches baseline Files: - src/main/blackbox/blackbox.c lines 1079, 1346 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 --- src/main/blackbox/blackbox.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/blackbox/blackbox.c b/src/main/blackbox/blackbox.c index 1027f25379d..e4c2afb3eec 100644 --- a/src/main/blackbox/blackbox.c +++ b/src/main/blackbox/blackbox.c @@ -987,7 +987,7 @@ static void writeIntraframe(void) blackboxWriteSignedVBArray(blackboxCurrent->debug, DEBUG32_VALUE_COUNT); } - if (testBlackboxCondition(FLIGHT_LOG_FIELD_CONDITION_MOTORS)) { + if (testBlackboxCondition(FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_MOTORS_1)) { //Motors can be below minthrottle when disarmed, but that doesn't happen much blackboxWriteUnsignedVB(blackboxCurrent->motor[0] - getThrottleIdleValue()); @@ -1254,7 +1254,7 @@ static void writeInterframe(void) blackboxWriteArrayUsingAveragePredictor32(offsetof(blackboxMainState_t, debug), DEBUG32_VALUE_COUNT); } - if (testBlackboxCondition(FLIGHT_LOG_FIELD_CONDITION_MOTORS)) { + if (testBlackboxCondition(FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_MOTORS_1)) { blackboxWriteArrayUsingAveragePredictor16(offsetof(blackboxMainState_t, motor), getMotorCount()); }