mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-06-25 21:10:34 +08:00
param command: use param_* calls even if flash-based params are enabled
This will ensure proper locking.
This commit is contained in:
@@ -342,11 +342,6 @@ int flash_param_save(void)
|
||||
}
|
||||
|
||||
|
||||
int flash_param_save_default(void)
|
||||
{
|
||||
return param_export_internal(false);
|
||||
}
|
||||
|
||||
|
||||
int flash_param_load(void)
|
||||
{
|
||||
@@ -356,5 +351,5 @@ int flash_param_load(void)
|
||||
|
||||
int flash_param_import(void)
|
||||
{
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -64,9 +64,8 @@ __EXPORT extern UT_array *param_values;
|
||||
__EXPORT int param_set_external(param_t param, const void *val, bool mark_saved, bool notify_changes, bool is_saved);
|
||||
__EXPORT const void *param_get_value_ptr_external(param_t param);
|
||||
|
||||
/* The interface hooks to the Flash based storage */
|
||||
/* The interface hooks to the Flash based storage. The caller is responsible for locking */
|
||||
__EXPORT int flash_param_save(void);
|
||||
__EXPORT int flash_param_save_default(void);
|
||||
__EXPORT int flash_param_load(void);
|
||||
__EXPORT int flash_param_import(void);
|
||||
__END_DECLS
|
||||
|
||||
@@ -803,7 +803,9 @@ param_save_default(void)
|
||||
|
||||
PARAM_CLOSE(fd);
|
||||
#else
|
||||
param_lock();
|
||||
res = flash_param_save();
|
||||
param_unlock();
|
||||
#endif
|
||||
return res;
|
||||
}
|
||||
@@ -814,7 +816,8 @@ param_save_default(void)
|
||||
int
|
||||
param_load_default(void)
|
||||
{
|
||||
warnx("param_load_default\n");
|
||||
int res = 0;
|
||||
#if !defined(FLASH_BASED_PARAMS)
|
||||
int fd_load = PARAM_OPEN(param_get_default_file(), O_RDONLY);
|
||||
|
||||
if (fd_load < 0) {
|
||||
@@ -835,7 +838,11 @@ param_load_default(void)
|
||||
return -2;
|
||||
}
|
||||
|
||||
return 0;
|
||||
#else
|
||||
// no need for locking
|
||||
res = flash_param_load();
|
||||
#endif
|
||||
return res;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1134,7 +1141,13 @@ out:
|
||||
int
|
||||
param_import(int fd)
|
||||
{
|
||||
#if !defined(FLASH_BASED_PARAMS)
|
||||
return param_import_internal(fd, false);
|
||||
#else
|
||||
(void)fd; // unused
|
||||
// no need for locking here
|
||||
return flash_param_import();
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
|
||||
Reference in New Issue
Block a user