Skip to content
This repository was archived by the owner on Jan 28, 2021. It is now read-only.

Commit 45e987c

Browse files
committed
Attempt to 'fix' issue #26. No good breakthroughs yet.
Ex 14 DebugOutput is still freezing at odd times. The increase of time between I2C checks to 100ms helps a little but doesn't fix the random freeze-for-a-few-seconds problem.
1 parent 75ccfdf commit 45e987c

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

Diff for: src/SparkFun_Ublox_Arduino_Library.cpp

+8-1
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ boolean SFE_UBLOX_GPS::checkUblox()
208208
}
209209

210210
//Polls I2C for data, passing any new bytes to process()
211+
//Returns true if new bytes are available
211212
boolean SFE_UBLOX_GPS::checkUbloxI2C()
212213
{
213214
if (millis() - lastCheck >= I2C_POLLING_WAIT_MS)
@@ -224,14 +225,20 @@ boolean SFE_UBLOX_GPS::checkUbloxI2C()
224225
{
225226
uint8_t msb = _i2cPort->read();
226227
uint8_t lsb = _i2cPort->read();
228+
if (lsb == 0xFF)
229+
{
230+
debugPrintln("No bytes available");
231+
lastCheck = millis(); //Put off checking to avoid I2C bus traffic
232+
return (false);
233+
}
227234
bytesAvailable = (uint16_t)msb << 8 | lsb;
228235
}
229236

230237
if (bytesAvailable == 0)
231238
{
232239
debugPrintln("Zero bytes available");
233240
lastCheck = millis(); //Put off checking to avoid I2C bus traffic
234-
return (true);
241+
return (false);
235242
}
236243

237244
while (bytesAvailable)

Diff for: src/SparkFun_Ublox_Arduino_Library.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ class SFE_UBLOX_GPS
422422
ubxPacket packetAck = {0, 0, 0, 0, 0, payloadAck, 0, 0, false};
423423
ubxPacket packetCfg = {0, 0, 0, 0, 0, payloadCfg, 0, 0, false};
424424

425-
const uint8_t I2C_POLLING_WAIT_MS = 25; //Limit checking of new characters to every X ms
425+
const uint8_t I2C_POLLING_WAIT_MS = 100; //Limit checking of new characters to every X ms
426426
unsigned long lastCheck = 0;
427427
boolean autoPVT = false; //Whether autoPVT is enabled or not
428428
boolean commandAck = false; //This goes true after we send a command and it's ack'd

0 commit comments

Comments
 (0)