mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +08:00
param: add param_get_system_default_value
This commit is contained in:
parent
c356181f90
commit
b512a3d8f7
@ -215,13 +215,22 @@ __EXPORT size_t param_size(param_t param);
|
||||
__EXPORT int param_get(param_t param, void *val);
|
||||
|
||||
/**
|
||||
* Copy the default value of a parameter.
|
||||
* Copy the (airframe-specific) default value of a parameter.
|
||||
*
|
||||
* @param param A handle returned by param_find or passed by param_foreach.
|
||||
* @param val Where to return the value, assumed to point to suitable storage for the parameter type.
|
||||
* @param default_val Where to return the value, assumed to point to suitable storage for the parameter type.
|
||||
* @return Zero if the parameter's deafult value could be returned, nonzero otherwise.
|
||||
*/
|
||||
__EXPORT int param_get_default_value(param_t param, void *val);
|
||||
__EXPORT int param_get_default_value(param_t param, void *default_val);
|
||||
|
||||
/**
|
||||
* Copy the system-wide default value of a parameter.
|
||||
*
|
||||
* @param param A handle returned by param_find or passed by param_foreach.
|
||||
* @param default_val Where to return the value, assumed to point to suitable storage for the parameter type.
|
||||
* @return Zero if the parameter's deafult value could be returned, nonzero otherwise.
|
||||
*/
|
||||
__EXPORT int param_get_system_default_value(param_t param, void *default_val);
|
||||
|
||||
/**
|
||||
* Set the value of a parameter.
|
||||
|
||||
@ -617,6 +617,34 @@ bool param_value_is_default(param_t param)
|
||||
return false;
|
||||
}
|
||||
|
||||
int
|
||||
param_get_system_default_value(param_t param, void *default_val)
|
||||
{
|
||||
if (!handle_in_range(param)) {
|
||||
return PX4_ERROR;
|
||||
}
|
||||
|
||||
int ret = PX4_OK;
|
||||
param_lock_reader();
|
||||
|
||||
switch (param_type(param)) {
|
||||
case PARAM_TYPE_INT32:
|
||||
memcpy(default_val, &px4::parameters[param].val.i, param_size(param));
|
||||
break;
|
||||
|
||||
case PARAM_TYPE_FLOAT:
|
||||
memcpy(default_val, &px4::parameters[param].val.f, param_size(param));
|
||||
break;
|
||||
|
||||
default:
|
||||
ret = PX4_ERROR;
|
||||
break;
|
||||
}
|
||||
|
||||
param_unlock_reader();
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* worker callback method to save the parameters
|
||||
* @param arg unused
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user