Refactored debug() and log() in CDev

These functions used vprintf which is not available on all platforms.
They also do not enable line and file debug output.

Changed to macros that preserve the output format.  Uses new macro that
can be used to implement per object, runtime selectable logging

Signed-off-by: Mark Charlebois <charlebm@gmail.com>
This commit is contained in:
Mark Charlebois
2015-08-11 12:07:06 -07:00
parent be58c6abd3
commit a589d15c52
47 changed files with 202 additions and 261 deletions
+6 -6
View File
@@ -133,7 +133,7 @@ int LidarLiteI2C::init()
&_orb_class_instance, ORB_PRIO_LOW);
if (_distance_sensor_topic == nullptr) {
debug("failed to create distance_sensor object. Did you start uOrb?");
DEVICE_DEBUG("failed to create distance_sensor object. Did you start uOrb?");
}
}
@@ -177,7 +177,7 @@ int LidarLiteI2C::probe()
goto ok;
}
debug("probe failed reg11=0x%02x reg2=0x%02x\n",
DEVICE_DEBUG("probe failed reg11=0x%02x reg2=0x%02x\n",
(unsigned)who_am_i,
(unsigned)max_acq_count);
}
@@ -307,7 +307,7 @@ int LidarLiteI2C::measure()
if (OK != ret) {
perf_count(_comms_errors);
debug("i2c::transfer returned %d", ret);
DEVICE_DEBUG("i2c::transfer returned %d", ret);
// if we are getting lots of I2C transfer errors try
// resetting the sensor
@@ -387,7 +387,7 @@ int LidarLiteI2C::collect()
read before it is ready, so only consider it
an error if more than 100ms has elapsed.
*/
debug("error reading from sensor: %d", ret);
DEVICE_DEBUG("error reading from sensor: %d", ret);
perf_count(_comms_errors);
if (perf_event_count(_comms_errors) % 10 == 0) {
@@ -488,7 +488,7 @@ void LidarLiteI2C::cycle()
/* try a collection */
if (OK != collect()) {
debug("collection error");
DEVICE_DEBUG("collection error");
/* if we've been waiting more than 200ms then
send a new acquire */
@@ -520,7 +520,7 @@ void LidarLiteI2C::cycle()
if (_collect_phase == false) {
/* measurement phase */
if (OK != measure()) {
debug("measure error");
DEVICE_DEBUG("measure error");
} else {
/* next phase is collection. Don't switch to
+2 -2
View File
@@ -117,7 +117,7 @@ int LidarLitePWM::init()
&_orb_class_instance, ORB_PRIO_LOW);
if (_distance_sensor_topic == nullptr) {
debug("failed to create distance_sensor object. Did you start uOrb?");
DEVICE_DEBUG("failed to create distance_sensor object. Did you start uOrb?");
}
}
@@ -175,7 +175,7 @@ int LidarLitePWM::measure()
perf_begin(_sample_perf);
if (OK != collect()) {
debug("collection error");
DEVICE_DEBUG("collection error");
perf_count(_read_errors);
perf_end(_sample_perf);
return ERROR;