aboutsummaryrefslogtreecommitdiff
path: root/src/systemcmds/param
diff options
context:
space:
mode:
authorLorenz Meier <lm@inf.ethz.ch>2014-05-14 14:23:16 +0200
committerLorenz Meier <lm@inf.ethz.ch>2014-05-14 14:23:16 +0200
commitc646a8ff1d6fd0b0f08ed317619c20b83b49e418 (patch)
treeb0571a0cc1aa04e10727ecdcc29720c32edac4c8 /src/systemcmds/param
parente5d28b239393748a5ba2a9ca7ab1733f5333cbd1 (diff)
downloadpx4-firmware-c646a8ff1d6fd0b0f08ed317619c20b83b49e418.tar.gz
px4-firmware-c646a8ff1d6fd0b0f08ed317619c20b83b49e418.tar.bz2
px4-firmware-c646a8ff1d6fd0b0f08ed317619c20b83b49e418.zip
Let the param set command default to non-failing, because unknown params are in the script default init not a reason to give up on the complete boot
Diffstat (limited to 'src/systemcmds/param')
-rw-r--r--src/systemcmds/param/param.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/systemcmds/param/param.c b/src/systemcmds/param/param.c
index 984d19bd9..d92ee88ef 100644
--- a/src/systemcmds/param/param.c
+++ b/src/systemcmds/param/param.c
@@ -61,7 +61,7 @@ static void do_load(const char* param_file_name);
static void do_import(const char* param_file_name);
static void do_show(const char* search_string);
static void do_show_print(void *arg, param_t param);
-static void do_set(const char* name, const char* val);
+static void do_set(const char* name, const char* val, bool fail_on_not_found);
static void do_compare(const char* name, const char* vals[], unsigned comparisons);
static void do_reset();
@@ -117,10 +117,17 @@ param_main(int argc, char *argv[])
}
if (!strcmp(argv[1], "set")) {
- if (argc >= 4) {
- do_set(argv[2], argv[3]);
+ if (argc >= 5) {
+
+ /* if the fail switch is provided, fails the command if not found */
+ bool fail = !strcmp(argv[4], "fail");
+
+ do_set(argv[2], argv[3], fail);
+
+ } else if (argc >= 4) {
+ do_set(argv[2], argv[3], false);
} else {
- errx(1, "not enough arguments.\nTry 'param set PARAM_NAME 3'");
+ errx(1, "not enough arguments.\nTry 'param set PARAM_NAME 3 [fail]'");
}
}
@@ -282,7 +289,7 @@ do_show_print(void *arg, param_t param)
}
static void
-do_set(const char* name, const char* val)
+do_set(const char* name, const char* val, bool fail_on_not_found)
{
int32_t i;
float f;
@@ -290,8 +297,8 @@ do_set(const char* name, const char* val)
/* set nothing if parameter cannot be found */
if (param == PARAM_INVALID) {
- /* param not found */
- errx(1, "Error: Parameter %s not found.", name);
+ /* param not found - fail silenty in scripts as it prevents booting */
+ errx(((fail_on_not_found) ? 1 : 0), "Error: Parameter %s not found.", name);
}
printf("%c %s: ",