mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-18 17:19:06 +08:00
param_import: add mark_saved argument
Behavior of the 'param import' command: - if no file provided, parameters are marked as saved (differs from before) - if a file is provided: parameters are not marked as saved
This commit is contained in:
parent
f6e8ddfaa0
commit
3e9692c5bd
@ -362,5 +362,5 @@ int flash_param_load()
|
||||
|
||||
int flash_param_import()
|
||||
{
|
||||
return param_import_internal(false);
|
||||
return param_import_internal(true);
|
||||
}
|
||||
|
||||
@ -308,10 +308,11 @@ __EXPORT int param_export(int fd, bool only_unsaved, param_filter_func filter);
|
||||
* This function merges the imported parameters with the current parameter set.
|
||||
*
|
||||
* @param fd File descriptor to import from (-1 selects the FLASH storage).
|
||||
* @param mark_saved Whether to mark imported parameters as already saved
|
||||
* @return Zero on success, nonzero if an error occurred during import.
|
||||
* Note that in the failure case, parameters may be inconsistent.
|
||||
*/
|
||||
__EXPORT int param_import(int fd);
|
||||
__EXPORT int param_import(int fd, bool mark_saved);
|
||||
|
||||
/**
|
||||
* Load parameters from a file.
|
||||
|
||||
@ -1300,13 +1300,13 @@ param_import_internal(int fd, bool mark_saved)
|
||||
}
|
||||
|
||||
int
|
||||
param_import(int fd)
|
||||
param_import(int fd, bool mark_saved)
|
||||
{
|
||||
if (fd < 0) {
|
||||
return flash_param_import();
|
||||
}
|
||||
|
||||
return param_import_internal(fd, false);
|
||||
return param_import_internal(fd, mark_saved);
|
||||
}
|
||||
|
||||
int
|
||||
|
||||
@ -1073,7 +1073,7 @@ param_load_default_no_notify()
|
||||
return 1;
|
||||
}
|
||||
|
||||
int result = param_import(fd_load);
|
||||
int result = param_import(fd_load, true);
|
||||
|
||||
close(fd_load);
|
||||
|
||||
@ -1351,10 +1351,10 @@ param_import_internal(int fd, bool mark_saved)
|
||||
}
|
||||
|
||||
int
|
||||
param_import(int fd)
|
||||
param_import(int fd, bool mark_saved)
|
||||
{
|
||||
#if !defined(FLASH_BASED_PARAMS)
|
||||
return param_import_internal(fd, false);
|
||||
return param_import_internal(fd, mark_saved);
|
||||
#else
|
||||
(void)fd; // unused
|
||||
// no need for locking here
|
||||
|
||||
@ -83,7 +83,7 @@ enum class COMPARE_ERROR_LEVEL {
|
||||
static int do_save(const char *param_file_name);
|
||||
static int do_save_default();
|
||||
static int do_load(const char *param_file_name);
|
||||
static int do_import(const char *param_file_name);
|
||||
static int do_import(const char *param_file_name = nullptr);
|
||||
static int do_show(const char *search_string, bool only_changed);
|
||||
static int do_show_for_airframe();
|
||||
static int do_show_all();
|
||||
@ -213,7 +213,7 @@ param_main(int argc, char *argv[])
|
||||
return do_import(argv[2]);
|
||||
|
||||
} else {
|
||||
return do_import(param_get_default_file());
|
||||
return do_import();
|
||||
}
|
||||
}
|
||||
|
||||
@ -428,6 +428,12 @@ do_load(const char *param_file_name)
|
||||
static int
|
||||
do_import(const char *param_file_name)
|
||||
{
|
||||
bool mark_saved = false;
|
||||
if (param_file_name == nullptr) {
|
||||
param_file_name = param_get_default_file();
|
||||
mark_saved = true; // if imported from default storage, mark as saved
|
||||
}
|
||||
|
||||
int fd = -1;
|
||||
if (param_file_name) { // passing NULL means to select the flash storage
|
||||
fd = open(param_file_name, O_RDONLY);
|
||||
@ -438,7 +444,7 @@ do_import(const char *param_file_name)
|
||||
}
|
||||
}
|
||||
|
||||
int result = param_import(fd);
|
||||
int result = param_import(fd, mark_saved);
|
||||
if (fd >= 0) {
|
||||
close(fd);
|
||||
}
|
||||
|
||||
@ -363,7 +363,7 @@ bool ParameterTest::exportImportAll()
|
||||
return false;
|
||||
}
|
||||
|
||||
int result = param_export(fd, false);
|
||||
int result = param_export(fd, false, nullptr);
|
||||
|
||||
if (result != PX4_OK) {
|
||||
PX4_ERR("param_export failed");
|
||||
@ -516,7 +516,7 @@ bool ParameterTest::exportImportAll()
|
||||
return false;
|
||||
}
|
||||
|
||||
result = param_import(fd);
|
||||
result = param_import(fd, false);
|
||||
close(fd);
|
||||
|
||||
if (result < 0) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user