Skip to content

Commit 93ecea1

Browse files
committed
Add RTCM packet counting. Add log icon.
We display log icon only when the file sizes are increasing in size. This will hopefully help warn the user when logging has failed.
1 parent 4221d4f commit 93ecea1

File tree

5 files changed

+104
-55
lines changed

5 files changed

+104
-55
lines changed

Firmware/RTK_Surveyor/Base.ino

Lines changed: 38 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,15 @@ bool surveyIn()
6868
if (response == false)
6969
{
7070
Serial.println(F("Survey start failed"));
71-
return(false);
71+
return (false);
7272
}
7373

7474
Serial.printf("Survey started. This will run until %d seconds have passed and less than %0.03f meter accuracy is achieved.\n",
7575
settings.observationSeconds,
7676
settings.observationPositionAccuracy
7777
);
7878

79-
return(true);
79+
return (true);
8080
}
8181

8282
void resetSurvey()
@@ -113,9 +113,9 @@ bool startFixedBase()
113113
//Units are cm with a high precision extension so -1234.5678 should be called: (-123456, -78)
114114
//-1280208.308,-4716803.847,4086665.811 is SparkFun HQ so...
115115
response = i2cGNSS.setStaticPosition(majorEcefX, minorEcefX,
116-
majorEcefY, minorEcefY,
117-
majorEcefZ, minorEcefZ
118-
); //With high precision 0.1mm parts
116+
majorEcefY, minorEcefY,
117+
majorEcefZ, minorEcefZ
118+
); //With high precision 0.1mm parts
119119
}
120120
else if (settings.fixedBaseCoordinateType == COORD_TYPE_GEOGRAPHIC)
121121
{
@@ -128,17 +128,17 @@ bool startFixedBase()
128128
int32_t majorAlt = settings.fixedAltitude * 100;
129129
int32_t minorAlt = ((settings.fixedAltitude * 100) - majorAlt) * 100;
130130

131-
// Serial.printf("fixedLat (should be -105.184774720): %0.09f\n", settings.fixedLat);
132-
// Serial.printf("major (should be -1051847747): %lld\n", majorLat);
133-
// Serial.printf("minor (should be -20): %lld\n", minorLat);
134-
//
135-
// Serial.printf("fixedLong (should be 40.090335429): %0.09f\n", settings.fixedLong);
136-
// Serial.printf("major (should be 400903354): %lld\n", majorLong);
137-
// Serial.printf("minor (should be 29): %lld\n", minorLong);
138-
//
139-
// Serial.printf("fixedAlt (should be 1560.2284): %0.04f\n", settings.fixedAltitude);
140-
// Serial.printf("major (should be 156022): %ld\n", majorAlt);
141-
// Serial.printf("minor (should be 84): %ld\n", minorAlt);
131+
// Serial.printf("fixedLat (should be -105.184774720): %0.09f\n", settings.fixedLat);
132+
// Serial.printf("major (should be -1051847747): %lld\n", majorLat);
133+
// Serial.printf("minor (should be -20): %lld\n", minorLat);
134+
//
135+
// Serial.printf("fixedLong (should be 40.090335429): %0.09f\n", settings.fixedLong);
136+
// Serial.printf("major (should be 400903354): %lld\n", majorLong);
137+
// Serial.printf("minor (should be 29): %lld\n", minorLong);
138+
//
139+
// Serial.printf("fixedAlt (should be 1560.2284): %0.04f\n", settings.fixedAltitude);
140+
// Serial.printf("major (should be 156022): %ld\n", majorAlt);
141+
// Serial.printf("minor (should be 84): %ld\n", minorAlt);
142142

143143
response = i2cGNSS.setStaticPosition(
144144
majorLat, minorLat,
@@ -180,7 +180,7 @@ bool updateNtripServer()
180180
return (false);
181181
}
182182

183-
if(Serial.available()) return(false); //User has pressed a key
183+
if (Serial.available()) return (false); //User has pressed a key
184184
}
185185
Serial.println();
186186

