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

Commit 5f916bc

Browse files
committed
Work in progress: corrections for sendCommand return values
1 parent e061d73 commit 5f916bc

File tree

1 file changed

+26
-7
lines changed

1 file changed

+26
-7
lines changed

src/SparkFun_Ublox_Arduino_Library.cpp

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,12 @@ void SFE_UBLOX_GPS::setSerialRate(uint32_t baudrate, uint8_t uartPort, uint16_t
224224
_debugSerial->println(((uint32_t)payloadCfg[10] << 16) | ((uint32_t)payloadCfg[9] << 8) | payloadCfg[8]);
225225
}
226226

227-
sendCommand(packetCfg, maxWait);
227+
sfe_ublox_status_e retVal = sendCommand(packetCfg, maxWait);
228+
if (_printDebug == true)
229+
{
230+
_debugSerial->print(F("setSerialRate: sendCommand returned: "));
231+
_debugSerial->println(statusString(retVal));
232+
}
228233
}
229234

230235
//Changes the I2C address that the Ublox module responds to
@@ -242,7 +247,7 @@ boolean SFE_UBLOX_GPS::setI2CAddress(uint8_t deviceAddress, uint16_t maxWait)
242247
//payloadCfg is now loaded with current bytes. Change only the ones we need to
243248
payloadCfg[4] = deviceAddress << 1; //DDC mode LSB
244249

245-
if (sendCommand(packetCfg, maxWait) == true)
250+
if (sendCommand(packetCfg, maxWait) == SFE_UBLOX_STATUS_DATA_SENT)
246251
{
247252
//Success! Now change our internal global.
248253
_gpsI2Caddress = deviceAddress; //Store the I2C address from user
@@ -975,7 +980,14 @@ boolean SFE_UBLOX_GPS::isConnected()
975980
packetCfg.len = 0;
976981
packetCfg.startingSpot = 0;
977982

978-
return sendCommand(packetCfg);
983+
if (sendCommand(packetCfg) == SFE_UBLOX_STATUS_DATA_SENT)
984+
{
985+
return true;
986+
}
987+
else
988+
{
989+
return false;
990+
}
979991
}
980992
return false;
981993
}
@@ -1257,7 +1269,7 @@ boolean SFE_UBLOX_GPS::saveConfiguration(uint16_t maxWait)
12571269
packetCfg.payload[4] = 0xFF; //Set any bit in the saveMask field to save current config to Flash and BBR
12581270
packetCfg.payload[5] = 0xFF;
12591271

1260-
if (sendCommand(packetCfg, maxWait) == false)
1272+
if (sendCommand(packetCfg, maxWait) != SFE_UBLOX_STATUS_DATA_SENT)
12611273
return (false); //If command send fails then bail
12621274

12631275
return (true);
@@ -1281,7 +1293,7 @@ boolean SFE_UBLOX_GPS::saveConfigSelective(uint32_t configMask, uint16_t maxWait
12811293
packetCfg.payload[6] = (configMask >> 16) & 0xFF;
12821294
packetCfg.payload[7] = (configMask >> 24) & 0xFF;
12831295

1284-
if (sendCommand(packetCfg, maxWait) == false)
1296+
if (sendCommand(packetCfg, maxWait) != SFE_UBLOX_STATUS_DATA_SENT)
12851297
return (false); //If command send fails then bail
12861298

12871299
return (true);
@@ -1305,7 +1317,7 @@ boolean SFE_UBLOX_GPS::factoryDefault(uint16_t maxWait)
13051317
packetCfg.payload[8] = 0xFF; //Set any bit in the loadMask field to discard current config and rebuild from lower non-volatile memory layers
13061318
packetCfg.payload[9] = 0xFF;
13071319

1308-
if (sendCommand(packetCfg, maxWait) == false)
1320+
if (sendCommand(packetCfg, maxWait) != SFE_UBLOX_STATUS_DATA_SENT)
13091321
return (false); //If command send fails then bail
13101322

13111323
return (true);
@@ -1364,7 +1376,14 @@ uint8_t SFE_UBLOX_GPS::getVal8(uint32_t key, uint8_t layer, uint16_t maxWait)
13641376
}
13651377

13661378
//Send VALGET command with this key
1367-
if (sendCommand(packetCfg, maxWait) == false)
1379+
1380+
sfe_ublox_status_e retVal = sendCommand(packetCfg, maxWait);
1381+
if (_printDebug == true)
1382+
{
1383+
_debugSerial->print(F("getVal8: sendCommand returned: "));
1384+
_debugSerial->println(statusString(retVal));
1385+
}
1386+
if (retVal != SFE_UBLOX_STATUS_DATA_SENT)
13681387
return (false); //If command send fails then bail
13691388

13701389
//Verify the response is the correct length as compared to what the user called (did the module respond with 8-bits but the user called getVal32?)

0 commit comments

Comments
 (0)