From f92c5aa688d1c8d934af759fefa224b4cbecf810 Mon Sep 17 00:00:00 2001 From: Matthias Grob Date: Tue, 25 Aug 2020 19:41:07 +0200 Subject: [PATCH] ina226/voxlpm: make sure parameter sub is reset The subscription to parameter updates has to get copied otherwise the change detection will not get reset for next time. --- src/drivers/power_monitor/ina226/ina226.cpp | 6 ++++-- src/drivers/power_monitor/ina226/ina226.h | 2 +- src/drivers/power_monitor/voxlpm/voxlpm.cpp | 6 ++++-- src/drivers/power_monitor/voxlpm/voxlpm.hpp | 2 +- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/drivers/power_monitor/ina226/ina226.cpp b/src/drivers/power_monitor/ina226/ina226.cpp index c14cca4c71..ee74c612df 100644 --- a/src/drivers/power_monitor/ina226/ina226.cpp +++ b/src/drivers/power_monitor/ina226/ina226.cpp @@ -210,9 +210,11 @@ INA226::collect() { perf_begin(_sample_perf); - parameter_update_s param_update; + if (_parameter_update_sub.updated()) { + // Read from topic to clear updated flag + parameter_update_s parameter_update; + _parameter_update_sub.copy(¶meter_update); - if (_parameters_sub.copy(¶m_update)) { updateParams(); } diff --git a/src/drivers/power_monitor/ina226/ina226.h b/src/drivers/power_monitor/ina226/ina226.h index 399ca38f41..0ba8596fae 100644 --- a/src/drivers/power_monitor/ina226/ina226.h +++ b/src/drivers/power_monitor/ina226/ina226.h @@ -169,7 +169,7 @@ private: Battery _battery; uORB::Subscription _actuators_sub{ORB_ID(actuator_controls_0)}; - uORB::Subscription _parameters_sub{ORB_ID(parameter_update)}; + uORB::Subscription _parameter_update_sub{ORB_ID(parameter_update)}; int read(uint8_t address, int16_t &data); int write(uint8_t address, uint16_t data); diff --git a/src/drivers/power_monitor/voxlpm/voxlpm.cpp b/src/drivers/power_monitor/voxlpm/voxlpm.cpp index dc50d63b96..84b2be3ee6 100644 --- a/src/drivers/power_monitor/voxlpm/voxlpm.cpp +++ b/src/drivers/power_monitor/voxlpm/voxlpm.cpp @@ -316,9 +316,11 @@ VOXLPM::measure() } } - parameter_update_s update; + if (_parameter_update_sub.updated()) { + // Read from topic to clear updated flag + parameter_update_s parameter_update; + _parameter_update_sub.copy(¶meter_update); - if (_parameter_sub.update(&update)) { updateParams(); } diff --git a/src/drivers/power_monitor/voxlpm/voxlpm.hpp b/src/drivers/power_monitor/voxlpm/voxlpm.hpp index 29b0d07bc0..d3a991efca 100644 --- a/src/drivers/power_monitor/voxlpm/voxlpm.hpp +++ b/src/drivers/power_monitor/voxlpm/voxlpm.hpp @@ -253,7 +253,7 @@ private: perf_counter_t _comms_errors; uORB::PublicationMulti _pm_pub_topic{ORB_ID(power_monitor)}; - uORB::Subscription _parameter_sub{ORB_ID(parameter_update)}; + uORB::Subscription _parameter_update_sub{ORB_ID(parameter_update)}; power_monitor_s _pm_status{};