diff options
author | Lorenz Meier <lm@inf.ethz.ch> | 2014-04-05 14:28:44 +0200 |
---|---|---|
committer | Lorenz Meier <lm@inf.ethz.ch> | 2014-04-05 14:30:27 +0200 |
commit | be38372be17925e14fa864ad26e8f487a402d46f (patch) | |
tree | 42f7905d288a50974cbcb113156d76bf30dd00ab /src/drivers/sf0x | |
parent | fa63609da33cbbf7b3c57d5044af3f8972c73647 (diff) | |
download | px4-firmware-be38372be17925e14fa864ad26e8f487a402d46f.tar.gz px4-firmware-be38372be17925e14fa864ad26e8f487a402d46f.tar.bz2 px4-firmware-be38372be17925e14fa864ad26e8f487a402d46f.zip |
sf0x driver: Stop emitting error messages once there is no hope this sensor will recover - continue to output error messages if the errors are just intermittent
Diffstat (limited to 'src/drivers/sf0x')
-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 */ |