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

Commit e724638

Browse files
committed
Updated the example
1 parent e0c3230 commit e724638

File tree

2 files changed

+8
-22
lines changed

2 files changed

+8
-22
lines changed

examples/Example20_SendCustomCommand/Example20_SendCustomCommand.ino

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,10 @@ void setup()
8585
// SFE_UBLOX_STATUS_DATA_RECEIVED if the data we requested was read / polled successfully
8686
// SFE_UBLOX_STATUS_DATA_SENT if the data we sent was writted successfully (ACK'd)
8787
// Other values indicate errors. Please see the sfe_ublox_status_e enum for further details.
88-
// If you see a failure you can of course simply try sending the same command again.
8988

9089
// Referring to the u-blox M8 Receiver Description and Protocol Specification we see that
9190
// the dynamic model is configured using the UBX-CFG-NAV5 message. So let's load our
92-
// custom packet with the correct information so we can read (poll) the current settings.
91+
// custom packet with the correct information so we can read (poll / get) the current settings.
9392

9493
customCfg.cls = UBX_CLASS_CFG; // This is the message Class
9594
customCfg.id = UBX_CFG_NAV5; // This is the message ID
@@ -102,18 +101,9 @@ void setup()
102101
// Now let's read the current navigation model settings. The results will be loaded into customCfg.
103102
if (myGPS.sendCommand(&customCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) // We are expecting data and an ACK
104103
{
105-
Serial.println(F("sendCommand (poll) failed! Trying again..."));
106-
// We need to reset the packet before we try again as the values could have changed
107-
customCfg.cls = UBX_CLASS_CFG;
108-
customCfg.id = UBX_CFG_NAV5;
109-
customCfg.len = 0;
110-
customCfg.startingSpot = 0;
111-
if (myGPS.sendCommand(&customCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) // We are expecting data and an ACK
112-
{
113-
Serial.println(F("sendCommand (poll) failed again! Freezing."));
114-
while (1)
115-
;
116-
}
104+
Serial.println(F("sendCommand (poll) failed! Freezing..."));
105+
while (1)
106+
;
117107
}
118108

119109
// Referring to the message definition for UBX-CFG-NAV5 we see that we need to change

src/SparkFun_Ublox_Arduino_Library.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ const char *SFE_UBLOX_GPS::statusString(sfe_ublox_status_e stat)
128128
return "Timeout";
129129
break;
130130
case SFE_UBLOX_STATUS_COMMAND_UNKNOWN:
131-
return "Command Unknown";
131+
return "Command Unknown (NACK)";
132132
break;
133133
case SFE_UBLOX_STATUS_OUT_OF_RANGE:
134134
return "Out of range";
@@ -154,6 +154,9 @@ const char *SFE_UBLOX_GPS::statusString(sfe_ublox_status_e stat)
154154
case SFE_UBLOX_STATUS_I2C_COMM_FAILURE:
155155
return "I2C Comm Failure";
156156
break;
157+
case SFE_UBLOX_STATUS_DATA_OVERWRITTEN:
158+
return "Data Packet Overwritten";
159+
break;
157160
default:
158161
return "Unknown Status";
159162
break;
@@ -2059,18 +2062,11 @@ boolean SFE_UBLOX_GPS::setNavigationFrequency(uint8_t navFreq, uint16_t maxWait)
20592062
if (sendCommand(&packetCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) // We are expecting data and an ACK
20602063
return (false); //If command send fails then bail
20612064

2062-
if (_printDebug == true)
2063-
{
2064-
_debugSerial->print(F("setNavigationFrequency packetCfg.len is "));
2065-
_debugSerial->println(packetCfg.len);
2066-
}
2067-
20682065
uint16_t measurementRate = 1000 / navFreq;
20692066

20702067
//payloadCfg is now loaded with current bytes. Change only the ones we need to
20712068
payloadCfg[0] = measurementRate & 0xFF; //measRate LSB
20722069
payloadCfg[1] = measurementRate >> 8; //measRate MSB
2073-
//packetCfg.len = 6;
20742070

20752071
return ((sendCommand(&packetCfg, maxWait)) == SFE_UBLOX_STATUS_DATA_SENT); // We are only expecting an ACK
20762072
}

0 commit comments

Comments
 (0)