Skip to content

Commit 2ec3077

Browse files
committed
Adding clearFileBuffer and clearMaxFileBufferAvail
1 parent fb76790 commit 2ec3077

3 files changed

+20
-2
lines changed

keywords.txt

+2
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ setFileBufferSize KEYWORD2
8484
extractFileBufferData KEYWORD2
8585
fileBufferAvailable KEYWORD2
8686
getMaxFileBufferAvail KEYWORD2
87+
clearFileBuffer KEYWORD2
88+
clearMaxFileBufferAvail KEYWORD2
8789

8890
getPortSettings KEYWORD2
8991
setPortOutput KEYWORD2

src/SparkFun_u-blox_GNSS_Arduino_Library.cpp

+14
Original file line numberDiff line numberDiff line change
@@ -3055,6 +3055,20 @@ uint16_t SFE_UBLOX_GNSS::getMaxFileBufferAvail(void)
30553055
return (fileBufferMaxAvail);
30563056
}
30573057

3058+
// Clear the file buffer - discard all contents
3059+
void SFE_UBLOX_GNSS::clearFileBuffer(void)
3060+
{
3061+
if (fileBufferSize == 0) // Bail if the user has not called setFileBufferSize (probably redundant)
3062+
return;
3063+
fileBufferTail = fileBufferHead;
3064+
}
3065+
3066+
// Reset fileBufferMaxAvail
3067+
void SFE_UBLOX_GNSS::clearMaxFileBufferAvail(void)
3068+
{
3069+
fileBufferMaxAvail = 0;
3070+
}
3071+
30583072
// PRIVATE: Create the file buffer. Called by .begin
30593073
boolean SFE_UBLOX_GNSS::createFileBuffer(void)
30603074
{

src/SparkFun_u-blox_GNSS_Arduino_Library.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -557,8 +557,10 @@ class SFE_UBLOX_GNSS
557557
// Support for data logging
558558
void setFileBufferSize(uint16_t bufferSize); // Set the size of the file buffer. This must be called _before_ .begin.
559559
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.
560-
uint16_t fileBufferAvailable(void); // Returns the number of bytes available in file buffer which are waiting to be read
561-
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.
560+
uint16_t fileBufferAvailable(void); // Returns the number of bytes available in file buffer which are waiting to be read
561+
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.
562+
void clearFileBuffer(void); // Empty the file buffer - discard all contents
563+
void clearMaxFileBufferAvail(void); // Reset fileBufferMaxAvail
562564

563565
// Specific commands
564566

0 commit comments

Comments
 (0)