forked from Archive/PX4-Autopilot
param: enable reseting specific parameters from shell
Renaming previous "param reset" to "param reset_all".
This commit is contained in:
parent
f70dda12a6
commit
ce9954a919
|
@ -993,7 +993,7 @@ void cleanupFTDI() {
|
|||
|
||||
// wipe parameters
|
||||
sh './Tools/HIL/run_nsh_cmd.py --device `find /dev/serial -name *usb-FTDI_*` --cmd "mtd erase"'
|
||||
sh './Tools/HIL/run_nsh_cmd.py --device `find /dev/serial -name *usb-FTDI_*` --cmd "param reset"'
|
||||
sh './Tools/HIL/run_nsh_cmd.py --device `find /dev/serial -name *usb-FTDI_*` --cmd "param reset_all"'
|
||||
|
||||
// disable buzzer and cleanup storage
|
||||
sh './Tools/HIL/run_nsh_cmd.py --device `find /dev/serial -name *usb-FTDI_*` --cmd "param set CBRK_BUZZER 782097"'
|
||||
|
@ -1020,7 +1020,7 @@ void cleanupSEGGER() {
|
|||
|
||||
// wipe parameters
|
||||
sh './Tools/HIL/run_nsh_cmd.py --device `find /dev/serial -name *usb-SEGGER_*` --cmd "mtd erase"'
|
||||
sh './Tools/HIL/run_nsh_cmd.py --device `find /dev/serial -name *usb-SEGGER_*` --cmd "param reset"'
|
||||
sh './Tools/HIL/run_nsh_cmd.py --device `find /dev/serial -name *usb-SEGGER_*` --cmd "param reset_all"'
|
||||
|
||||
// disable buzzer and cleanup storage
|
||||
sh './Tools/HIL/run_nsh_cmd.py --device `find /dev/serial -name *usb-SEGGER_*` --cmd "param set CBRK_BUZZER 782097"'
|
||||
|
|
|
@ -51,7 +51,7 @@ fi
|
|||
param select $PARAM_FILE
|
||||
if ! param load
|
||||
then
|
||||
param reset
|
||||
param reset_all
|
||||
fi
|
||||
|
||||
#
|
||||
|
|
|
@ -169,7 +169,7 @@ else
|
|||
param select $PARAM_FILE
|
||||
if ! param load
|
||||
then
|
||||
param reset
|
||||
param reset_all
|
||||
fi
|
||||
|
||||
#
|
||||
|
|
|
@ -278,6 +278,16 @@ __EXPORT void param_reset_all(void);
|
|||
*/
|
||||
__EXPORT void param_reset_excludes(const char *excludes[], int num_excludes);
|
||||
|
||||
/**
|
||||
* Reset only specific parameters to their default values.
|
||||
*
|
||||
* This function also releases the storage used by struct parameters.
|
||||
*
|
||||
* @param resets Array of param names to reset. Use a wildcard at the end to reset parameters with a certain prefix.
|
||||
* @param num_resets The number of passed reset conditions in the resets array.
|
||||
*/
|
||||
__EXPORT void param_reset_specific(const char *resets[], int num_resets);
|
||||
|
||||
/**
|
||||
* Export changed parameters to a file.
|
||||
* Note: this method requires a large amount of stack size!
|
||||
|
|
|
@ -881,8 +881,33 @@ param_reset_excludes(const char *excludes[], int num_excludes)
|
|||
param_reset(param);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_param_notify_changes();
|
||||
void
|
||||
param_reset_specific(const char *resets[], int num_resets)
|
||||
{
|
||||
param_t param;
|
||||
|
||||
for (param = 0; handle_in_range(param); param++) {
|
||||
const char *name = param_name(param);
|
||||
bool reset = false;
|
||||
|
||||
for (int index = 0; index < num_resets; index++) {
|
||||
int len = strlen(resets[index]);
|
||||
|
||||
if ((resets[index][len - 1] == '*'
|
||||
&& strncmp(name, resets[index], len - 1) == 0)
|
||||
|| strcmp(name, resets[index]) == 0) {
|
||||
|
||||
reset = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (reset) {
|
||||
param_reset(param);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
@ -92,7 +92,8 @@ static void do_show_print(void *arg, param_t param);
|
|||
static int do_set(const char *name, const char *val, bool fail_on_not_found);
|
||||
static int do_compare(const char *name, char *vals[], unsigned comparisons, enum COMPARE_OPERATOR cmd_op,
|
||||
enum COMPARE_ERROR_LEVEL err_level);
|
||||
static int do_reset(const char *excludes[], int num_excludes);
|
||||
static int do_reset_all(const char *excludes[], int num_excludes);
|
||||
static int do_reset_specific(const char *resets[], int num_resets);
|
||||
static int do_touch(const char *params[], int num_params);
|
||||
static int do_reset_nostart(const char *excludes[], int num_excludes);
|
||||
static int do_find(const char *name);
|
||||
|
@ -161,7 +162,9 @@ $ reboot
|
|||
PRINT_MODULE_USAGE_COMMAND_DESCR("touch", "Mark a parameter as used");
|
||||
PRINT_MODULE_USAGE_ARG("<param_name1> [<param_name2>]", "Parameter name (one or more)", true);
|
||||
|
||||
PRINT_MODULE_USAGE_COMMAND_DESCR("reset", "Reset params to default");
|
||||
PRINT_MODULE_USAGE_COMMAND_DESCR("reset", "Reset only specified params to default");
|
||||
PRINT_MODULE_USAGE_ARG("<param1> [<param2>]", "Parameter names to reset (wildcard at end allowed)", true);
|
||||
PRINT_MODULE_USAGE_COMMAND_DESCR("reset_all", "Reset all params to default");
|
||||
PRINT_MODULE_USAGE_ARG("<exclude1> [<exclude2>]", "Do not reset matching params (wildcard at end allowed)", true);
|
||||
PRINT_MODULE_USAGE_COMMAND_DESCR("reset_nostart",
|
||||
"Reset params to default, but keep SYS_AUTOSTART and SYS_AUTOCONFIG");
|
||||
|
@ -302,10 +305,20 @@ param_main(int argc, char *argv[])
|
|||
|
||||
if (!strcmp(argv[1], "reset")) {
|
||||
if (argc >= 3) {
|
||||
return do_reset((const char **) &argv[2], argc - 2);
|
||||
return do_reset_specific((const char **) &argv[2], argc - 2);
|
||||
|
||||
} else {
|
||||
return do_reset(nullptr, 0);
|
||||
PX4_ERR("not enough arguments (use 'param reset_all' to reset all).");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!strcmp(argv[1], "reset_all")) {
|
||||
if (argc >= 3) {
|
||||
return do_reset_all((const char **) &argv[2], argc - 2);
|
||||
|
||||
} else {
|
||||
return do_reset_all(nullptr, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -794,7 +807,7 @@ do_compare(const char *name, char *vals[], unsigned comparisons, enum COMPARE_OP
|
|||
}
|
||||
|
||||
static int
|
||||
do_reset(const char *excludes[], int num_excludes)
|
||||
do_reset_all(const char *excludes[], int num_excludes)
|
||||
{
|
||||
if (num_excludes > 0) {
|
||||
param_reset_excludes(excludes, num_excludes);
|
||||
|
@ -806,6 +819,13 @@ do_reset(const char *excludes[], int num_excludes)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
do_reset_specific(const char *resets[], int num_resets)
|
||||
{
|
||||
param_reset_specific(resets, num_resets);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
do_touch(const char *params[], int num_params)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue