diff --git a/src/drivers/distance_sensor/sf0x/sf0x.cpp b/src/drivers/distance_sensor/sf0x/sf0x.cpp index 4ef5a111ed..06d3297390 100644 --- a/src/drivers/distance_sensor/sf0x/sf0x.cpp +++ b/src/drivers/distance_sensor/sf0x/sf0x.cpp @@ -81,7 +81,7 @@ // designated SERIAL4/5 on Pixhawk #define SF0X_DEFAULT_PORT "/dev/ttyS6" -class SF0X : public device::CDev +class SF0X : public cdev::CDev { public: SF0X(const char *port = SF0X_DEFAULT_PORT, uint8_t rotation = distance_sensor_s::ROTATION_DOWNWARD_FACING); @@ -106,7 +106,7 @@ private: float _min_distance; float _max_distance; int _conversion_interval; - work_s _work; + work_s _work{}; ringbuffer::RingBuffer *_reports; int _measure_ticks; bool _collect_phase; @@ -173,7 +173,7 @@ private: extern "C" __EXPORT int sf0x_main(int argc, char *argv[]); SF0X::SF0X(const char *port, uint8_t rotation) : - CDev("SF0X", RANGE_FINDER0_DEVICE_PATH), + CDev(RANGE_FINDER0_DEVICE_PATH), _rotation(rotation), _min_distance(0.30f), _max_distance(40.0f), @@ -231,12 +231,6 @@ SF0X::SF0X(const char *port, uint8_t rotation) : if ((termios_state = tcsetattr(_fd, TCSANOW, &uart_config)) < 0) { warnx("ERR baud %d ATTR", termios_state); } - - // disable debug() calls - _debug_enabled = false; - - // work_cancel in the dtor will explode if we don't do this... - memset(&_work, 0, sizeof(_work)); } SF0X::~SF0X() @@ -265,7 +259,7 @@ SF0X::init() switch (hw_model) { case 0: - DEVICE_LOG("disabled."); + PX4_WARN("disabled."); return 0; case 1: /* SF02 (40m, 12 Hz)*/ @@ -300,7 +294,7 @@ SF0X::init() break; default: - DEVICE_LOG("invalid HW model %d.", hw_model); + PX4_ERR("invalid HW model %d.", hw_model); return -1; } @@ -332,7 +326,7 @@ SF0X::init() &_orb_class_instance, ORB_PRIO_HIGH); if (_distance_sensor_topic == nullptr) { - DEVICE_LOG("failed to create distance_sensor object. Did you start uOrb?"); + PX4_ERR("failed to create distance_sensor object"); } } while (0); @@ -547,7 +541,7 @@ SF0X::measure() if (ret != sizeof(cmd)) { perf_count(_comms_errors); - DEVICE_LOG("write fail %d", ret); + PX4_DEBUG("write fail %d", ret); return ret; } @@ -574,7 +568,7 @@ SF0X::collect() ret = ::read(_fd, &readbuf[0], readlen); if (ret < 0) { - DEVICE_DEBUG("read err: %d", ret); + PX4_DEBUG("read err: %d", ret); perf_count(_comms_errors); perf_end(_sample_perf); @@ -605,7 +599,7 @@ SF0X::collect() return -EAGAIN; } - DEVICE_DEBUG("val (float): %8.4f, raw: %s, valid: %s", (double)distance_m, _linebuf, ((valid) ? "OK" : "NO")); + PX4_DEBUG("val (float): %8.4f, raw: %s, valid: %s", (double)distance_m, _linebuf, ((valid) ? "OK" : "NO")); struct distance_sensor_s report; @@ -689,7 +683,7 @@ SF0X::cycle() /* we know the sensor needs about four seconds to initialize */ if (hrt_absolute_time() > 5 * 1000 * 1000LL && _consecutive_fail_count < 5) { - DEVICE_LOG("collection error #%u", _consecutive_fail_count); + PX4_ERR("collection error #%u", _consecutive_fail_count); } _consecutive_fail_count++; @@ -724,7 +718,7 @@ SF0X::cycle() /* measurement phase */ if (OK != measure()) { - DEVICE_LOG("measure error"); + PX4_DEBUG("measure error"); } /* next phase is collection */