From ebce93f338b5e17a7b89a3d276a676c8987fba83 Mon Sep 17 00:00:00 2001 From: Nicolas de Palezieux Date: Fri, 26 Aug 2016 14:28:46 +0200 Subject: [PATCH] only advertise range topic of px4flow board if it is the primary range device (#5390) this allows selecting another range device such as a lidar by starting that app first --- src/drivers/px4flow/px4flow.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/drivers/px4flow/px4flow.cpp b/src/drivers/px4flow/px4flow.cpp index 03015e315b..ef9f1759e4 100644 --- a/src/drivers/px4flow/px4flow.cpp +++ b/src/drivers/px4flow/px4flow.cpp @@ -245,11 +245,16 @@ PX4FLOW::init() /* get a publish handle on the range finder topic */ struct distance_sensor_s ds_report = {}; - _distance_sensor_topic = orb_advertise_multi(ORB_ID(distance_sensor), &ds_report, - &_orb_class_instance, ORB_PRIO_HIGH); + if (_class_instance == CLASS_DEVICE_PRIMARY) { + _distance_sensor_topic = orb_advertise_multi(ORB_ID(distance_sensor), &ds_report, + &_orb_class_instance, ORB_PRIO_HIGH); - if (_distance_sensor_topic == nullptr) { - DEVICE_LOG("failed to create distance_sensor object. Did you start uOrb?"); + if (_distance_sensor_topic == nullptr) { + DEVICE_LOG("failed to create distance_sensor object. Did you start uOrb?"); + } + + } else { + DEVICE_LOG("not primary range device, not advertising"); } ret = OK;