diff options
author | Lorenz Meier <lm@inf.ethz.ch> | 2014-04-05 05:41:46 -0700 |
---|---|---|
committer | Lorenz Meier <lm@inf.ethz.ch> | 2014-04-05 05:41:46 -0700 |
commit | 40bf02bda0e093e9d695f1172cf4bba534d248ad (patch) | |
tree | 42f7905d288a50974cbcb113156d76bf30dd00ab | |
parent | fa63609da33cbbf7b3c57d5044af3f8972c73647 (diff) | |
parent | be38372be17925e14fa864ad26e8f487a402d46f (diff) | |
download | px4-firmware-40bf02bda0e093e9d695f1172cf4bba534d248ad.tar.gz px4-firmware-40bf02bda0e093e9d695f1172cf4bba534d248ad.tar.bz2 px4-firmware-40bf02bda0e093e9d695f1172cf4bba534d248ad.zip |
Merge pull request #804 from PX4/laser_error_management
sf0x driver: Stop emitting error messages once there is no hope this sen...
-rw-r--r-- | src/drivers/sf0x/sf0x.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/drivers/sf0x/sf0x.cpp b/src/drivers/sf0x/sf0x.cpp index 07163035b..a0cf98340 100644 --- a/src/drivers/sf0x/sf0x.cpp +++ b/src/drivers/sf0x/sf0x.cpp @@ -124,6 +124,8 @@ private: orb_advert_t _range_finder_topic; + unsigned _consecutive_fail_count; + perf_counter_t _sample_perf; perf_counter_t _comms_errors; perf_counter_t _buffer_overflows; @@ -186,6 +188,7 @@ SF0X::SF0X(const char *port) : _linebuf_index(0), _last_read(0), _range_finder_topic(-1), + _consecutive_fail_count(0), _sample_perf(perf_alloc(PC_ELAPSED, "sf0x_read")), _comms_errors(perf_alloc(PC_COUNT, "sf0x_comms_errors")), _buffer_overflows(perf_alloc(PC_COUNT, "sf0x_buffer_overflows")) @@ -720,12 +723,17 @@ SF0X::cycle() if (OK != collect_ret) { /* we know the sensor needs about four seconds to initialize */ - if (hrt_absolute_time() > 5 * 1000 * 1000LL) { - log("collection error"); + if (hrt_absolute_time() > 5 * 1000 * 1000LL && _consecutive_fail_count < 5) { + log("collection error #%u", _consecutive_fail_count); } + _consecutive_fail_count++; + /* restart the measurement state machine */ start(); return; + } else { + /* apparently success */ + _consecutive_fail_count = 0; } /* next phase is measurement */ |