Skip to content

Commit c4bbe44

Browse files
committed
Call checkUbloxSerial during serial pushRawData
1 parent 7cdb203 commit c4bbe44

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

src/u-blox_GNSS.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6072,7 +6072,7 @@ void DevUBLOXGNSS::checkCallbacks(void)
60726072
// Push (e.g.) RTCM data directly to the module
60736073
// Returns true if all numDataBytes were pushed successfully
60746074
// Warning: this function does not check that the data is valid. It is the user's responsibility to ensure the data is valid before pushing.
6075-
bool DevUBLOXGNSS::pushRawData(uint8_t *dataBytes, size_t numDataBytes, bool callProcessSpiBuffer)
6075+
bool DevUBLOXGNSS::pushRawData(uint8_t *dataBytes, size_t numDataBytes, bool callProcessBuffer)
60766076
{
60776077
// Return now if numDataBytes is zero
60786078
if (numDataBytes == 0)
@@ -6089,22 +6089,26 @@ bool DevUBLOXGNSS::pushRawData(uint8_t *dataBytes, size_t numDataBytes, bool cal
60896089
bool ok = false;
60906090
if (_commType == COMM_TYPE_SERIAL)
60916091
{
6092-
// Serial: writeBytes can only write 255 bytes maximum, so we need to divide up into chunks if required
6092+
// Serial: divide pushes up into 16 byte chunks and call checkUbloxSerial between pushes
6093+
// (if callProcessBuffer is true) to try and avoid data loss
60936094
ok = true;
60946095
size_t bytesLeftToWrite = numDataBytes;
60956096
while (bytesLeftToWrite > 0)
60966097
{
60976098
uint8_t bytesToWrite;
60986099

6099-
if (bytesLeftToWrite < 0x100)
6100+
if (bytesLeftToWrite < 16)
61006101
bytesToWrite = (uint8_t)bytesLeftToWrite;
61016102
else
6102-
bytesToWrite = 0xFF;
6103+
bytesToWrite = 16;
61036104

61046105
ok &= (writeBytes(dataBytes, bytesToWrite) == bytesToWrite); // Will set ok to false if any one write fails
61056106

61066107
bytesLeftToWrite -= (size_t)bytesToWrite;
61076108
dataBytes += bytesToWrite;
6109+
6110+
if (callProcessBuffer) // Try and prevent data loss during large pushes by calling checkUbloxSerial between chunks
6111+
checkUbloxSerial(&packetCfg, 0, 0); // Don't call checkUbloxInternal as we already have the lock!
61086112
}
61096113
}
61106114
else if (_commType == COMM_TYPE_I2C)
@@ -6204,7 +6208,7 @@ bool DevUBLOXGNSS::pushRawData(uint8_t *dataBytes, size_t numDataBytes, bool cal
62046208

62056209
bytesLeftToWrite -= bytesToWrite; // Update the totals
62066210

6207-
if (callProcessSpiBuffer)
6211+
if (callProcessBuffer)
62086212
processSpiBuffer(&packetCfg, 0, 0); // This will hopefully prevent any lost data?
62096213
}
62106214

@@ -6324,7 +6328,7 @@ size_t DevUBLOXGNSS::pushAssistNowDataInternal(size_t offset, bool skipTime, con
63246328
}
63256329
else
63266330
{
6327-
bool pushResult = pushRawData((uint8_t *)(dataBytes + dataPtr), packetLength + ((size_t)8), checkForAcks ? false : true); // Push the data. Don't call processSpiBuffer when using ACKs
6331+
bool pushResult = pushRawData((uint8_t *)(dataBytes + dataPtr), packetLength + ((size_t)8), checkForAcks ? false : true); // Push the data. Don't call processSpiBuffer / checkUbloxSerial when using ACKs
63286332

63296333
if (pushResult)
63306334
bytesPushed += packetLength + ((size_t)8); // Increment bytesPushed if the push was successful

src/u-blox_GNSS.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,10 +262,14 @@ class DevUBLOXGNSS
262262
// Push (e.g.) RTCM or Assist Now data directly to the module
263263
// Warning: this function does not check that the data is valid. It is the user's responsibility to ensure the data is valid before pushing.
264264
//
265-
// For SPI: callProcessSpiBuffer defaults to true and forces pushRawData to call processSpiBuffer in between push transactions.
265+
// For SPI: callProcessBuffer defaults to true and forces pushRawData to call processSpiBuffer in between push transactions.
266266
// This is to try and prevent incoming data being 'lost' during large (bi-directional) pushes.
267-
// If you are only pushing limited amounts of data and/or will be calling checkUblox manually, it might be advantageous to set callProcessSpiBuffer to false.
268-
bool pushRawData(uint8_t *dataBytes, size_t numDataBytes, bool callProcessSpiBuffer = true);
267+
// If you are only pushing limited amounts of data and/or will be calling checkUblox manually, it might be advantageous to set callProcessBuffer to false.
268+
//
269+
// Likewise for Serial: callProcessBuffer defaults to true and forces pushRawData to call checkUbloxSerial in between pushing data.
270+
// This is to try and prevent incoming data being 'lost' (overflowing the serial RX buffer) during a large push.
271+
// If you are only pushing limited amounts of data and/or will be calling checkUblox manually, it might be advantageous to set callProcessBuffer to false.
272+
bool pushRawData(uint8_t *dataBytes, size_t numDataBytes, bool callProcessBuffer = true);
269273
#ifndef SFE_UBLOX_DISABLE_RTCM_LOGGING
270274
// RTCM parsing - used inside pushRawData
271275
protected:

0 commit comments

Comments
 (0)