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

Commit 3ae42b5

Browse files
author
Nathan Seidle
committed
Adding response for cfg packet only in waitForResponse.
Many more debug statements added. This may break Uno/Flash compatibility.
1 parent 5b51956 commit 3ae42b5

File tree

1 file changed

+34
-2
lines changed

1 file changed

+34
-2
lines changed

src/SparkFun_Ublox_Arduino_Library.cpp

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,10 @@ boolean SFE_UBLOX_GPS::sendCommand(ubxPacket outgoingUBX, uint16_t maxWait)
711711
if (commType == COMM_TYPE_I2C)
712712
{
713713
if (!sendI2cCommand(outgoingUBX, maxWait))
714+
{
715+
debugPrintln((char *)"Send I2C Command failed");
714716
return false;
717+
}
715718
}
716719
else if (commType == COMM_TYPE_SERIAL)
717720
{
@@ -720,12 +723,15 @@ boolean SFE_UBLOX_GPS::sendCommand(ubxPacket outgoingUBX, uint16_t maxWait)
720723

721724
if (maxWait > 0)
722725
{
726+
debugPrintln((char *)"Waiting for response from sendCommand");
727+
723728
//Give waitForResponse the cls/id to check for
724729
return waitForResponse(outgoingUBX.cls, outgoingUBX.id, maxWait); //Wait for Ack response
725730
}
726731
return true;
727732
}
728733

734+
//Returns false if sensor fails to respond to I2C traffic
729735
boolean SFE_UBLOX_GPS::sendI2cCommand(ubxPacket outgoingUBX, uint16_t maxWait)
730736
{
731737
//Point at 0xFF data register
@@ -958,12 +964,31 @@ boolean SFE_UBLOX_GPS::waitForResponse(uint8_t requestedClass, uint8_t requested
958964
return (true);
959965
}
960966
}
967+
else if (packetCfg.valid == true)
968+
{
969+
//Packets that are not CFG packets such as getPVT()
970+
Serial.println("Non CFG packet");
971+
//Did we receive a config packet that matches the cls/id we requested?
972+
if (packetCfg.cls == requestedClass && packetCfg.id == requestedID)
973+
{
974+
debugPrintln((char *)"CLS/ID match!");
975+
return (true); //We have new data to act upon
976+
}
977+
else
978+
{
979+
if (_printDebug == true)
980+
{
981+
_debugSerial->print(F("Packet didn't match CLS/ID"));
982+
printPacket(&packetCfg);
983+
}
984+
}
985+
}
961986
}
962987

963988
delayMicroseconds(500);
964989
}
965990

966-
debugPrintln((char *)"waitForResponse timeout");
991+
debugPrintln((char *)"waitForResponse timeout: No valid ack packet received");
967992

968993
return (false);
969994
}
@@ -2063,17 +2088,20 @@ boolean SFE_UBLOX_GPS::getPVT(uint16_t maxWait)
20632088
{
20642089
if (autoPVT && autoPVTImplicitUpdate)
20652090
{
2091+
Serial.println("Check ulbox");
20662092
//The GPS is automatically reporting, we just check whether we got unread data
20672093
checkUblox();
20682094
return moduleQueried.all;
20692095
}
20702096
else if (autoPVT && !autoPVTImplicitUpdate)
20712097
{
20722098
//Someone else has to call checkUblox for us...
2099+
Serial.println("Immediateexi");
20732100
return (false);
20742101
}
20752102
else
20762103
{
2104+
Serial.println("Poll PVT");
20772105
//The GPS is not automatically reporting navigation position so we have to poll explicitly
20782106
packetCfg.cls = UBX_CLASS_NAV;
20792107
packetCfg.id = UBX_NAV_PVT;
@@ -2082,7 +2110,6 @@ boolean SFE_UBLOX_GPS::getPVT(uint16_t maxWait)
20822110

20832111
//The data is parsed as part of processing the response
20842112
return sendCommand(packetCfg, maxWait);
2085-
return (false); //If command send fails then bail
20862113
}
20872114
}
20882115

@@ -2245,8 +2272,13 @@ uint8_t SFE_UBLOX_GPS::getSIV(uint16_t maxWait)
22452272
//0=no fix, 1=dead reckoning, 2=2D, 3=3D, 4=GNSS, 5=Time fix
22462273
uint8_t SFE_UBLOX_GPS::getFixType(uint16_t maxWait)
22472274
{
2275+
Serial.println("Get fix type");
22482276
if (moduleQueried.fixType == false)
2277+
{
2278+
Serial.println("GetPVT");
2279+
22492280
getPVT(maxWait);
2281+
}
22502282
moduleQueried.fixType = false; //Since we are about to give this to user, mark this data as stale
22512283
moduleQueried.all = false;
22522284

0 commit comments

Comments
 (0)