I am trying to add a parameter for my sensor driver and was able to update the parameter successfully in the initialization time.
-
Create a parameter file “name_params.c” and defined a param
PARAM_DEFINE_FLOAT(SENS_RNG_LPF, 0.25f); -
Added followings as private variables
int _params_sub{-1}; /**< parameter updates subscription */
param_t _param_lpf; -
Subscribe parameter_update in the constructor
_params_sub = orb_subscribe(ORB_ID(parameter_update)); -
Update param in init() function as following
_param_lpf = param_find(“SENS_RNG_LPF”);
if (_param_lpf != PARAM_INVALID) {
float val = 2.5;
param_get(_param_lpf, &val);
_lpf_cutoff_freq = val;
} -
During run time I tried to poll updated parameters as here
void LidarLitePWM::parameter_update_poll()
{
bool updated;
/* Check if parameters have changed */
orb_check(_params_sub, &updated);
if (updated) {
struct parameter_update_s param_update;
orb_copy(ORB_ID(parameter_update), _params_sub, ¶m_update);
float val = 2.5;
param_get(_param_lpf, &val);
_lpf_cutoff_freq = val;
}
}
1 - 4 works fine as the parameter save and update works in the initialization time however 5 is not working in the run time.
What should I change in order to able to change parameters in the run time?
Any help would much appreciated.
Thanks,
Kyu