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

Commit 4eb9b56

Browse files
committed
Query module regardless of interface type to prove isConnected()
Greatly increases confidence over I2C comm that we are talking to a ublox module.
1 parent 9f3799d commit 4eb9b56

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

Diff for: src/SparkFun_Ublox_Arduino_Library.cpp

+14-16
Original file line numberDiff line numberDiff line change
@@ -1147,19 +1147,17 @@ boolean SFE_UBLOX_GPS::isConnected(uint16_t maxWait)
11471147
if (commType == COMM_TYPE_I2C)
11481148
{
11491149
_i2cPort->beginTransmission((uint8_t)_gpsI2Caddress);
1150-
return _i2cPort->endTransmission() == 0;
1150+
if (_i2cPort->endTransmission() != 0)
1151+
return false; //Sensor did not ack
11511152
}
1152-
else if (commType == COMM_TYPE_SERIAL)
1153-
{
1154-
// Query navigation rate to see whether we get a meaningful response
1155-
packetCfg.cls = UBX_CLASS_CFG;
1156-
packetCfg.id = UBX_CFG_RATE;
1157-
packetCfg.len = 0;
1158-
packetCfg.startingSpot = 0;
11591153

1160-
return (sendCommand(&packetCfg, maxWait) == SFE_UBLOX_STATUS_DATA_RECEIVED); // We are polling the RATE so we expect data and an ACK
1161-
}
1162-
return false;
1154+
// Query navigation rate to see whether we get a meaningful response
1155+
packetCfg.cls = UBX_CLASS_CFG;
1156+
packetCfg.id = UBX_CFG_RATE;
1157+
packetCfg.len = 0;
1158+
packetCfg.startingSpot = 0;
1159+
1160+
return (sendCommand(&packetCfg, maxWait) == SFE_UBLOX_STATUS_DATA_RECEIVED); // We are polling the RATE so we expect data and an ACK
11631161
}
11641162

11651163
//Given a message, calc and store the two byte "8-Bit Fletcher" checksum over the entirety of the message
@@ -2012,17 +2010,17 @@ boolean SFE_UBLOX_GPS::setSurveyMode(uint8_t mode, uint16_t observationTime, flo
20122010
packetCfg.payload[x] = 0;
20132011

20142012
//payloadCfg should be loaded with poll response. Now modify only the bits we care about
2015-
payloadCfg[2] = mode; //Set mode. Survey-In and Disabled are most common. Use ECEF (not LAT/LON/ALT).
2013+
payloadCfg[2] = mode; //Set mode. Survey-In and Disabled are most common. Use ECEF (not LAT/LON/ALT).
20162014

20172015
//svinMinDur is U4 (uint32_t) but we'll only use a uint16_t (waiting more than 65535 seconds seems excessive!)
20182016
payloadCfg[24] = observationTime & 0xFF; //svinMinDur in seconds
20192017
payloadCfg[25] = observationTime >> 8; //svinMinDur in seconds
2020-
payloadCfg[26] = 0; //Truncate to 16 bits
2021-
payloadCfg[27] = 0; //Truncate to 16 bits
2018+
payloadCfg[26] = 0; //Truncate to 16 bits
2019+
payloadCfg[27] = 0; //Truncate to 16 bits
20222020

20232021
//svinAccLimit is U4 (uint32_t) in 0.1mm.
20242022
uint32_t svinAccLimit = (uint32_t)(requiredAccuracy * 10000.0); //Convert m to 0.1mm
2025-
payloadCfg[28] = svinAccLimit & 0xFF; //svinAccLimit in 0.1mm increments
2023+
payloadCfg[28] = svinAccLimit & 0xFF; //svinAccLimit in 0.1mm increments
20262024
payloadCfg[29] = svinAccLimit >> 8;
20272025
payloadCfg[30] = svinAccLimit >> 16;
20282026
payloadCfg[31] = svinAccLimit >> 24;
@@ -2079,7 +2077,7 @@ boolean SFE_UBLOX_GPS::getSurveyStatus(uint16_t maxWait)
20792077
uint32_t tempFloat = extractLong(28);
20802078
svin.meanAccuracy = ((float)tempFloat) / 10000.0; //Convert 0.1mm to m
20812079

2082-
svin.valid = payloadCfg[36]; //1 if survey-in position is valid, 0 otherwise
2080+
svin.valid = payloadCfg[36]; //1 if survey-in position is valid, 0 otherwise
20832081
svin.active = payloadCfg[37]; //1 if survey-in in progress, 0 otherwise
20842082

20852083
return (true);

0 commit comments

Comments
 (0)