parameter_update use uORB::Subscription consistently

This commit is contained in:
Daniel Agar
2019-09-29 10:49:03 -04:00
parent bbb96cbd0c
commit c8e59c4e39
47 changed files with 274 additions and 259 deletions
+9 -15
View File
@@ -145,8 +145,7 @@ void Module::run()
fds[0].events = POLLIN;
// initialize parameters
int parameter_update_sub = orb_subscribe(ORB_ID(parameter_update));
parameters_update(parameter_update_sub, true);
parameters_update(true);
while (!should_exit()) {
@@ -170,26 +169,21 @@ void Module::run()
}
parameters_update(parameter_update_sub);
parameters_update();
}
orb_unsubscribe(sensor_combined_sub);
orb_unsubscribe(parameter_update_sub);
}
void Module::parameters_update(int parameter_update_sub, bool force)
void Module::parameters_update(bool force)
{
bool updated;
struct parameter_update_s param_upd;
// check for parameter updates
if (_parameter_update_sub.updated() || force) {
// clear update
parameter_update_s update;
_parameter_update_sub.copy(&update);
orb_check(parameter_update_sub, &updated);
if (updated) {
orb_copy(ORB_ID(parameter_update), parameter_update_sub, &param_upd);
}
if (force || updated) {
// update parameters from storage
updateParams();
}
}
+7 -1
View File
@@ -35,6 +35,8 @@
#include <px4_module.h>
#include <px4_module_params.h>
#include <uORB/Subscription.hpp>
#include <uORB/topics/parameter_update.h>
extern "C" __EXPORT int module_main(int argc, char *argv[]);
@@ -71,12 +73,16 @@ private:
* @param parameter_update_sub uorb subscription to parameter_update
* @param force for a parameter update
*/
void parameters_update(int parameter_update_sub, bool force = false);
void parameters_update(bool force = false);
DEFINE_PARAMETERS(
(ParamInt<px4::params::SYS_AUTOSTART>) _param_sys_autostart, /**< example parameter */
(ParamInt<px4::params::SYS_AUTOCONFIG>) _param_sys_autoconfig /**< another parameter */
)
// Subscriptions
uORB::Subscription _parameter_update_sub{ORB_ID(parameter_update)};
};