From fa7ba7ddbcee6da06cd6d12cfc4d44a4b68a5179 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Wed, 15 Aug 2018 11:36:09 +1000 Subject: [PATCH] DataFlash: force messagewriters to completion Setting a dataflash-file buffer size of less than or equal to 2kiB would cause the startup-messagewriter to never push any messages other than FMT out to the logs. This is a combination of the return values of critical_message_reserved_space and non_messagewriter_message_reserved_space This patch forces the startup messages out to the logs by ignoring the space constraints every 100ms --- libraries/DataFlash/DataFlash_File.cpp | 6 +++++- libraries/DataFlash/DataFlash_File.h | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/libraries/DataFlash/DataFlash_File.cpp b/libraries/DataFlash/DataFlash_File.cpp index 1c00a085b42..abb895f2808 100644 --- a/libraries/DataFlash/DataFlash_File.cpp +++ b/libraries/DataFlash/DataFlash_File.cpp @@ -554,11 +554,15 @@ bool DataFlash_File::_WritePrioritisedBlock(const void *pBuffer, uint16_t size, // writing format messages out. It can always get back to us // with more messages later, so let's leave room for other // things: - if (space < non_messagewriter_message_reserved_space()) { + const uint32_t now = AP_HAL::millis(); + const bool must_dribble = (now - last_messagewrite_message_sent) > 100; + if (!must_dribble && + space < non_messagewriter_message_reserved_space()) { // this message isn't dropped, it will be sent again... semaphore->give(); return false; } + last_messagewrite_message_sent = now; } else { // we reserve some amount of space for critical messages: if (!is_critical && space < critical_message_reserved_space()) { diff --git a/libraries/DataFlash/DataFlash_File.h b/libraries/DataFlash/DataFlash_File.h index 93b1f86924c..7a0e2a6ec01 100644 --- a/libraries/DataFlash/DataFlash_File.h +++ b/libraries/DataFlash/DataFlash_File.h @@ -136,6 +136,7 @@ private: } return ret; }; + uint32_t last_messagewrite_message_sent; // free-space checks; filling up SD cards under NuttX leads to // corrupt filesystems which cause loss of data, failure to gather