diff options
author | Lorenz Meier <lm@inf.ethz.ch> | 2015-02-14 20:31:51 +0100 |
---|---|---|
committer | Lorenz Meier <lm@inf.ethz.ch> | 2015-02-15 19:52:01 +0100 |
commit | aef041e0329fc1902f88392945d875bb49eba6f5 (patch) | |
tree | 5d392d481fcde211a55aad28e9a38fe79c809be7 | |
parent | bed3eaafa10fe8e916ddcd31a66d2411f86c601e (diff) | |
download | px4-firmware-aef041e0329fc1902f88392945d875bb49eba6f5.tar.gz px4-firmware-aef041e0329fc1902f88392945d875bb49eba6f5.tar.bz2 px4-firmware-aef041e0329fc1902f88392945d875bb49eba6f5.zip |
Syslib: Add support for setting parameters without global notification
-rw-r--r-- | src/modules/systemlib/param/param.c | 14 | ||||
-rw-r--r-- | src/modules/systemlib/param/param.h | 10 |
2 files changed, 20 insertions, 4 deletions
diff --git a/src/modules/systemlib/param/param.c b/src/modules/systemlib/param/param.c index 926ae75a7..d0d24960e 100644 --- a/src/modules/systemlib/param/param.c +++ b/src/modules/systemlib/param/param.c @@ -361,7 +361,7 @@ param_get(param_t param, void *val) } static int -param_set_internal(param_t param, const void *val, bool mark_saved) +param_set_internal(param_t param, const void *val, bool mark_saved, bool notify_changes) { int result = -1; bool params_changed = false; @@ -436,7 +436,7 @@ out: * If we set something, now that we have unlocked, go ahead and advertise that * a thing has been set. */ - if (params_changed) + if (params_changed && notify_changes) param_notify_changes(); return result; @@ -445,7 +445,13 @@ out: int param_set(param_t param, const void *val) { - return param_set_internal(param, val, false); + return param_set_internal(param, val, false, true); +} + +int +param_set_no_notification(param_t param, const void *val) +{ + return param_set_internal(param, val, false, false); } int @@ -775,7 +781,7 @@ param_import_callback(bson_decoder_t decoder, void *private, bson_node_t node) goto out; } - if (param_set_internal(param, v, state->mark_saved)) { + if (param_set_internal(param, v, state->mark_saved, true)) { debug("error setting value for '%s'", node->name); goto out; } diff --git a/src/modules/systemlib/param/param.h b/src/modules/systemlib/param/param.h index f82af5e16..69e984a8f 100644 --- a/src/modules/systemlib/param/param.h +++ b/src/modules/systemlib/param/param.h @@ -172,6 +172,16 @@ __EXPORT int param_get(param_t param, void *val); __EXPORT int param_set(param_t param, const void *val); /** + * Set the value of a parameter, but do not notify the system about the change. + * + * @param param A handle returned by param_find or passed by param_foreach. + * @param val The value to set; assumed to point to a variable of the parameter type. + * For structures, the pointer is assumed to point to a structure to be copied. + * @return Zero if the parameter's value could be set from a scalar, nonzero otherwise. + */ +__EXPORT int param_set_no_notification(param_t param, const void *val); + +/** * Reset a parameter to its default value. * * This function frees any storage used by struct parameters, and returns the parameter |