Skip to content

Commit f081f75

Browse files
committed
Adding stop as an argument for pushRawData - resolves #30
1 parent 39cc5bb commit f081f75

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

Diff for: src/SparkFun_u-blox_GNSS_Arduino_Library.cpp

+6-4
Original file line numberDiff line numberDiff line change
@@ -3394,7 +3394,9 @@ void SFE_UBLOX_GNSS::checkCallbacks(void)
33943394
// Push (e.g.) RTCM data directly to the module
33953395
// Returns true if all numDataBytes were pushed successfully
33963396
// 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.
3397-
boolean SFE_UBLOX_GNSS::pushRawData(uint8_t *dataBytes, size_t numDataBytes)
3397+
// Default to using a restart between transmissions. Set stop to true to use a stop instead.
3398+
// On processors like the ESP32, you can use setI2CTransactionSize to increase the size of each transmission - to e.g. 128 bytes
3399+
boolean SFE_UBLOX_GNSS::pushRawData(uint8_t *dataBytes, size_t numDataBytes, boolean stop)
33983400
{
33993401
if (commType == COMM_TYPE_SERIAL)
34003402
{
@@ -3425,12 +3427,12 @@ boolean SFE_UBLOX_GNSS::pushRawData(uint8_t *dataBytes, size_t numDataBytes)
34253427

34263428
if (bytesLeftToWrite > 0)
34273429
{
3428-
if (_i2cPort->endTransmission(false) != 0) //Send a restart command. Do not release bus.
3429-
return (false); //Sensor did not ACK
3430+
if (_i2cPort->endTransmission(stop) != 0) //Send a restart or stop command
3431+
return (false); //Sensor did not ACK
34303432
}
34313433
else
34323434
{
3433-
if (_i2cPort->endTransmission() != 0) //We're done. Release bus.
3435+
if (_i2cPort->endTransmission() != 0) //We're done. Release bus. Always use a stop here
34343436
return (false); //Sensor did not ACK
34353437
}
34363438
}

Diff for: src/SparkFun_u-blox_GNSS_Arduino_Library.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,8 @@ class SFE_UBLOX_GNSS
641641

642642
// Push (e.g.) RTCM data directly to the module
643643
// 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.
644-
boolean pushRawData(uint8_t *dataBytes, size_t numDataBytes);
644+
// Default to using a restart between transmissions. Set stop to true to use a stop instead.
645+
boolean pushRawData(uint8_t *dataBytes, size_t numDataBytes, boolean stop = false);
645646

646647
// Support for data logging
647648
void setFileBufferSize(uint16_t bufferSize); // Set the size of the file buffer. This must be called _before_ .begin.

0 commit comments

Comments
 (0)