srf02 cleanup unnecessary Device CDev usage

This commit is contained in:
Daniel Agar
2018-08-27 13:14:15 -04:00
parent ebcd3b0b2e
commit cfe34ee19c
+9 -14
View File
@@ -115,7 +115,7 @@ private:
uint8_t _rotation; uint8_t _rotation;
float _min_distance; float _min_distance;
float _max_distance; float _max_distance;
work_s _work; work_s _work{};
ringbuffer::RingBuffer *_reports; ringbuffer::RingBuffer *_reports;
bool _sensor_ok; bool _sensor_ok;
int _measure_ticks; int _measure_ticks;
@@ -210,11 +210,6 @@ SRF02::SRF02(uint8_t rotation, int bus, int address) :
_index_counter(0) /* initialising temp sonar i2c address to zero */ _index_counter(0) /* initialising temp sonar i2c address to zero */
{ {
/* enable debug() calls */
_debug_enabled = false;
/* work_cancel in the dtor will explode if we don't do this... */
memset(&_work, 0, sizeof(_work));
} }
SRF02::~SRF02() SRF02::~SRF02()
@@ -265,7 +260,7 @@ SRF02::init()
&_orb_class_instance, ORB_PRIO_LOW); &_orb_class_instance, ORB_PRIO_LOW);
if (_distance_sensor_topic == nullptr) { 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");
} }
// XXX we should find out why we need to wait 200 ms here // XXX we should find out why we need to wait 200 ms here
@@ -281,7 +276,7 @@ SRF02::init()
if (ret2 == 0) { /* sonar is present -> store address_index in array */ if (ret2 == 0) { /* sonar is present -> store address_index in array */
addr_ind.push_back(_index_counter); addr_ind.push_back(_index_counter);
DEVICE_DEBUG("sonar added"); PX4_DEBUG("sonar added");
_latest_sonar_measurements.push_back(200); _latest_sonar_measurements.push_back(200);
} }
} }
@@ -299,10 +294,10 @@ SRF02::init()
/* show the connected sonars in terminal */ /* show the connected sonars in terminal */
for (unsigned i = 0; i < addr_ind.size(); i++) { for (unsigned i = 0; i < addr_ind.size(); i++) {
DEVICE_LOG("sonar %d with address %d added", (i + 1), addr_ind[i]); PX4_DEBUG("sonar %d with address %d added", (i + 1), addr_ind[i]);
} }
DEVICE_DEBUG("Number of sonars connected: %zu", addr_ind.size()); PX4_DEBUG("Number of sonars connected: %zu", addr_ind.size());
ret = OK; ret = OK;
/* sensor is ok, but we don't really know if it is within range */ /* sensor is ok, but we don't really know if it is within range */
@@ -519,7 +514,7 @@ SRF02::measure()
if (OK != ret) { if (OK != ret) {
perf_count(_comms_errors); perf_count(_comms_errors);
DEVICE_DEBUG("i2c::transfer returned %d", ret); PX4_DEBUG("i2c::transfer returned %d", ret);
return ret; return ret;
} }
@@ -542,7 +537,7 @@ SRF02::collect()
ret = transfer(nullptr, 0, &val[0], 2); ret = transfer(nullptr, 0, &val[0], 2);
if (ret < 0) { if (ret < 0) {
DEVICE_DEBUG("error reading from sensor: %d", ret); PX4_DEBUG("error reading from sensor: %d", ret);
perf_count(_comms_errors); perf_count(_comms_errors);
perf_end(_sample_perf); perf_end(_sample_perf);
return ret; return ret;
@@ -616,7 +611,7 @@ SRF02::cycle()
/* perform collection */ /* perform collection */
if (OK != collect()) { if (OK != collect()) {
DEVICE_DEBUG("collection error"); PX4_DEBUG("collection error");
/* if error restart the measurement state machine */ /* if error restart the measurement state machine */
start(); start();
return; return;
@@ -655,7 +650,7 @@ SRF02::cycle()
/* Perform measurement */ /* Perform measurement */
if (OK != measure()) { if (OK != measure()) {
DEVICE_DEBUG("measure error sonar adress %d", _index_counter); PX4_DEBUG("measure error sonar adress %d", _index_counter);
} }
/* next phase is collection */ /* next phase is collection */