diff options
-rw-r--r-- | ROMFS/px4fmu_common/init.d/rcS | 4 | ||||
-rw-r--r-- | src/modules/systemlib/system_params.c | 5 | ||||
-rw-r--r-- | src/systemcmds/param/param.c | 43 |
3 files changed, 35 insertions, 17 deletions
diff --git a/ROMFS/px4fmu_common/init.d/rcS b/ROMFS/px4fmu_common/init.d/rcS index 4e7208de6..1663a2ab3 100644 --- a/ROMFS/px4fmu_common/init.d/rcS +++ b/ROMFS/px4fmu_common/init.d/rcS @@ -122,8 +122,8 @@ then # if param compare SYS_AUTOCONFIG 1 then - # Wipe out params - param reset_nostart + # Wipe out params except RC* + param reset_nostart RC* set AUTOCNF yes else set AUTOCNF no diff --git a/src/modules/systemlib/system_params.c b/src/modules/systemlib/system_params.c index a0988035c..497b7da37 100644 --- a/src/modules/systemlib/system_params.c +++ b/src/modules/systemlib/system_params.c @@ -52,8 +52,9 @@ PARAM_DEFINE_INT32(SYS_AUTOSTART, 0); /** * Automatically configure default values. * - * Set to 1 to set platform-specific parameters to their default - * values on next system startup. + * Set to 1 to reset parameters on next system startup (setting defaults). + * Platform-specific values are used if available. + * RC* parameters are preserved. * * @min 0 * @max 1 diff --git a/src/systemcmds/param/param.c b/src/systemcmds/param/param.c index 0b6d3b8d3..7273c4148 100644 --- a/src/systemcmds/param/param.c +++ b/src/systemcmds/param/param.c @@ -1,6 +1,6 @@ /**************************************************************************** * - * Copyright (c) 2012, 2013 PX4 Development Team. All rights reserved. + * Copyright (c) 2012-2015 PX4 Development Team. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -33,7 +33,8 @@ /** * @file param.c - * @author Lorenz Meier <lm@inf.ethz.ch> + * @author Lorenz Meier <lorenz@px4.io> + * @author Andreas Antener <andreas@uaventure.com> * * Parameter tool. */ @@ -62,10 +63,10 @@ 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, bool fail_on_not_found); -static void do_compare(const char *name, char *vals[], unsigned comparisons); -static void do_reset(void); -static void do_reset_nostart(void); +static void do_set(const char* name, const char* val, bool fail_on_not_found); +static void do_compare(const char* name, char* vals[], unsigned comparisons); +static void do_reset(const char* excludes[], int num_excludes); +static void do_reset_nostart(const char* excludes[], int num_excludes); int param_main(int argc, char *argv[]) @@ -151,11 +152,19 @@ param_main(int argc, char *argv[]) } if (!strcmp(argv[1], "reset")) { - do_reset(); + if (argc >= 3) { + do_reset((const char**) &argv[2], argc - 2); + } else { + do_reset(NULL, 0); + } } if (!strcmp(argv[1], "reset_nostart")) { - do_reset_nostart(); + if (argc >= 3) { + do_reset_nostart((const char**) &argv[2], argc - 2); + } else { + do_reset_nostart(NULL, 0); + } } } @@ -452,10 +461,14 @@ do_compare(const char *name, char *vals[], unsigned comparisons) } static void -do_reset(void) +do_reset(const char* excludes[], int num_excludes) { - param_reset_all(); - + if (num_excludes > 0) { + param_reset_excludes(excludes, num_excludes); + } else { + param_reset_all(); + } + if (param_save_default()) { warnx("Param export failed."); exit(1); @@ -466,7 +479,7 @@ do_reset(void) } static void -do_reset_nostart(void) +do_reset_nostart(const char* excludes[], int num_excludes) { int32_t autostart; @@ -475,7 +488,11 @@ do_reset_nostart(void) (void)param_get(param_find("SYS_AUTOSTART"), &autostart); (void)param_get(param_find("SYS_AUTOCONFIG"), &autoconfig); - param_reset_all(); + if (num_excludes > 0) { + param_reset_excludes(excludes, num_excludes); + } else { + param_reset_all(); + } (void)param_set(param_find("SYS_AUTOSTART"), &autostart); (void)param_set(param_find("SYS_AUTOCONFIG"), &autoconfig); |