Skip to content

Commit 7edf2b0

Browse files
committed
Add data generation and recording stats to output.
1 parent 0808ece commit 7edf2b0

File tree

1 file changed

+22
-13
lines changed

1 file changed

+22
-13
lines changed

Firmware/RTK_Surveyor/RTK_Surveyor.ino

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
(Done) Firmware upgrade menu
3434
Enable various debug outputs sent over BT
3535
36-
Add blinking log file icon
36+
TODO
37+
Solve caster port not closing issue
3738
*/
3839

3940
const int FIRMWARE_VERSION_MAJOR = 1;
@@ -96,7 +97,7 @@ char settingsFileName[40] = "SFE_Surveyor_Settings.txt"; //File to read/write sy
9697

9798
SdFile ubxFile; //File that all gnss ubx messages setences are written to
9899
unsigned long lastUBXLogSyncTime = 0; //Used to record to SD every half second
99-
long startLogTime_minutes = 0; //Mark when we start logging so we can stop logging after maxLogTime_minutes
100+
int startLogTime_minutes = 0; //Mark when we start logging so we can stop logging after maxLogTime_minutes
100101

101102
//SdFat crashes when F9PSerialReadTask() is called in the middle of a ubx file write within loop()
102103
//So we use a semaphore to see if file system is available
@@ -216,11 +217,13 @@ uint8_t unitMACAddress[6]; //Use MAC address in BT broadcast and display
216217
char deviceName[20]; //The serial string that is broadcast. Ex: 'Surveyor Base-BC61'
217218
const byte menuTimeout = 15; //Menus will exit/timeout after this number of seconds
218219
bool inTestMode = false; //Used to re-route BT traffic while in test sub menu
219-
long systemTime_minutes = 0; //Used to test if logging is less than max minutes
220+
int systemTime_minutes = 0; //Used to test if logging is less than max minutes
220221

221222
uint32_t lastBattUpdate = 0;
222223
uint32_t lastDisplayUpdate = 0;
223224
uint32_t lastSystemStateUpdate = 0;
225+
uint32_t lastAccuracyLEDUpdate = 0;
226+
uint32_t lastBaseLEDupdate = 0; //Controls the blinking of the Base LED
224227

225228
uint32_t lastFileReport = 0; //When logging, print file record stats every few seconds
226229
long lastStackReport = 0; //Controls the report rate of stack highwater mark within a task
@@ -242,20 +245,17 @@ uint32_t rtcmPacketsSent = 0; //Used to count RTCM packets sent via processRTCM(
242245

243246
uint32_t maxSurveyInWait_s = 60L * 15L; //Re-start survey-in after X seconds
244247

245-
uint32_t lastBaseLEDupdate = 0; //Controls the blinking of the Base LED
246-
248+
uint32_t totalWriteTime = 0; //Used to calculate overall write speed using SdFat library
247249
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
248250

249251
void setup()
250252
{
251253
Serial.begin(115200); //UART0 for programming and debugging
252-
Serial.setRxBufferSize(SERIAL_SIZE_RX);
253-
Serial.setTimeout(1);
254254

255255
Wire.begin(); //Start I2C on core 1
256256
Wire.setClock(400000);
257257

258-
beginUART2(); //Start UART2 on core 0
258+
beginUART2(); //Start UART2 on core 0, used to receive serial from ZED and pass out over SPP
259259

260260
beginLEDs(); //LED and PWM setup
261261

@@ -289,6 +289,7 @@ void setup()
289289
danceLEDs(); //Turn on LEDs like a car dashboard
290290

291291
//i2cGNSS.enableDebugging(); //Enable debug messages over Serial (default)
292+
i2cGNSS.enableDebugging(Serial, true); //Enable only the critical debug messages over Serial
292293
}
293294

294295
void loop()
@@ -346,7 +347,7 @@ void updateLogs()
346347

347348
i2cGNSS.extractFileBufferData((uint8_t *)&myBuffer, sdWriteSize); // Extract exactly sdWriteSize bytes from the UBX file buffer and put them into myBuffer
348349

349-
int bytesWritten = ubxFile.write(myBuffer, sdWriteSize); // Write exactly sdWriteSize bytes from myBuffer to the ubxDataFile on the SD card
350+
ubxFile.write(myBuffer, sdWriteSize); // Write exactly sdWriteSize bytes from myBuffer to the ubxDataFile on the SD card
350351

351352
if (settings.frequentFileAccessTimestamps == true)
352353
updateDataFileAccess(&ubxFile); // Update the file access time & date
@@ -356,7 +357,10 @@ void updateLogs()
356357
{
357358
lastUBXLogSyncTime = millis();
358359
digitalWrite(baseStatusLED, !digitalRead(baseStatusLED)); //Blink LED to indicate logging activity
360+
long startWriteTime = millis();
359361
ubxFile.sync();
362+
long stopWriteTime = millis();
363+
totalWriteTime += stopWriteTime - startWriteTime; //Used to calculate overall write speed
360364
digitalWrite(baseStatusLED, !digitalRead(baseStatusLED)); //Return LED to previous state
361365

362366
updateDataFileAccess(&ubxFile); // Update the file access time & date
@@ -379,10 +383,15 @@ void updateLogs()
379383
lastFileReport = millis();
380384
Serial.printf("UBX file size: %d", ubxFile.fileSize());
381385

382-
if ((systemTime_minutes - startLogTime_minutes) > settings.maxLogTime_minutes)
383-
Serial.printf(" reached max log time %d / System time %d",
384-
settings.maxLogTime_minutes,
385-
(systemTime_minutes - startLogTime_minutes));
386+
if ((systemTime_minutes - startLogTime_minutes) < settings.maxLogTime_minutes)
387+
{
388+
Serial.printf(" - Generation rate: %0.1fkB/s", (ubxFile.fileSize() / (millis() / 1000.0)) / 1000.0);
389+
Serial.printf(" - Write speed: %0.1fkB/s", (ubxFile.fileSize() / (totalWriteTime / 1000.0)) / 1000.0);
390+
}
391+
else
392+
{
393+
Serial.printf(" reached max log time %d", settings.maxLogTime_minutes);
394+
}
386395

387396
Serial.println();
388397

0 commit comments

Comments
 (0)