aboutsummaryrefslogtreecommitdiff
path: root/apps/systemlib
diff options
context:
space:
mode:
authorpx4dev <px4@purgatory.org>2012-08-20 01:53:37 -0700
committerpx4dev <px4@purgatory.org>2012-08-20 01:53:37 -0700
commit56bba7816f179f3743853866343946fd9e303c69 (patch)
treebb0ac8db9f8829982c3d85b884ed0cbae3678598 /apps/systemlib
parentcc7a9c9b668c4575c2b3b50e004b2a9c1137908c (diff)
parent41172f24d5146575baba685f37631baee22ce0ef (diff)
downloadpx4-firmware-56bba7816f179f3743853866343946fd9e303c69.tar.gz
px4-firmware-56bba7816f179f3743853866343946fd9e303c69.tar.bz2
px4-firmware-56bba7816f179f3743853866343946fd9e303c69.zip
Merge branch 'px4dev_new_param' of https://github.com/PX4/Firmware into px4dev_new_param
Diffstat (limited to 'apps/systemlib')
-rw-r--r--apps/systemlib/param/param.c9
-rw-r--r--apps/systemlib/param/param.h14
2 files changed, 21 insertions, 2 deletions
diff --git a/apps/systemlib/param/param.c b/apps/systemlib/param/param.c
index 93a71b735..692489cd4 100644
--- a/apps/systemlib/param/param.c
+++ b/apps/systemlib/param/param.c
@@ -193,6 +193,15 @@ param_for_index(unsigned index)
return PARAM_INVALID;
}
+int
+param_get_index(param_t param)
+{
+ if (handle_in_range(param))
+ return (unsigned)param;
+
+ return -1;
+}
+
const char *
param_name(param_t param)
{
diff --git a/apps/systemlib/param/param.h b/apps/systemlib/param/param.h
index 29857b46b..643d0ef7b 100644
--- a/apps/systemlib/param/param.h
+++ b/apps/systemlib/param/param.h
@@ -103,6 +103,14 @@ __EXPORT unsigned param_count(void) __attribute__((const));
__EXPORT param_t param_for_index(unsigned index) __attribute__((const));
/**
+ * Look up the index of a parameter.
+ *
+ * @param param The parameter to obtain the index for.
+ * @return The index, or -1 if the parameter does not exist.
+ */
+__EXPORT int param_get_index(param_t param) __attribute__((const));
+
+/**
* Obtain the name of a parameter.
*
* @param param A handle returned by param_find or passed by param_foreach.
@@ -156,7 +164,7 @@ __EXPORT int param_set(param_t param, const void *val);
__EXPORT int param_export(int fd, bool only_unsaved);
/**
- * Import parameters from a file, discarding any unrecognised parameters.
+ * Import parameters from a file, discarding any unrecognized parameters.
*
* @param fd File descriptor to import from. (Currently expected to be a file.)
* @return Zero on success, nonzero if an error occurred during import.
@@ -167,7 +175,9 @@ __EXPORT int param_import(int fd);
/**
* Apply a function to each parameter.
*
- * Note that the parameter set is not locked during the traversal.
+ * Note that the parameter set is not locked during the traversal. It also does
+ * not hold an internal state, so the callback function can block or sleep between
+ * parameter callbacks.
*
* @param func The function to invoke for each parameter.
* @param arg Argument passed to the function.