You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 28, 2021. It is now read-only.
uint8_t hms = myGPS.packetUBXNAVPVTcopy->hour; // Print the hours
65
+
uint8_t hms = ubxDataStruct.hour; // Print the hours
64
66
if (hms < 10) Serial.print(F("0")); // Print a leading zero if required
65
67
Serial.print(hms);
66
68
Serial.print(F(":"));
67
-
hms = myGPS.packetUBXNAVPVTcopy->min; // Print the minutes
69
+
hms = ubxDataStruct.min; // Print the minutes
68
70
if (hms < 10) Serial.print(F("0")); // Print a leading zero if required
69
71
Serial.print(hms);
70
72
Serial.print(F(":"));
71
-
hms = myGPS.packetUBXNAVPVTcopy->sec; // Print the seconds
73
+
hms = ubxDataStruct.sec; // Print the seconds
72
74
if (hms < 10) Serial.print(F("0")); // Print a leading zero if required
73
75
Serial.print(hms);
74
76
Serial.print(F("."));
75
-
unsignedlong millisecs = myGPS.packetUBXNAVPVTcopy->iTOW % 1000; // Print the milliseconds
77
+
unsignedlong millisecs = ubxDataStruct.iTOW % 1000; // Print the milliseconds
76
78
if (millisecs < 100) Serial.print(F("0")); // Print the trailing zeros correctly
77
79
if (millisecs < 10) Serial.print(F("0"));
78
80
Serial.print(millisecs);
79
81
80
-
long latitude = myGPS.packetUBXNAVPVTcopy->lat; // Print the latitude
82
+
long latitude = ubxDataStruct.lat; // Print the latitude
81
83
Serial.print(F(" Lat: "));
82
84
Serial.print(latitude);
83
85
84
-
long longitude = myGPS.packetUBXNAVPVTcopy->lon; // Print the longitude
86
+
long longitude = ubxDataStruct.lon; // Print the longitude
85
87
Serial.print(F(" Long: "));
86
88
Serial.print(longitude);
87
89
Serial.print(F(" (degrees * 10^-7)"));
88
90
89
-
long altitude = myGPS.packetUBXNAVPVTcopy->hMSL; // Print the height above mean sea level
91
+
long altitude = ubxDataStruct.hMSL; // Print the height above mean sea level
90
92
Serial.print(F(" Height above MSL: "));
91
93
Serial.print(altitude);
92
94
Serial.println(F(" (mm)"));
@@ -145,8 +147,6 @@ void setup()
145
147
146
148
//myGPS.enableDebugging(); // Uncomment this line to enable helpful GNSS debug messages on Serial
147
149
148
-
//myGPS.disableUBX7Fcheck(); // Advanced users only: uncomment this line to disable the "7F" check in checkUbloxI2C
149
-
150
150
// NAV PVT messages are 100 bytes long.
151
151
// In this example, the data will arrive no faster than one message per second.
152
152
// So, setting the file buffer size to 301 bytes should be more than adequate.
@@ -159,12 +159,16 @@ void setup()
159
159
while (1);
160
160
}
161
161
162
+
// Uncomment the next line if you want to reset your module back to the default settings with 1Hz navigation rate
163
+
// (This will also disable any "auto" messages that were enabled and saved by other examples and reduce the load on the I2C bus)
164
+
//myGPS.factoryDefault(); delay(5000);
165
+
162
166
myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
163
167
myGPS.saveConfigSelective(VAL_CFG_SUBSEC_IOPORT); //Save (only) the communications port settings to flash and BBR
164
168
165
169
myGPS.setNavigationFrequency(1); //Produce one navigation solution per second
166
170
167
-
myGPS.setAutoPVTcallback(printPVTdata); // Enable automatic NAV PVT messages with callback to printPVTdata
171
+
myGPS.setAutoPVTcallback(&printPVTdata); // Enable automatic NAV PVT messages with callback to printPVTdata
168
172
169
173
myGPS.logNAVPVT(); // Enable NAV PVT data logging
170
174
@@ -180,29 +184,11 @@ void loop()
180
184
{
181
185
uint8_t myBuffer[packetLength]; // Create our own buffer to hold the data while we write it to SD card
182
186
183
-
uint16_t numBytesExtracted = myGPS.extractFileBufferData((uint8_t *)&myBuffer, packetLength); // Extract exactly packetLength bytes from the UBX file buffer and put them into myBuffer
187
+
myGPS.extractFileBufferData((uint8_t *)&myBuffer, packetLength); // Extract exactly packetLength bytes from the UBX file buffer and put them into myBuffer
184
188
185
-
if (numBytesExtracted != packetLength) // Check that we did extract exactly packetLength bytes
186
-
{
187
-
Serial.println(F("numBytesExtracted does not match packetLength! Something really bad has happened! Freezing..."));
188
-
myFile.close(); // Close the data file
189
-
while (1); // Do nothing more
190
-
}
189
+
myFile.write(myBuffer, packetLength); // Write exactly packetLength bytes from myBuffer to the ubxDataFile on the SD card
191
190
192
-
uint16_t numBytesWritten = myFile.write(myBuffer, packetLength); // Write exactly packetLength bytes from myBuffer to the ubxDataFile on the SD card
193
-
194
-
//printBuffer(myBuffer); // Uncomment this line to print the data
195
-
196
-
if (numBytesWritten != packetLength) // Check that we did write exactly packetLength bytes
197
-
{
198
-
Serial.println(F("numBytesWritten does not match packetLength! Something really bad has happened! Freezing..."));
199
-
myFile.close(); // Close the data file
200
-
while (1);
201
-
}
202
-
203
-
Serial.print(F("Wrote "));
204
-
Serial.print(packetLength);
205
-
Serial.println(F(" bytes of data to NAV_PVT.ubx"));
191
+
//printBuffer(myBuffer); // Uncomment this line to print the data as Hexadecimal bytes
206
192
}
207
193
208
194
if (Serial.available()) // Check if the user wants to stop logging
//myGPS.enableDebugging(); // Uncomment this line to enable helpful GNSS debug messages on Serial
140
155
141
-
//myGPS.disableUBX7Fcheck(); // Advanced users only: uncomment this line to disable the "7F" check in checkUbloxI2C
142
-
143
156
// TIM TM2 messages are 36 bytes long.
144
157
// In this example, the data will arrive no faster than one message per second.
145
158
// So, setting the file buffer size to 109 bytes should be more than adequate.
@@ -152,12 +165,16 @@ void setup()
152
165
while (1);
153
166
}
154
167
168
+
// Uncomment the next line if you want to reset your module back to the default settings with 1Hz navigation rate
169
+
// (This will also disable any "auto" messages that were enabled and saved by other examples and reduce the load on the I2C bus)
170
+
//myGPS.factoryDefault(); delay(5000);
171
+
155
172
myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
156
173
myGPS.saveConfigSelective(VAL_CFG_SUBSEC_IOPORT); //Save (only) the communications port settings to flash and BBR
157
174
158
175
myGPS.setNavigationFrequency(1); //Produce one navigation solution per second
159
176
160
-
myGPS.setAutoTIMTM2callback(printTIMTM2data); // Enable automatic TIM TM2 messages with callback to printTIMTM2data
177
+
myGPS.setAutoTIMTM2callback(&printTIMTM2data); // Enable automatic TIM TM2 messages with callback to printTIMTM2data
161
178
162
179
myGPS.logTIMTM2(); // Enable TIM TM2 data logging
163
180
@@ -173,29 +190,11 @@ void loop()
173
190
{
174
191
uint8_t myBuffer[packetLength]; // Create our own buffer to hold the data while we write it to SD card
175
192
176
-
uint16_t numBytesExtracted = myGPS.extractFileBufferData((uint8_t *)&myBuffer, packetLength); // Extract exactly packetLength bytes from the UBX file buffer and put them into myBuffer
177
-
178
-
if (numBytesExtracted != packetLength) // Check that we did extract exactly packetLength bytes
179
-
{
180
-
Serial.println(F("numBytesExtracted does not match packetLength! Something really bad has happened! Freezing..."));
181
-
myFile.close(); // Close the data file
182
-
while (1); // Do nothing more
183
-
}
193
+
myGPS.extractFileBufferData((uint8_t *)&myBuffer, packetLength); // Extract exactly packetLength bytes from the UBX file buffer and put them into myBuffer
184
194
185
-
uint16_t numBytesWritten = myFile.write(myBuffer, packetLength); // Write exactly packetLength bytes from myBuffer to the ubxDataFile on the SD card
195
+
myFile.write(myBuffer, packetLength); // Write exactly packetLength bytes from myBuffer to the ubxDataFile on the SD card
186
196
187
197
//printBuffer(myBuffer); // Uncomment this line to print the data
188
-
189
-
if (numBytesWritten != packetLength) // Check that we did write exactly packetLength bytes
190
-
{
191
-
Serial.println(F("numBytesWritten does not match packetLength! Something really bad has happened! Freezing..."));
192
-
myFile.close(); // Close the data file
193
-
while (1);
194
-
}
195
-
196
-
Serial.print(F("Wrote "));
197
-
Serial.print(packetLength);
198
-
Serial.println(F(" bytes of data to TIM_TM2.ubx"));
199
198
}
200
199
201
200
if (Serial.available()) // Check if the user wants to stop logging
Copy file name to clipboardExpand all lines: examples/Data_Logging/DataLoggingExample3_RXM_SFRBX_and_RAWX/DataLoggingExample3_RXM_SFRBX_and_RAWX.ino
+14-26Lines changed: 14 additions & 26 deletions
Original file line number
Diff line number
Diff line change
@@ -72,15 +72,15 @@ int numSFRBX = 0; // Keep count of how many SFRBX message groups have been recei
72
72
int numRAWX = 0; // Keep count of how many RAWX message groups have been received (see note above)
73
73
74
74
// Callback: newSFRBX will be called when new RXM SFRBX data arrives
75
-
// See u-blox_structs.h for the full definition of UBX_RXMSFRBX_data_t *packetUBXRXMSFRBXcopy
76
-
voidnewSFRBX()
75
+
// See u-blox_structs.h for the full definition of UBX_RXMSFRBX_data_t
76
+
voidnewSFRBX(UBX_RXM_SFRBX_data_t ubxDataStruct)
77
77
{
78
78
numSFRBX++; // Increment the count
79
79
}
80
80
81
81
// Callback: newRAWX will be called when new RXM RAWX data arrives
82
-
// See u-blox_structs.h for the full definition of UBX_RXMRAWX_data_t *packetUBXRXMRAWXcopy
83
-
voidnewRAWX()
82
+
// See u-blox_structs.h for the full definition of UBX_RXMRAWX_data_t
83
+
voidnewRAWX(UBX_RXM_RAWX_data_t ubxDataStruct)
84
84
{
85
85
numRAWX++; // Increment the count
86
86
}
@@ -157,18 +157,19 @@ void setup()
157
157
}
158
158
159
159
// Uncomment the next line if you want to reset your module back to the default settings with 1Hz navigation rate
160
+
// (This will also disable any "auto" messages that were enabled and saved by other examples and reduce the load on the I2C bus)
160
161
//myGPS.factoryDefault(); delay(5000);
161
162
162
163
myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
163
164
myGPS.saveConfigSelective(VAL_CFG_SUBSEC_IOPORT); //Save (only) the communications port settings to flash and BBR
164
165
165
166
myGPS.setNavigationFrequency(1); //Produce one navigation solution per second (that's plenty for Precise Point Positioning)
166
167
167
-
myGPS.setAutoRXMSFRBXcallback(newSFRBX); // Enable automatic RXM SFRBX messages with callback to newSFRBX
168
+
myGPS.setAutoRXMSFRBXcallback(&newSFRBX); // Enable automatic RXM SFRBX messages with callback to newSFRBX
168
169
169
170
myGPS.logRXMSFRBX(); // Enable RXM SFRBX data logging
170
171
171
-
myGPS.setAutoRXMRAWXcallback(newRAWX); // Enable automatic RXM RAWX messages with callback to newRAWX
172
+
myGPS.setAutoRXMRAWXcallback(&newRAWX); // Enable automatic RXM RAWX messages with callback to newRAWX
172
173
173
174
myGPS.logRXMRAWX(); // Enable RXM RAWX data logging
174
175
@@ -192,23 +193,9 @@ void loop()
192
193
193
194
uint8_t myBuffer[sdWriteSize]; // Create our own buffer to hold the data while we write it to SD card
194
195
195
-
uint16_t numBytesExtracted = myGPS.extractFileBufferData((uint8_t *)&myBuffer, sdWriteSize); // Extract exactly sdWriteSize bytes from the UBX file buffer and put them into myBuffer
196
+
myGPS.extractFileBufferData((uint8_t *)&myBuffer, sdWriteSize); // Extract exactly sdWriteSize bytes from the UBX file buffer and put them into myBuffer
196
197
197
-
if (numBytesExtracted != sdWriteSize) // Check that we did extract exactly sdWriteSize bytes
198
-
{
199
-
Serial.println(F("numBytesExtracted does not match sdWriteSize! Something really bad has happened! Freezing..."));
200
-
myFile.close(); // Close the data file
201
-
while (1); // Do nothing more
202
-
}
203
-
204
-
uint16_t numBytesWritten = myFile.write(myBuffer, sdWriteSize); // Write exactly sdWriteSize bytes from myBuffer to the ubxDataFile on the SD card
205
-
206
-
if (numBytesWritten != sdWriteSize) // Check that we did write exactly sdWriteSize bytes
207
-
{
208
-
Serial.println(F("numBytesWritten does not match sdWriteSize! Something really bad has happened! Freezing..."));
209
-
myFile.close(); // Close the data file
210
-
while (1);
211
-
}
198
+
myFile.write(myBuffer, sdWriteSize); // Write exactly sdWriteSize bytes from myBuffer to the ubxDataFile on the SD card
212
199
213
200
// In case the SD writing is slow or there is a lot of data to write, keep checking for the arrival of new data
214
201
myGPS.checkUblox(); // Check for the arrival of new data and process it.
@@ -226,13 +213,14 @@ void loop()
226
213
Serial.print(F(" RAWX: "));
227
214
Serial.println(numRAWX);
228
215
229
-
uint16_t maxBufferBytes = myGPS.getMaxFileBufferAvail(); // Print how full the file buffer has been (not how full it is now)
230
-
Serial.print(F("The maximum number of bytes which the file buffer has contained is: "));
231
-
Serial.println(maxBufferBytes);
216
+
uint16_t maxBufferBytes = myGPS.getMaxFileBufferAvail(); // Get how full the file buffer has been (not how full it is now)
217
+
218
+
//Serial.print(F("The maximum number of bytes which the file buffer has contained is: ")); // It is a fun thing to watch how full the buffer gets
219
+
//Serial.println(maxBufferBytes);
232
220
233
221
if (maxBufferBytes > ((fileBufferSize / 5) * 4)) // Warn the user if fileBufferSize was more than 80% full
234
222
{
235
-
Serial.println(F("Warning: the file buffer was almost full. Some data may have been lost."));
223
+
Serial.println(F("Warning: the file buffer has been over 80% full. Some data may have been lost."));
0 commit comments