@@ -247,7 +247,7 @@ bool updateNtripServer()
247247
//Reset flags
248248
lastServerReport_ms = millis();
249249
lastServerSent_ms = millis();
250-
serverBytesSent = 0;
250+
casterBytesSent = 0;
251251
}
252252
} //End attempt to connect
253253
else
@@ -273,7 +273,7 @@ bool updateNtripServer()
273273
if (millis() - lastServerReport_ms > 250)
274274
{
275275
lastServerReport_ms = millis();
276-
Serial.printf("Total bytes sent to caster: %d\n", serverBytesSent);
276+
Serial.printf("Total bytes sent to caster: %d\n", casterBytesSent);
277277
}
278278

279279
return (true);
@@ -284,10 +284,28 @@ bool updateNtripServer()
284284
//Useful for passing the RTCM correction data to a radio, Ntrip broadcaster, etc.
285285
void SFE_UBLOX_GNSS::processRTCM(uint8_t incoming)
286286
{
287+
//Count outgoing packets for display
288+
//Assume 1Hz RTCM transmissions
289+
if (millis() - lastRTCMPacketSent > 500)
290+
{
291+
lastRTCMPacketSent = millis();
292+
rtcmPacketsSent++;
293+
}
294+
295+
//Check for too many digits
296+
if (logIncreasing == true)
297+
{
298+
if (rtcmPacketsSent > 999) rtcmPacketsSent = 1; //Trim to three digits to avoid logging icon
299+
}
300+
else
301+
{
302+
if (rtcmPacketsSent > 9999) rtcmPacketsSent = 1;
303+
}
304+
287305
if (caster.connected() == true)
288306
{
289307
caster.write(incoming); //Send this byte to socket
290-
serverBytesSent++;
308+
casterBytesSent++;
291309
lastServerSent_ms = millis();
292310
}
293311
}

Firmware/RTK_Surveyor/Display.ino

Lines changed: 41 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,19 @@ void paintSIV()
380380
}
381381
}
382382

383+
//Draw log icon
384+
//Turn off icon if log file gets bigger
385+
void paintLogging()
386+
{
387+
if (online.display == true)
388+
{
389+
if (logIncreasing == true)
390+
{
391+
oled.drawIcon(63 - Logging_Width, 47 - Logging_Height, Logging_Width, Logging_Height, Logging, sizeof(Logging), true); //Draw the icon
392+
}
393+
}
394+
}
395+
383396
//Base screen. Display BLE, rover, battery, HorzAcc and SIV
384397
//Blink SIV until fix
385398
void paintRoverNoFix()
@@ -395,6 +408,8 @@ void paintRoverNoFix()
395408
paintHorizontalAccuracy();
396409

397410
paintSIV();
411+
412+
paintLogging();
398413
}
399414
}
400415

@@ -412,6 +427,8 @@ void paintRoverFix()
412427
paintHorizontalAccuracy();
413428

414429
paintSIV();
430+
431+
paintLogging();
415432
}
416433
}
417434

@@ -429,6 +446,8 @@ void paintRoverRTKFloat()
429446
paintHorizontalAccuracy();
430447

431448
paintSIV();
449+
450+
paintLogging();
432451
}
433452
}
434453

@@ -445,6 +464,8 @@ void paintRoverRTKFix()
445464
paintHorizontalAccuracy();
446465

447466
paintSIV();
467+
468+
paintLogging();
448469
}
449470
}
450471

@@ -464,6 +485,8 @@ void paintBaseTempSurveyNotStarted()
464485
paintHorizontalAccuracy(); //2nd line
465486

466487
paintSIV();
488+
489+
paintLogging();
467490
}
468491
}
469492

@@ -481,10 +504,6 @@ void paintBaseTempSurveyStarted()
481504
float meanAccuracy = i2cGNSS.getSurveyInMeanAccuracy(100);
482505
int elapsedTime = i2cGNSS.getSurveyInObservationTime(100);
483506

484-
//Stopped. We either need a call back or we accept a 2s update to screen. Something is taking a lot of polling time.
485-
486-
// deleteMeElapsedTime++;
487-
488507
oled.setFontType(0);
489508
oled.setCursor(0, 22); //x, y
490509
oled.print("Mean:");
@@ -500,6 +519,8 @@ void paintBaseTempSurveyStarted()
500519
oled.setCursor(30, 36); //x, y
501520
oled.setFontType(1);
502521
oled.print(elapsedTime);
522+
523+
paintLogging();
503524
}
504525
}
505526

