From 957f23d5ddf300de7f587b8f4e20d604aa1c0f0a Mon Sep 17 00:00:00 2001 From: Jonathan Hudson Date: Thu, 1 Aug 2024 11:45:42 +0100 Subject: [PATCH] only BBL log servos defined in the mixer (#10267) * only BBL log servos defined in the mixer * address gcc13/gcc14/arm/intel GCC type mismatch --- src/main/blackbox/blackbox.c | 64 +++++++++++++++++++++++----------- src/main/blackbox/blackbox_fielddefs.h | 19 ++++++++++ 2 files changed, 62 insertions(+), 21 deletions(-) diff --git a/src/main/blackbox/blackbox.c b/src/main/blackbox/blackbox.c index 5a72d323b..8c37ee3cb 100644 --- a/src/main/blackbox/blackbox.c +++ b/src/main/blackbox/blackbox.c @@ -334,24 +334,24 @@ static const blackboxDeltaFieldDefinition_t blackboxMainFields[] = { {"motor", 7, UNSIGNED, .Ipredict = PREDICT(MOTOR_0), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(AT_LEAST_MOTORS_8)}, /* servos */ - {"servo", 0, UNSIGNED, .Ipredict = PREDICT(1500), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(SERVOS)}, - {"servo", 1, UNSIGNED, .Ipredict = PREDICT(1500), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(SERVOS)}, - {"servo", 2, UNSIGNED, .Ipredict = PREDICT(1500), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(SERVOS)}, - {"servo", 3, UNSIGNED, .Ipredict = PREDICT(1500), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(SERVOS)}, - {"servo", 4, UNSIGNED, .Ipredict = PREDICT(1500), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(SERVOS)}, - {"servo", 5, UNSIGNED, .Ipredict = PREDICT(1500), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(SERVOS)}, - {"servo", 6, UNSIGNED, .Ipredict = PREDICT(1500), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(SERVOS)}, - {"servo", 7, UNSIGNED, .Ipredict = PREDICT(1500), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(SERVOS)}, - {"servo", 8, UNSIGNED, .Ipredict = PREDICT(1500), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(SERVOS)}, - {"servo", 9, UNSIGNED, .Ipredict = PREDICT(1500), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(SERVOS)}, - {"servo", 10, UNSIGNED, .Ipredict = PREDICT(1500), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(SERVOS)}, - {"servo", 11, UNSIGNED, .Ipredict = PREDICT(1500), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(SERVOS)}, - {"servo", 12, UNSIGNED, .Ipredict = PREDICT(1500), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(SERVOS)}, - {"servo", 13, UNSIGNED, .Ipredict = PREDICT(1500), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(SERVOS)}, - {"servo", 14, UNSIGNED, .Ipredict = PREDICT(1500), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(SERVOS)}, - {"servo", 15, UNSIGNED, .Ipredict = PREDICT(1500), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(SERVOS)}, - {"servo", 16, UNSIGNED, .Ipredict = PREDICT(1500), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(SERVOS)}, - {"servo", 17, UNSIGNED, .Ipredict = PREDICT(1500), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(SERVOS)}, + {"servo", 0, UNSIGNED, .Ipredict = PREDICT(1500), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(AT_LEAST_SERVOS_1)}, + {"servo", 1, UNSIGNED, .Ipredict = PREDICT(1500), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(AT_LEAST_SERVOS_2)}, + {"servo", 2, UNSIGNED, .Ipredict = PREDICT(1500), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(AT_LEAST_SERVOS_3)}, + {"servo", 3, UNSIGNED, .Ipredict = PREDICT(1500), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(AT_LEAST_SERVOS_4)}, + {"servo", 4, UNSIGNED, .Ipredict = PREDICT(1500), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(AT_LEAST_SERVOS_5)}, + {"servo", 5, UNSIGNED, .Ipredict = PREDICT(1500), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(AT_LEAST_SERVOS_6)}, + {"servo", 6, UNSIGNED, .Ipredict = PREDICT(1500), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(AT_LEAST_SERVOS_7)}, + {"servo", 7, UNSIGNED, .Ipredict = PREDICT(1500), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(AT_LEAST_SERVOS_8)}, + {"servo", 8, UNSIGNED, .Ipredict = PREDICT(1500), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(AT_LEAST_SERVOS_9)}, + {"servo", 9, UNSIGNED, .Ipredict = PREDICT(1500), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(AT_LEAST_SERVOS_10)}, + {"servo", 10, UNSIGNED, .Ipredict = PREDICT(1500), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(AT_LEAST_SERVOS_11)}, + {"servo", 11, UNSIGNED, .Ipredict = PREDICT(1500), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(AT_LEAST_SERVOS_12)}, + {"servo", 12, UNSIGNED, .Ipredict = PREDICT(1500), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(AT_LEAST_SERVOS_13)}, + {"servo", 13, UNSIGNED, .Ipredict = PREDICT(1500), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(AT_LEAST_SERVOS_14)}, + {"servo", 14, UNSIGNED, .Ipredict = PREDICT(1500), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(AT_LEAST_SERVOS_15)}, + {"servo", 15, UNSIGNED, .Ipredict = PREDICT(1500), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(AT_LEAST_SERVOS_16)}, + {"servo", 16, UNSIGNED, .Ipredict = PREDICT(1500), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(AT_LEAST_SERVOS_17)}, + {"servo", 17, UNSIGNED, .Ipredict = PREDICT(1500), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(AT_LEAST_SERVOS_18)}, {"navState", -1, SIGNED, .Ipredict = PREDICT(0), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(PREVIOUS), .Pencode = ENCODING(SIGNED_VB), CONDITION(ALWAYS)}, {"navFlags", -1, UNSIGNED, .Ipredict = PREDICT(0), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(PREVIOUS), .Pencode = ENCODING(SIGNED_VB), CONDITION(ALWAYS)}, @@ -656,6 +656,26 @@ static bool testBlackboxConditionUncached(FlightLogFieldCondition condition) case FLIGHT_LOG_FIELD_CONDITION_SERVOS: return isMixerUsingServos(); + case FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_1: + case FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_2: + case FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_3: + case FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_4: + case FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_5: + case FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_6: + case FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_7: + case FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_8: + case FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_9: + case FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_10: + case FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_11: + case FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_12: + case FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_13: + case FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_14: + case FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_15: + case FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_16: + case FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_17: + case FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_18: + return ((FlightLogFieldCondition)getServoCount() >= condition - FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_1 + 1); + case FLIGHT_LOG_FIELD_CONDITION_NONZERO_PID_D_0: case FLIGHT_LOG_FIELD_CONDITION_NONZERO_PID_D_1: case FLIGHT_LOG_FIELD_CONDITION_NONZERO_PID_D_2: @@ -955,7 +975,8 @@ static void writeIntraframe(void) } if (testBlackboxCondition(FLIGHT_LOG_FIELD_CONDITION_SERVOS)) { - for (int x = 0; x < MAX_SUPPORTED_SERVOS; x++) { + const int servoCount = getServoCount(); + for (int x = 0; x < servoCount; x++) { //Assume that servos spends most of its time around the center blackboxWriteSignedVB(blackboxCurrent->servo[x] - 1500); } @@ -1214,7 +1235,7 @@ static void writeInterframe(void) } if (testBlackboxCondition(FLIGHT_LOG_FIELD_CONDITION_SERVOS)) { - blackboxWriteArrayUsingAveragePredictor16(offsetof(blackboxMainState_t, servo), MAX_SUPPORTED_SERVOS); + blackboxWriteArrayUsingAveragePredictor16(offsetof(blackboxMainState_t, servo), getServoCount()); } blackboxWriteSignedVB(blackboxCurrent->navState - blackboxLast->navState); @@ -1682,7 +1703,8 @@ static void loadMainState(timeUs_t currentTimeUs) blackboxCurrent->rssi = getRSSI(); - for (int i = 0; i < MAX_SUPPORTED_SERVOS; i++) { + const int servoCount = getServoCount(); + for (int i = 0; i < servoCount; i++) { blackboxCurrent->servo[i] = servo[i]; } diff --git a/src/main/blackbox/blackbox_fielddefs.h b/src/main/blackbox/blackbox_fielddefs.h index 1e5615e3e..63a951d40 100644 --- a/src/main/blackbox/blackbox_fielddefs.h +++ b/src/main/blackbox/blackbox_fielddefs.h @@ -33,7 +33,26 @@ typedef enum FlightLogFieldCondition { FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_MOTORS_6, FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_MOTORS_7, FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_MOTORS_8, + FLIGHT_LOG_FIELD_CONDITION_SERVOS, + FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_1, + FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_2, + FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_3, + FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_4, + FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_5, + FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_6, + FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_7, + FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_8, + FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_9, + FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_10, + FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_11, + FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_12, + FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_13, + FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_14, + FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_15, + FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_16, + FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_17, + FLIGHT_LOG_FIELD_CONDITION_AT_LEAST_SERVOS_18, FLIGHT_LOG_FIELD_CONDITION_MAG, FLIGHT_LOG_FIELD_CONDITION_BARO, -- 2.11.4.GIT