diff options
author | Andrew Tridgell <tridge@samba.org> | 2014-10-14 10:07:40 +1100 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2014-10-20 07:11:24 +1100 |
commit | 99bfbb6dc3c2d8f60b356945026e586397d66170 (patch) | |
tree | 0bbf4309ef3c8e18983fe3ef02e89c5e876adf94 /src/drivers/ll40ls/ll40ls.cpp | |
parent | 111a8745b3d9d4ab99e4e0d34a9b9ddd3cd1ecdb (diff) | |
download | px4-firmware-99bfbb6dc3c2d8f60b356945026e586397d66170.tar.gz px4-firmware-99bfbb6dc3c2d8f60b356945026e586397d66170.tar.bz2 px4-firmware-99bfbb6dc3c2d8f60b356945026e586397d66170.zip |
ll40ls: add last distance in "ll40ls info" output
Diffstat (limited to 'src/drivers/ll40ls/ll40ls.cpp')
-rw-r--r-- | src/drivers/ll40ls/ll40ls.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/drivers/ll40ls/ll40ls.cpp b/src/drivers/ll40ls/ll40ls.cpp index a69e6ee55..7fd023ec4 100644 --- a/src/drivers/ll40ls/ll40ls.cpp +++ b/src/drivers/ll40ls/ll40ls.cpp @@ -132,6 +132,7 @@ private: perf_counter_t _sample_perf; perf_counter_t _comms_errors; perf_counter_t _buffer_overflows; + uint16_t _last_distance; /** * Test whether the device supported by the driver is present at a @@ -200,7 +201,8 @@ LL40LS::LL40LS(int bus, int address) : _range_finder_topic(-1), _sample_perf(perf_alloc(PC_ELAPSED, "ll40ls_read")), _comms_errors(perf_alloc(PC_COUNT, "ll40ls_comms_errors")), - _buffer_overflows(perf_alloc(PC_COUNT, "ll40ls_buffer_overflows")) + _buffer_overflows(perf_alloc(PC_COUNT, "ll40ls_buffer_overflows")), + _last_distance(0) { // up the retries since the device misses the first measure attempts I2C::_retries = 3; @@ -521,6 +523,8 @@ LL40LS::collect() float si_units = distance * 0.01f; /* cm to m */ struct range_finder_report report; + _last_distance = distance; + /* this should be fairly close to the end of the measurement, so the best approximation of the time */ report.timestamp = hrt_absolute_time(); report.error_count = perf_event_count(_comms_errors); @@ -648,6 +652,8 @@ LL40LS::print_info() perf_print_counter(_buffer_overflows); printf("poll interval: %u ticks\n", _measure_ticks); _reports->print_info("report queue"); + printf("distance: %ucm (0x%04x)\n", + (unsigned)_last_distance, (unsigned)_last_distance); } /** |