|
|
|
@ -50,15 +50,16 @@
@@ -50,15 +50,16 @@
|
|
|
|
|
#include <math.h> |
|
|
|
|
|
|
|
|
|
#include <drivers/drv_hrt.h> |
|
|
|
|
#include <lib/perf/perf_counter.h> |
|
|
|
|
#include <px4_config.h> |
|
|
|
|
#include <px4_defines.h> |
|
|
|
|
#include <px4_posix.h> |
|
|
|
|
#include <px4_sem.h> |
|
|
|
|
#include <px4_shutdown.h> |
|
|
|
|
|
|
|
|
|
#include <perf/perf_counter.h> |
|
|
|
|
#include <systemlib/uthash/utarray.h> |
|
|
|
|
|
|
|
|
|
using namespace time_literals; |
|
|
|
|
|
|
|
|
|
//#define PARAM_NO_ORB ///< if defined, avoid uorb dependency. This disables publication of parameter_update on param change
|
|
|
|
|
//#define PARAM_NO_AUTOSAVE ///< if defined, do not autosave (avoids LP work queue dependency)
|
|
|
|
|
|
|
|
|
@ -91,8 +92,8 @@ static char *param_user_file = nullptr;
@@ -91,8 +92,8 @@ static char *param_user_file = nullptr;
|
|
|
|
|
#include <px4_workqueue.h> |
|
|
|
|
/* autosaving variables */ |
|
|
|
|
static hrt_abstime last_autosave_timestamp = 0; |
|
|
|
|
static struct work_s autosave_work; |
|
|
|
|
static bool autosave_scheduled = false; |
|
|
|
|
static struct work_s autosave_work {}; |
|
|
|
|
static volatile bool autosave_scheduled = false; |
|
|
|
|
static bool autosave_disabled = false; |
|
|
|
|
#endif /* PARAM_NO_AUTOSAVE */ |
|
|
|
|
|
|
|
|
@ -627,7 +628,7 @@ autosave_worker(void *arg)
@@ -627,7 +628,7 @@ autosave_worker(void *arg)
|
|
|
|
|
int ret = param_save_default(); |
|
|
|
|
|
|
|
|
|
if (ret != 0) { |
|
|
|
|
PX4_ERR("param save failed (%i)", ret); |
|
|
|
|
PX4_ERR("param auto save failed (%i)", ret); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
#endif /* PARAM_NO_AUTOSAVE */ |
|
|
|
@ -651,10 +652,10 @@ param_autosave()
@@ -651,10 +652,10 @@ param_autosave()
|
|
|
|
|
// - tasks often call param_set() for multiple params, so this avoids unnecessary save calls
|
|
|
|
|
// - the logger stores changed params. He gets notified on a param change via uORB and then
|
|
|
|
|
// looks at all unsaved params.
|
|
|
|
|
hrt_abstime delay = 300 * 1000; |
|
|
|
|
hrt_abstime delay = 300_ms; |
|
|
|
|
|
|
|
|
|
const hrt_abstime rate_limit = 2000 * 1000; // rate-limit saving to 2 seconds
|
|
|
|
|
hrt_abstime last_save_elapsed = hrt_elapsed_time(&last_autosave_timestamp); |
|
|
|
|
static constexpr const hrt_abstime rate_limit = 2_s; // rate-limit saving to 2 seconds
|
|
|
|
|
const hrt_abstime last_save_elapsed = hrt_elapsed_time(&last_autosave_timestamp); |
|
|
|
|
|
|
|
|
|
if (last_save_elapsed < rate_limit && rate_limit > last_save_elapsed + delay) { |
|
|
|
|
delay = rate_limit - last_save_elapsed; |
|
|
|
@ -1371,3 +1372,36 @@ uint32_t param_hash_check()
@@ -1371,3 +1372,36 @@ uint32_t param_hash_check()
|
|
|
|
|
|
|
|
|
|
return param_hash; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void param_print_status() |
|
|
|
|
{ |
|
|
|
|
PX4_INFO("summary: %d/%d (used/total)", param_count_used(), param_count()); |
|
|
|
|
|
|
|
|
|
#ifndef FLASH_BASED_PARAMS |
|
|
|
|
const char *filename = param_get_default_file(); |
|
|
|
|
|
|
|
|
|
if (filename != nullptr) { |
|
|
|
|
PX4_INFO("file: %s", param_get_default_file()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#endif /* FLASH_BASED_PARAMS */ |
|
|
|
|
|
|
|
|
|
if (param_values != nullptr) { |
|
|
|
|
PX4_INFO("storage array: %d/%d elements (%zu bytes total)", |
|
|
|
|
utarray_len(param_values), param_values->n, param_values->n * sizeof(UT_icd)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#ifndef PARAM_NO_AUTOSAVE |
|
|
|
|
PX4_INFO("auto save: %s", autosave_disabled ? "off" : "on"); |
|
|
|
|
|
|
|
|
|
if (!autosave_disabled && (last_autosave_timestamp > 0)) { |
|
|
|
|
PX4_INFO("last auto save: %.3f seconds ago", hrt_elapsed_time(&last_autosave_timestamp) * 1e-6); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#endif /* PARAM_NO_AUTOSAVE */ |
|
|
|
|
|
|
|
|
|
perf_print_counter(param_export_perf); |
|
|
|
|
perf_print_counter(param_find_perf); |
|
|
|
|
perf_print_counter(param_get_perf); |
|
|
|
|
perf_print_counter(param_set_perf); |
|
|
|
|
} |
|
|
|
|