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
@@ -59,17 +59,13 @@ FactoryCalibrationStorage::FactoryCalibrationStorage()
int FactoryCalibrationStorage::open()
{
if (_fd >= 0) {
cleanup();
}
if (!_enabled) {
return 0;
}
_fd = ::open(CALIBRATION_STORAGE, O_RDWR);
int ret = ::access(CALIBRATION_STORAGE, R_OK | W_OK);
if (_fd == -1) {
if (ret != 0) {
return -errno;
}
@@ -84,7 +80,7 @@ int FactoryCalibrationStorage::store()
return 0;
}
int ret = param_export(_fd, filter_calibration_params);
int ret = param_export(CALIBRATION_STORAGE, filter_calibration_params);
if (ret != 0) {
PX4_ERR("param export failed (%i)", ret);
@@ -98,10 +94,5 @@ void FactoryCalibrationStorage::cleanup()
if (_enabled) {
param_control_autosave(true);
}
if (_fd >= 0) {
close(_fd);
_fd = -1;
}
}
@@ -60,5 +60,4 @@ private:
void cleanup();
bool _enabled{false};
int _fd{-1};
};