aboutsummaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/systemlib/param/param.c25
-rw-r--r--src/modules/systemlib/param/param.h12
2 files changed, 37 insertions, 0 deletions
diff --git a/src/modules/systemlib/param/param.c b/src/modules/systemlib/param/param.c
index 7f5caf18f..68721598d 100644
--- a/src/modules/systemlib/param/param.c
+++ b/src/modules/systemlib/param/param.c
@@ -488,6 +488,31 @@ param_reset_all(void)
param_notify_changes();
}
+void
+param_reset_excludes(const char* excludes[], int num_excludes)
+{
+ param_lock();
+
+ param_t param;
+
+ for (param = 0; handle_in_range(param); param++) {
+ const char* name = param_name(param);
+
+ for (int index = 0, len = strlen(excludes[index]); index < num_excludes; index ++) {
+ if((excludes[index][len - 1] == '*'
+ && strncmp(name, excludes[index], strlen(excludes[index]))) == 0
+ || strcmp(name, excludes[index]) == 0) {
+
+ param_reset(param);
+ }
+ }
+ }
+
+ param_unlock();
+
+ param_notify_changes();
+}
+
static const char *param_default_file = "/eeprom/parameters";
static char *param_user_file = NULL;
diff --git a/src/modules/systemlib/param/param.h b/src/modules/systemlib/param/param.h
index e003572d9..f82af5e16 100644
--- a/src/modules/systemlib/param/param.h
+++ b/src/modules/systemlib/param/param.h
@@ -189,6 +189,18 @@ __EXPORT int param_reset(param_t param);
*/
__EXPORT void param_reset_all(void);
+
+/**
+ * Reset all parameters to their default values except for excluded parameters.
+ *
+ * This function also releases the storage used by struct parameters.
+ *
+ * @param excludes Array of param names to exclude from resetting. Use a wildcard
+ * at the end to exclude parameters with a certain prefix.
+ * @param num_excludes The number of excludes provided.
+ */
+ __EXPORT void param_reset_excludes(const char* excludes[], int num_excludes);
+
/**
* Export changed parameters to a file.
*