diff --git a/src/drivers/ll40ls/LidarLiteI2C.cpp b/src/drivers/ll40ls/LidarLiteI2C.cpp index a9626c8c45..f3fb0dda45 100644 --- a/src/drivers/ll40ls/LidarLiteI2C.cpp +++ b/src/drivers/ll40ls/LidarLiteI2C.cpp @@ -62,7 +62,7 @@ LidarLiteI2C::LidarLiteI2C(int bus, const char *path, int address) : _collect_phase(false), _class_instance(-1), _orb_class_instance(-1), - _distance_sensor_topic(-1), + _distance_sensor_topic(nullptr), _sample_perf(perf_alloc(PC_ELAPSED, "ll40ls_i2c_read")), _comms_errors(perf_alloc(PC_COUNT, "ll40ls_i2c_comms_errors")), _buffer_overflows(perf_alloc(PC_COUNT, "ll40ls_buffer_i2c_overflows")), @@ -132,7 +132,7 @@ int LidarLiteI2C::init() _distance_sensor_topic = orb_advertise_multi(ORB_ID(distance_sensor), &ds_report, &_orb_class_instance, ORB_PRIO_LOW); - if (_distance_sensor_topic < 0) { + if (_distance_sensor_topic == nullptr) { debug("failed to create distance_sensor object. Did you start uOrb?"); } } @@ -442,7 +442,7 @@ int LidarLiteI2C::collect() report.id = 0; /* publish it, if we are the primary */ - if (_distance_sensor_topic >= 0) { + if (_distance_sensor_topic != nullptr) { orb_publish(ORB_ID(distance_sensor), _distance_sensor_topic, &report); } @@ -467,22 +467,6 @@ void LidarLiteI2C::start() /* schedule a cycle to start things */ work_queue(HPWORK, &_work, (worker_t)&LidarLiteI2C::cycle_trampoline, this, 1); - - /* notify about state change */ - struct subsystem_info_s info = { - true, - true, - true, - SUBSYSTEM_TYPE_RANGEFINDER - }; - static orb_advert_t pub = -1; - - if (pub > 0) { - orb_publish(ORB_ID(subsystem_info), pub, &info); - - } else { - pub = orb_advertise(ORB_ID(subsystem_info), &info); - } } void LidarLiteI2C::stop() diff --git a/src/drivers/ll40ls/LidarLiteI2C.h b/src/drivers/ll40ls/LidarLiteI2C.h index f03784fc4d..d9218e3435 100644 --- a/src/drivers/ll40ls/LidarLiteI2C.h +++ b/src/drivers/ll40ls/LidarLiteI2C.h @@ -51,7 +51,7 @@ #include #include -#include + /* Configuration Constants */ #define LL40LS_BUS PX4_I2C_BUS_EXPANSION diff --git a/src/drivers/ll40ls/LidarLitePWM.cpp b/src/drivers/ll40ls/LidarLitePWM.cpp index 14ce921b4d..406aa111b8 100644 --- a/src/drivers/ll40ls/LidarLitePWM.cpp +++ b/src/drivers/ll40ls/LidarLitePWM.cpp @@ -61,7 +61,7 @@ LidarLitePWM::LidarLitePWM(const char *path) : _orb_class_instance(-1), _pwmSub(-1), _pwm{}, - _distance_sensor_topic(-1), + _distance_sensor_topic(nullptr), _range{}, _sample_perf(perf_alloc(PC_ELAPSED, "ll40ls_pwm_read")), _read_errors(perf_alloc(PC_COUNT, "ll40ls_pwm_read_errors")), @@ -116,7 +116,7 @@ int LidarLitePWM::init() _distance_sensor_topic = orb_advertise_multi(ORB_ID(distance_sensor), &ds_report, &_orb_class_instance, ORB_PRIO_LOW); - if (_distance_sensor_topic < 0) { + if (_distance_sensor_topic == nullptr) { debug("failed to create distance_sensor object. Did you start uOrb?"); } } @@ -198,7 +198,7 @@ int LidarLitePWM::measure() return reset_sensor(); } - if (_distance_sensor_topic >= 0) { + if (_distance_sensor_topic != nullptr) { orb_publish(ORB_ID(distance_sensor), _distance_sensor_topic, &_range); }