Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fca029c

Browse files
committed
ina226 update orb_publish_auto usage to uORB::PublicationMulti<>
1 parent 92933d9 commit fca029c

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/drivers/power_monitor/ina226/ina226.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
#include <lib/parameters/param.h>
4848
#include <lib/perf/perf_counter.h>
4949
#include <drivers/drv_hrt.h>
50-
#include <uORB/uORB.h>
50+
#include <uORB/PublicationMulti.hpp>
5151
#include <uORB/topics/power_monitor.h>
5252
#include <px4_platform_common/px4_work_queue/ScheduledWorkItem.hpp>
5353

@@ -164,7 +164,7 @@ class INA226 : public device::I2C, px4::ScheduledWorkItem
164164
int _measure_interval{0};
165165
bool _collect_phase{false};
166166

167-
orb_advert_t _power_monitor_topic{nullptr};
167+
uORB::PublicationMulti<power_monitor_s> _power_monitor_topic{ORB_ID(power_monitor)};
168168

169169
perf_counter_t _sample_perf;
170170
perf_counter_t _comms_errors;
@@ -394,7 +394,7 @@ INA226::collect()
394394

395395
if (_shunt >= 0) {
396396

397-
struct power_monitor_s report;
397+
power_monitor_s report{};
398398
report.timestamp = hrt_absolute_time();
399399
report.voltage_v = (float) _bus_volatage * INA226_VSCALE;
400400
report.current_a = (float) _current * _current_lsb;
@@ -411,8 +411,7 @@ INA226::collect()
411411
#endif
412412

413413
/* publish it */
414-
int instance;
415-
orb_publish_auto(ORB_ID(power_monitor), &_power_monitor_topic, &report, &instance, ORB_PRIO_DEFAULT);
414+
_power_monitor_topic.publish(report);
416415

417416
ret = OK;
418417
perf_end(_sample_perf);

0 commit comments

Comments
 (0)