From ae8ee5325c2f0b8788841efe355c1b38bf296f92 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 14 Jun 2024 14:04:30 +1000 Subject: [PATCH] AP_Param: added get_eeprom_full() for arming check --- libraries/AP_Param/AP_Param.cpp | 6 ++++++ libraries/AP_Param/AP_Param.h | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/libraries/AP_Param/AP_Param.cpp b/libraries/AP_Param/AP_Param.cpp index 65915b4d8834f..16838b7750188 100644 --- a/libraries/AP_Param/AP_Param.cpp +++ b/libraries/AP_Param/AP_Param.cpp @@ -112,6 +112,9 @@ uint16_t AP_Param::param_overrides_len; uint16_t AP_Param::num_param_overrides; uint16_t AP_Param::num_read_only; +// goes true if we run out of param space +bool AP_Param::eeprom_full; + ObjectBuffer_TS AP_Param::save_queue{30}; bool AP_Param::registered_save_handler; @@ -1192,6 +1195,8 @@ void AP_Param::save_sync(bool force_save, bool send_to_gcs) return; } if (ofs == (uint16_t) ~0) { + eeprom_full = true; + DEV_PRINTF("EEPROM full\n"); return; } @@ -1224,6 +1229,7 @@ void AP_Param::save_sync(bool force_save, bool send_to_gcs) if (ofs+type_size((enum ap_var_type)phdr.type)+2*sizeof(phdr) >= _storage.size()) { // we are out of room for saving variables + eeprom_full = true; DEV_PRINTF("EEPROM full\n"); return; } diff --git a/libraries/AP_Param/AP_Param.h b/libraries/AP_Param/AP_Param.h index 1be4a820d1c89..2b2a4094ff552 100644 --- a/libraries/AP_Param/AP_Param.h +++ b/libraries/AP_Param/AP_Param.h @@ -430,6 +430,11 @@ class AP_Param /// static bool load_all(); + // return true if eeprom is full, used for arming check + static bool get_eeprom_full(void) { + return eeprom_full; + } + // returns storage space used: static uint16_t storage_used() { return sentinal_offset; } @@ -865,6 +870,8 @@ class AP_Param }; static defaults_list *default_list; static void check_default(AP_Param *ap, float *default_value); + + static bool eeprom_full; }; namespace AP {