From 27f6d7e621d268c573069f66b7aa5632ebf2a580 Mon Sep 17 00:00:00 2001 From: bkleiner Date: Sun, 4 Aug 2024 13:25:06 +0200 Subject: [PATCH] bb: increase debug field size --- src/io/blackbox.c | 11 +++++------ src/io/blackbox.h | 3 ++- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/io/blackbox.c b/src/io/blackbox.c index 9b5deef6d..c36766b0d 100644 --- a/src/io/blackbox.c +++ b/src/io/blackbox.c @@ -63,11 +63,10 @@ cbor_result_t cbor_encode_blackbox_t(cbor_value_t *enc, const blackbox_t *b, con } if (field_flags & (1 << BBOX_FIELD_DEBUG)) { - CBOR_CHECK_ERROR(res = cbor_encode_array(enc, 4)); - CBOR_CHECK_ERROR(res = cbor_encode_int16_t(enc, &b->debug[0])); - CBOR_CHECK_ERROR(res = cbor_encode_int16_t(enc, &b->debug[1])); - CBOR_CHECK_ERROR(res = cbor_encode_int16_t(enc, &b->debug[2])); - CBOR_CHECK_ERROR(res = cbor_encode_int16_t(enc, &b->debug[3])); + CBOR_CHECK_ERROR(res = cbor_encode_array(enc, BLACKBOX_DEBUG_SIZE)); + for (uint32_t i = 0; i < BLACKBOX_DEBUG_SIZE; i++) { + CBOR_CHECK_ERROR(res = cbor_encode_int16_t(enc, &b->debug[i])); + } } CBOR_CHECK_ERROR(res = cbor_encode_end_indefinite(enc)); @@ -80,7 +79,7 @@ void blackbox_init() { } void blackbox_set_debug(uint8_t index, int16_t data) { - if (index >= 4) { + if (index >= BLACKBOX_DEBUG_SIZE) { return; } diff --git a/src/io/blackbox.h b/src/io/blackbox.h index 2e3f2f393..a49e14cb6 100644 --- a/src/io/blackbox.h +++ b/src/io/blackbox.h @@ -3,6 +3,7 @@ #include "core/profile.h" #define BLACKBOX_SCALE 1000 +#define BLACKBOX_DEBUG_SIZE 10 typedef struct { uint32_t loop; @@ -25,7 +26,7 @@ typedef struct { uint16_t cpu_load; - int16_t debug[4]; + int16_t debug[BLACKBOX_DEBUG_SIZE]; } blackbox_t; // Blackbox fields (should align with above structure)