From e11c276b35e88ba4a10c2d25073f4d9d2f0e9964 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Sun, 6 Nov 2016 16:26:31 +1100 Subject: [PATCH] DataFlash_File: stop trying to stuff a uint64_t into a uint32_t --- libraries/DataFlash/DataFlash_File.cpp | 10 +++++----- libraries/DataFlash/DataFlash_File.h | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/libraries/DataFlash/DataFlash_File.cpp b/libraries/DataFlash/DataFlash_File.cpp index 90b4da2987..fdb1294080 100644 --- a/libraries/DataFlash/DataFlash_File.cpp +++ b/libraries/DataFlash/DataFlash_File.cpp @@ -998,13 +998,13 @@ void DataFlash_File::ListAvailableLogs(AP_HAL::BetterStream *port) #if CONFIG_HAL_BOARD == HAL_BOARD_SITL || CONFIG_HAL_BOARD == HAL_BOARD_LINUX void DataFlash_File::flush(void) { - uint32_t tnow = AP_HAL::micros(); + uint32_t tnow = AP_HAL::millis(); hal.scheduler->suspend_timer_procs(); while (_write_fd != -1 && _initialised && !_open_error && _writebuf.available()) { // convince the IO timer that it really is OK to write out // less than _writebuf_chunk bytes: - if (tnow > 2000001) { // avoid resetting _last_write_time to 0 - _last_write_time = tnow - 2000001; + if (tnow > 2001) { // avoid resetting _last_write_time to 0 + _last_write_time = tnow - 2001; } _io_timer(); } @@ -1025,9 +1025,9 @@ void DataFlash_File::_io_timer(void) if (nbytes == 0) { return; } - uint32_t tnow = AP_HAL::micros(); + uint32_t tnow = AP_HAL::millis(); if (nbytes < _writebuf_chunk && - tnow - _last_write_time < 2000000UL) { + tnow - _last_write_time < 2000UL) { // write in _writebuf_chunk-sized chunks, but always write at // least once per 2 seconds if data is available return; diff --git a/libraries/DataFlash/DataFlash_File.h b/libraries/DataFlash/DataFlash_File.h index db341b8271..58cd1b041d 100644 --- a/libraries/DataFlash/DataFlash_File.h +++ b/libraries/DataFlash/DataFlash_File.h @@ -146,8 +146,8 @@ private: // free-space checks; filling up SD cards under NuttX leads to // corrupt filesystems which cause loss of data, failure to gather // data and failures-to-boot. - uint64_t _free_space_last_check_time; // microseconds - const uint32_t _free_space_check_interval = 1000000UL; // microseconds + uint32_t _free_space_last_check_time; // milliseconds + const uint32_t _free_space_check_interval = 1000UL; // milliseconds const uint32_t _free_space_min_avail = 8388608; // bytes AP_HAL::Semaphore *semaphore;