mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +08:00
param: add 'param touch <param_name>' command
so that params can be marked as used from scripts.
This commit is contained in:
parent
91a1ac1b60
commit
15044909a4
@ -87,6 +87,7 @@ 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);
|
||||
static int do_reset(const char *excludes[], int num_excludes);
|
||||
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);
|
||||
|
||||
@ -140,6 +141,9 @@ $ reboot
|
||||
"Compare a param with a value. Command will succeed if param is greater than the value");
|
||||
PRINT_MODULE_USAGE_ARG("<param_name> <value>", "Parameter name and value to compare", false);
|
||||
|
||||
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_ARG("<exclude1> [<exclude2>]", "Do not reset matching params (wildcard at end allowed)", true);
|
||||
PRINT_MODULE_USAGE_COMMAND_DESCR("reset_nostart",
|
||||
@ -275,6 +279,15 @@ param_main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
if (!strcmp(argv[1], "touch")) {
|
||||
if (argc >= 3) {
|
||||
return do_touch((const char **) &argv[2], argc - 2);
|
||||
} else {
|
||||
PX4_ERR("not enough arguments.");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!strcmp(argv[1], "reset_nostart")) {
|
||||
if (argc >= 3) {
|
||||
return do_reset_nostart((const char **) &argv[2], argc - 2);
|
||||
@ -759,6 +772,17 @@ do_reset(const char *excludes[], int num_excludes)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
do_touch(const char *params[], int num_params)
|
||||
{
|
||||
for (int i = 0; i < num_params; ++i) {
|
||||
if (param_find(params[i]) == PARAM_INVALID) {
|
||||
PX4_ERR("param %s not found", params[i]);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
do_reset_nostart(const char *excludes[], int num_excludes)
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user