mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-23 01:03:33 +08:00
param: add PARAM_NO_AUTOSAVE: if defined, do not depend on LP work queue
Some NuttX configs do not have the work queues enabled.
This commit is contained in:
@@ -64,6 +64,9 @@
|
|||||||
#include "systemlib/uthash/utarray.h"
|
#include "systemlib/uthash/utarray.h"
|
||||||
#include "systemlib/bson/tinybson.h"
|
#include "systemlib/bson/tinybson.h"
|
||||||
|
|
||||||
|
//#define PARAM_NO_ORB ///< if defined, avoid uorb depenency. This disables publication of parameter_update on param change
|
||||||
|
//#define PARAM_NO_AUTOSAVE ///< if defined, do not autosave (avoids LP work queue dependency)
|
||||||
|
|
||||||
#if !defined(PARAM_NO_ORB)
|
#if !defined(PARAM_NO_ORB)
|
||||||
# include "uORB/uORB.h"
|
# include "uORB/uORB.h"
|
||||||
# include "uORB/topics/parameter_update.h"
|
# include "uORB/topics/parameter_update.h"
|
||||||
@@ -96,12 +99,14 @@ static char *param_user_file = NULL;
|
|||||||
#define PARAM_CLOSE close
|
#define PARAM_CLOSE close
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef PARAM_NO_AUTOSAVE
|
||||||
#include <px4_workqueue.h>
|
#include <px4_workqueue.h>
|
||||||
/* autosaving variables */
|
/* autosaving variables */
|
||||||
static hrt_abstime last_autosave_timestamp = 0;
|
static hrt_abstime last_autosave_timestamp = 0;
|
||||||
struct work_s autosave_work;
|
struct work_s autosave_work;
|
||||||
static bool autosave_scheduled = false;
|
static bool autosave_scheduled = false;
|
||||||
static bool autosave_disabled = false;
|
static bool autosave_disabled = false;
|
||||||
|
#endif /* PARAM_NO_AUTOSAVE */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Array of static parameter info.
|
* Array of static parameter info.
|
||||||
@@ -588,11 +593,14 @@ param_get(param_t param, void *val)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef PARAM_NO_AUTOSAVE
|
||||||
/**
|
/**
|
||||||
* worker callback method to save the parameters
|
* worker callback method to save the parameters
|
||||||
* @param arg unused
|
* @param arg unused
|
||||||
*/
|
*/
|
||||||
static void autosave_worker(void *arg)
|
static void
|
||||||
|
autosave_worker(void *arg)
|
||||||
{
|
{
|
||||||
bool disabled = false;
|
bool disabled = false;
|
||||||
|
|
||||||
@@ -613,6 +621,7 @@ static void autosave_worker(void *arg)
|
|||||||
PX4_ERR("param save failed (%i)", ret);
|
PX4_ERR("param save failed (%i)", ret);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif /* PARAM_NO_AUTOSAVE */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Automatically save the parameters after a timeout and limited rate.
|
* Automatically save the parameters after a timeout and limited rate.
|
||||||
@@ -620,8 +629,11 @@ static void autosave_worker(void *arg)
|
|||||||
* This needs to be called with the writer lock held (it's not necessary that it's the writer lock, but it
|
* This needs to be called with the writer lock held (it's not necessary that it's the writer lock, but it
|
||||||
* needs to be the same lock as autosave_worker() and param_control_autosave() use).
|
* needs to be the same lock as autosave_worker() and param_control_autosave() use).
|
||||||
*/
|
*/
|
||||||
static void param_autosave(void)
|
static void
|
||||||
|
param_autosave(void)
|
||||||
{
|
{
|
||||||
|
#ifndef PARAM_NO_AUTOSAVE
|
||||||
|
|
||||||
if (autosave_scheduled || autosave_disabled) {
|
if (autosave_scheduled || autosave_disabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -641,11 +653,13 @@ static void param_autosave(void)
|
|||||||
|
|
||||||
autosave_scheduled = true;
|
autosave_scheduled = true;
|
||||||
work_queue(LPWORK, &autosave_work, (worker_t)&autosave_worker, NULL, USEC2TICK(delay));
|
work_queue(LPWORK, &autosave_work, (worker_t)&autosave_worker, NULL, USEC2TICK(delay));
|
||||||
|
#endif /* PARAM_NO_AUTOSAVE */
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
param_control_autosave(bool enable)
|
param_control_autosave(bool enable)
|
||||||
{
|
{
|
||||||
|
#ifndef PARAM_NO_AUTOSAVE
|
||||||
param_lock_writer();
|
param_lock_writer();
|
||||||
|
|
||||||
if (!enable && autosave_scheduled) {
|
if (!enable && autosave_scheduled) {
|
||||||
@@ -655,8 +669,10 @@ param_control_autosave(bool enable)
|
|||||||
|
|
||||||
autosave_disabled = !enable;
|
autosave_disabled = !enable;
|
||||||
param_unlock_writer();
|
param_unlock_writer();
|
||||||
|
#endif /* PARAM_NO_AUTOSAVE */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
param_set_internal(param_t param, const void *val, bool mark_saved, bool notify_changes)
|
param_set_internal(param_t param, const void *val, bool mark_saved, bool notify_changes)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user