parameters: fix export shutdown locking

- in NuttX bchlib keeps a sector sized buffer that might not be written
out to RAMTRON until the file is closed
This commit is contained in:
Daniel Agar
2021-12-30 16:29:43 -05:00
parent 2153710917
commit 9cbb5c9920
7 changed files with 124 additions and 138 deletions
+1 -13
View File
@@ -433,21 +433,9 @@ param_main(int argc, char *argv[])
static int
do_save(const char *param_file_name)
{
/* create the file */
int fd = open(param_file_name, O_RDWR | O_CREAT, PX4_O_MODE_666);
if (fd < 0) {
PX4_ERR("open '%s' failed (%i)", param_file_name, errno);
return 1;
}
int result = param_export(fd, nullptr);
close(fd);
int result = param_export(param_file_name, nullptr);
if (result < 0) {
#ifndef __PX4_QURT
(void)unlink(param_file_name);
#endif
PX4_ERR("exporting to '%s' failed (%i)", param_file_name, result);
return 1;
}
+2 -11
View File
@@ -401,23 +401,14 @@ bool ParameterTest::exportImportAll()
// backup current parameters
const char *param_file_name = PX4_STORAGEDIR "/param_backup";
int fd = open(param_file_name, O_RDWR | O_CREAT, PX4_O_MODE_666);
if (fd < 0) {
PX4_ERR("open '%s' failed (%i)", param_file_name, errno);
return false;
}
int result = param_export(fd, nullptr);
int result = param_export(param_file_name, nullptr);
if (result != PX4_OK) {
PX4_ERR("param_export failed");
close(fd);
return false;
}
close(fd);
bool ret = true;
int N = param_count();
@@ -554,7 +545,7 @@ bool ParameterTest::exportImportAll()
param_reset_all();
// restore original params
fd = open(param_file_name, O_RDONLY);
int fd = open(param_file_name, O_RDONLY);
if (fd < 0) {
PX4_ERR("open '%s' failed (%i)", param_file_name, errno);