@@ -527,10 +548,9 @@ void paintBaseTempTransmitting()
527548
oled.setCursor(29, 36); //x, y
528549
oled.setFontType(1); //Set font to type 1: 8x16
529550

530-
//Check for too many digits
531-
if (rtcmPacketsSent > 9999) rtcmPacketsSent = 1;
532-
533551
oled.print(rtcmPacketsSent); //rtcmPacketsSent is controlled in processRTCM()
552+
553+
paintLogging();
534554
}
535555
}
536556

@@ -559,10 +579,9 @@ void paintBaseTempWiFiStarted()
559579
oled.setCursor(29, 36); //x, y
560580
oled.setFontType(1); //Set font to type 1: 8x16
561581

562-
//Check for too many digits
563-
if (rtcmPacketsSent > 9999) rtcmPacketsSent = 1;
564-
565582
oled.print(rtcmPacketsSent); //rtcmPacketsSent is controlled in processRTCM()
583+
584+
paintLogging();
566585
}
567586
}
568587

@@ -592,10 +611,9 @@ void paintBaseTempWiFiConnected()
592611
oled.setCursor(29, 36); //x, y
593612
oled.setFontType(1); //Set font to type 1: 8x16
594613

595-
//Check for too many digits
596-
if (rtcmPacketsSent > 9999) rtcmPacketsSent = 1;
597-
598614
oled.print(rtcmPacketsSent); //rtcmPacketsSent is controlled in processRTCM()
615+
616+
paintLogging();
599617
}
600618
}
601619

@@ -651,10 +669,9 @@ void paintBaseTempCasterConnected()
651669
oled.setCursor(29, 36); //x, y
652670
oled.setFontType(1); //Set font to type 1: 8x16
653671

654-
//Check for too many digits
655-
if (rtcmPacketsSent > 9999) rtcmPacketsSent = 1;
656-
657672
oled.print(rtcmPacketsSent); //rtcmPacketsSent is controlled in processRTCM()
673+
674+
paintLogging();
658675
}
659676
}
660677

@@ -682,10 +699,9 @@ void paintBaseFixedTransmitting()
682699
oled.setCursor(29, 36); //x, y
683700
oled.setFontType(1); //Set font to type 1: 8x16
684701

685-
//Check for too many digits
686-
if (rtcmPacketsSent > 9999) rtcmPacketsSent = 1;
687-
688702
oled.print(rtcmPacketsSent); //rtcmPacketsSent is controlled in processRTCM()
703+
704+
paintLogging();
689705
}
690706
}
691707

@@ -714,10 +730,9 @@ void paintBaseFixedWiFiStarted()
714730
oled.setCursor(29, 36); //x, y
715731
oled.setFontType(1); //Set font to type 1: 8x16
716732

717-
//Check for too many digits
718-
if (rtcmPacketsSent > 9999) rtcmPacketsSent = 1;
719-
720733
oled.print(rtcmPacketsSent); //rtcmPacketsSent is controlled in processRTCM()
734+
735+
paintLogging();
721736
}
722737
}
723738

@@ -747,10 +762,9 @@ void paintBaseFixedWiFiConnected()
747762
oled.setCursor(29, 36); //x, y
748763
oled.setFontType(1); //Set font to type 1: 8x16
749764

750-
//Check for too many digits
751-
if (rtcmPacketsSent > 9999) rtcmPacketsSent = 1;
752-
753765
oled.print(rtcmPacketsSent); //rtcmPacketsSent is controlled in processRTCM()
766+
767+
paintLogging();
754768
}
755769
}
756770

@@ -806,10 +820,9 @@ void paintBaseFixedCasterConnected()
806820
oled.setCursor(29, 36); //x, y
807821
oled.setFontType(1); //Set font to type 1: 8x16
808822

