diff --git a/keywords.txt b/keywords.txt index 21b59a5..39f6149 100644 --- a/keywords.txt +++ b/keywords.txt @@ -84,6 +84,8 @@ setFileBufferSize KEYWORD2 extractFileBufferData KEYWORD2 fileBufferAvailable KEYWORD2 getMaxFileBufferAvail KEYWORD2 +clearFileBuffer KEYWORD2 +clearMaxFileBufferAvail KEYWORD2 getPortSettings KEYWORD2 setPortOutput KEYWORD2 diff --git a/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp b/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp index 491116f..e4a6be2 100644 --- a/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp +++ b/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp @@ -3055,6 +3055,20 @@ uint16_t SFE_UBLOX_GNSS::getMaxFileBufferAvail(void) return (fileBufferMaxAvail); } +// Clear the file buffer - discard all contents +void SFE_UBLOX_GNSS::clearFileBuffer(void) +{ + if (fileBufferSize == 0) // Bail if the user has not called setFileBufferSize (probably redundant) + return; + fileBufferTail = fileBufferHead; +} + +// Reset fileBufferMaxAvail +void SFE_UBLOX_GNSS::clearMaxFileBufferAvail(void) +{ + fileBufferMaxAvail = 0; +} + // PRIVATE: Create the file buffer. Called by .begin boolean SFE_UBLOX_GNSS::createFileBuffer(void) { diff --git a/src/SparkFun_u-blox_GNSS_Arduino_Library.h b/src/SparkFun_u-blox_GNSS_Arduino_Library.h index 7622ee5..86a977d 100644 --- a/src/SparkFun_u-blox_GNSS_Arduino_Library.h +++ b/src/SparkFun_u-blox_GNSS_Arduino_Library.h @@ -557,8 +557,10 @@ public: // Support for data logging void setFileBufferSize(uint16_t bufferSize); // Set the size of the file buffer. This must be called _before_ .begin. uint16_t extractFileBufferData(uint8_t *destination, uint16_t numBytes); // Extract numBytes of data from the file buffer. Copy it to destination. It is the user's responsibility to ensure destination is large enough. - uint16_t fileBufferAvailable(void); // Returns the number of bytes available in file buffer which are waiting to be read - uint16_t getMaxFileBufferAvail(void); // Returns the maximum number of bytes which the file buffer has contained. Handy for checking the buffer is large enough to handle all the incoming data. + uint16_t fileBufferAvailable(void); // Returns the number of bytes available in file buffer which are waiting to be read + uint16_t getMaxFileBufferAvail(void); // Returns the maximum number of bytes which the file buffer has contained. Handy for checking the buffer is large enough to handle all the incoming data. + void clearFileBuffer(void); // Empty the file buffer - discard all contents + void clearMaxFileBufferAvail(void); // Reset fileBufferMaxAvail // Specific commands