Back Port nuttx_v3 FLASH based parameter hooks

This commit is contained in:
David Sidrane
2016-07-13 20:42:05 +02:00
committed by Julian Oes
parent 39ce201efe
commit 5e8d6375c9
9 changed files with 1870 additions and 10 deletions
+42 -8
View File
@@ -63,12 +63,21 @@
#include "systemlib/uthash/utarray.h"
#include "systemlib/bson/tinybson.h"
#include "uORB/uORB.h"
#include "uORB/topics/parameter_update.h"
#include "px4_parameters.h"
#if !defined(PARAM_NO_ORB)
# include "uORB/uORB.h"
# include "uORB/topics/parameter_update.h"
#endif
#if !defined(FLASH_BASED_PARAMS)
# define FLASH_PARAMS_EXPOSE
#else
# include "systemlib/flashparams/flashparams.h"
#endif
#include "px4_parameters.h"
#include <crc32.h>
#if 0
# define debug(fmt, args...) do { warnx(fmt, ##args); } while(0)
#else
@@ -131,13 +140,16 @@ get_param_info_count(void)
}
/** flexible array holding modified parameter values */
UT_array *param_values;
FLASH_PARAMS_EXPOSE UT_array *param_values;
/** array info for the modified parameters array */
const UT_icd param_icd = {sizeof(struct param_wbuf_s), NULL, NULL, NULL};
FLASH_PARAMS_EXPOSE const UT_icd param_icd = {sizeof(struct param_wbuf_s), NULL, NULL, NULL};
#if !defined(PARAM_NO_ORB)
/** parameter update topic handle */
static orb_advert_t param_topic = NULL;
#endif
static void param_set_used_internal(param_t param);
@@ -235,9 +247,11 @@ param_find_changed(param_t param)
static void
param_notify_changes(bool is_saved)
{
struct parameter_update_s pup;
pup.timestamp = hrt_absolute_time();
pup.saved = is_saved;
#if !defined(PARAM_NO_ORB)
struct parameter_update_s pup = {
.timestamp = hrt_absolute_time(),
.saved = is_saved
};
/*
* If we don't have a handle to our topic, create one now; otherwise
@@ -249,6 +263,8 @@ param_notify_changes(bool is_saved)
} else {
orb_publish(ORB_ID(parameter_update), param_topic, &pup);
}
#endif
}
param_t
@@ -436,6 +452,7 @@ param_size(param_t param)
return 0;
}
/**
* Obtain a pointer to the storage allocated for a parameter.
*
@@ -583,6 +600,19 @@ out:
return result;
}
#if defined(FLASH_BASED_PARAMS)
int param_set_external(param_t param, const void *val, bool mark_saved, bool notify_changes, bool is_saved)
{
return param_set_internal(param, val, mark_saved, notify_changes, is_saved);
}
const void *param_get_value_ptr_external(param_t param)
{
return param_get_value_ptr(param);
}
#endif
int
param_set(param_t param, const void *val)
{
@@ -734,6 +764,7 @@ int
param_save_default(void)
{
int res;
#if !defined(FLASH_BASED_PARAMS)
int fd;
const char *filename = param_get_default_file();
@@ -759,6 +790,9 @@ param_save_default(void)
}
PARAM_CLOSE(fd);
#else
res = flash_param_save();
#endif
return res;
}