809-
//Check for too many digits
810-
if (rtcmPacketsSent > 9999) rtcmPacketsSent = 1;
811-
812823
oled.print(rtcmPacketsSent); //rtcmPacketsSent is controlled in processRTCM()
824+
825+
paintLogging();
813826
}
814827
}
815828

Firmware/RTK_Surveyor/RTK_Surveyor.ino

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ unsigned long lastServerSent_ms = 0; //Time of last data pushed to caster
116116
unsigned long lastServerReport_ms = 0; //Time of last report of caster bytes sent
117117
int maxTimeBeforeHangup_ms = 10000; //If we fail to get a complete RTCM frame after 10s, then disconnect from caster
118118

119-
uint32_t serverBytesSent = 0; //Just a running total
119+
uint32_t casterBytesSent = 0; //Just a running total
120+
uint32_t casterResponseWaitStartTime = 0; //Used to detect if caster service times out
120121
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
121122

122123
//GNSS configuration
@@ -229,14 +230,15 @@ bool satelliteDishIconDisplayed = false; //Toggles as lastSatelliteDishIconUpdat
229230
uint32_t lastCrosshairIconUpdate = 0;
230231
bool crosshairIconDisplayed = false; //Toggles as lastCrosshairIconUpdate goes above 1000ms
231232
uint32_t lastBaseIconUpdate = 0;
232-
bool baseIconDisplayed = false; //Toggles as lastSatelliteDishIconUpdate goes above 1000ms
233+
bool baseIconDisplayed = false; //Toggles as lastBaseIconUpdate goes above 1000ms
233234
uint32_t lastWifiIconUpdate = 0;
234235
bool wifiIconDisplayed = false; //Toggles as lastWifiIconUpdate goes above 1000ms
235236

236-
uint32_t lastRTCMPacketSent = 0; //Used to count RTCM packets sent during base mode
237-
uint32_t rtcmPacketsSent = 0; //Used to count RTCM packets sent during base mode
237+
uint32_t lastLogSize = 0;
238+
bool logIncreasing = false; //Goes true when log file is greater than lastLogSize
238239

239-
uint32_t casterResponseWaitStartTime = 0; //Used to detect if caster service times out
240+
uint32_t lastRTCMPacketSent = 0; //Used to count RTCM packets sent during base mode
241+
uint32_t rtcmPacketsSent = 0; //Used to count RTCM packets sent via processRTCM()
240242

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

@@ -383,6 +385,15 @@ void updateLogs()
383385
(systemTime_minutes - startLogTime_minutes));
384386

385387
Serial.println();
388+
389+
//Update for display
390+
if (ubxFile.fileSize() > lastLogSize)
391+
{
392+
lastLogSize = ubxFile.fileSize();
393+
logIncreasing = true;
394+
}
395+
else
396+
logIncreasing = false;
386397
}
387398
}
388399
}

Firmware/RTK_Surveyor/States.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ void updateSystemState()
253253
//Reset flags
254254
lastServerReport_ms = millis();
255255
lastServerSent_ms = millis();
256-
serverBytesSent = 0;
256+
casterBytesSent = 0;
257257

258258
changeState(STATE_BASE_TEMP_CASTER_CONNECTED);
259259
}
@@ -385,7 +385,7 @@ void updateSystemState()
385385
//Reset flags
386386
lastServerReport_ms = millis();
387387
lastServerSent_ms = millis();
388-
serverBytesSent = 0;
388+
casterBytesSent = 0;
389389

390390
changeState(STATE_BASE_FIXED_CASTER_CONNECTED);
391391
}

Firmware/RTK_Surveyor/icons.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,10 @@ uint8_t Battery_0 [] = {
9393
};
9494
int Battery_0_Height = 12;
9595
int Battery_0_Width = 19;
96+
97+
uint8_t Logging [] = {
98+
0xFF, 0x01, 0x51, 0x51, 0x51, 0x51, 0x53, 0x06, 0xFC, 0x0F, 0x08, 0x09, 0x09, 0x09, 0x09, 0x09,
99+
0x08, 0x0F,
100+
};
101+
int Logging_Height = 12;
102+
int Logging_Width = 9;

0 commit comments

Comments
 (0)