45 #ifndef _SYSTEMLIB_PARAM_PARAM_H 46 #define _SYSTEMLIB_PARAM_PARAM_H 50 #include <sys/types.h> 53 #define PARAM_FILE_MAXSIZE 4096 60 #define PARAM_TYPE_INT32 0 61 #define PARAM_TYPE_FLOAT 1 62 #define PARAM_TYPE_STRUCT 100 63 #define PARAM_TYPE_STRUCT_MAX (16384 + PARAM_TYPE_STRUCT) 64 #define PARAM_TYPE_UNKNOWN (0xffff) 69 #ifdef __PX4_NUTTX // on NuttX use 16 bits to save RAM 82 #define PARAM_INVALID ((uint16_t)0xffff) 87 #define PARAM_HASH ((uint16_t)INT16_MAX) 89 #else // on other platforms use 32 bits for better performance 103 #define PARAM_INVALID ((uint32_t)0xffffffff) 108 #define PARAM_HASH ((uint32_t)INT32_MAX) 456 #if 0 // set to 1 to debug param type mismatches 458 #define CHECK_PARAM_TYPE(param, type) \ 459 if (param_type(param) != type) { \ 461 printf("wrong type passed to param_get() for param %s\n", param_name(param)); \ 464 #define CHECK_PARAM_TYPE(param, type) 480 #undef CHECK_PARAM_TYPE __EXPORT param_t param_find_no_notification(const char *name)
Look up a parameter by name.
__EXPORT void param_init(void)
Initialize the param backend.
__EXPORT size_t param_size(param_t param)
Determine the size of a parameter.
__EXPORT bool param_value_unsaved(param_t param)
Test whether a parameter's value has been changed but not saved.
__EXPORT int param_import(int fd)
Import parameters from a file, discarding any unrecognized parameters.
__EXPORT void param_foreach(void(*func)(void *arg, param_t param), void *arg, bool only_changed, bool only_used)
Apply a function to each parameter.
#define PARAM_TYPE_INT32
Parameter types.
__EXPORT void param_print_status(void)
Print the status of the param system.
__EXPORT int param_get(param_t param, void *val)
Copy the value of a parameter.
__EXPORT int param_set_no_notification(param_t param, const void *val)
Set the value of a parameter, but do not notify the system about the change.
__EXPORT int param_get_index(param_t param)
Look up the index of a parameter.
__EXPORT const char * param_get_default_file(void)
Get the default parameter file name.
__EXPORT int param_set(param_t param, const void *val)
Set the value of a parameter.
__EXPORT param_t param_for_index(unsigned index)
Look up a parameter by index.
__EXPORT void param_set_used(param_t param)
Mark a parameter as used.
__EXPORT bool param_value_is_default(param_t param)
Test whether a parameter's value has changed from the default.
__EXPORT int param_get_used_index(param_t param)
Look up the index of an used parameter.
__EXPORT unsigned param_count(void)
Return the total number of parameters.
Static parameter definition structure.
__EXPORT const char * param_name(param_t param)
Obtain the name of a parameter.
__EXPORT void param_reset_excludes(const char *excludes[], int num_excludes)
Reset all parameters to their default values except for excluded parameters.
__EXPORT int param_export(int fd, bool only_unsaved)
Export changed parameters to a file.
__EXPORT unsigned param_count_used(void)
Return the actually used number of parameters.
__EXPORT int param_set_default_file(const char *filename)
Set the default parameter file name.
__EXPORT param_type_t param_type(param_t param)
Obtain the type of a parameter.
__EXPORT int param_save_default(void)
Save parameters to the default file.
struct __attribute__((__packed__)) reading_msg
__EXPORT uint32_t param_hash_check(void)
Generate the hash of all parameters and their values.
__EXPORT param_t param_find(const char *name)
Look up a parameter by name.
__EXPORT bool param_is_volatile(param_t param)
Obtain the volatile state of a parameter.
__EXPORT void param_notify_changes(void)
Notify the system about parameter changes.
__EXPORT void param_control_autosave(bool enable)
Enable/disable the param autosaving.
__EXPORT void param_reset_all(void)
Reset all parameters to their default values.
__EXPORT int param_reset(param_t param)
Reset a parameter to its default value.
__EXPORT param_t param_for_used_index(unsigned index)
Look up an used parameter by index.
__EXPORT int param_load_default(void)
Load parameters from the default parameter file.
__EXPORT int param_load(int fd)
Load parameters from a file.
uint32_t param_t
Parameter handle.
__EXPORT bool param_used(param_t param)
Wether a parameter is in use in the system.