Skip to content

Commit 828d1ad

Browse files
committed
Correct SPI key offset. Doh! Add better GNSS debug for Ref Stn. Add log position
1 parent f9f4c5d commit 828d1ad

File tree

6 files changed

+37
-6
lines changed

6 files changed

+37
-6
lines changed

Firmware/RTK_Surveyor/Begin.ino

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,14 @@ void beginUART2()
550550
//Assign UART2 interrupts to the core 0. See: https://github.com/espressif/arduino-esp32/issues/3386
551551
void pinUART2Task( void *pvParameters )
552552
{
553-
if (USE_I2C_GNSS)
553+
//Note: ESP32 2.0.6 does some strange auto-bauding thing here which takes 20s to complete if there is no data for it to auto-baud.
554+
// That's fine for most RTK products, but causes the Ref Stn to stall for 20s. However, it doesn't stall with ESP32 2.0.2...
555+
// Note to my future self: uncomment these lines to prevent the stall if/when we upgrade to ESP32 ~2.0.6.
556+
//#if defined(ENABLE_DEVELOPER) && defined(REF_STN_GNSS_DEBUG)
557+
// if (productVariant == REFERENCE_STATION)
558+
//#else
559+
// if (USE_I2C_GNSS)
560+
//#endif
554561
{
555562
serialGNSS.setRxBufferSize(settings.uartReceiveBufferSize); // TODO: work out if we can reduce or skip this when using SPI GNSS
556563
serialGNSS.setTimeout(settings.serialTimeoutGNSS); // Requires serial traffic on the UART pins for detection

Firmware/RTK_Surveyor/RTK_Surveyor.ino

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#define ENABLE_DEVELOPER //Uncomment this line to enable special developer modes (don't check power button at startup)
3535
//#define FACTORY_RESET_AT_POWER_ON //Uncomment this line to perform a factory reset at every power-on. Needs ENABLE_DEVELOPER
3636
//#define ERASE_PROFILES_AT_POWER_ON //Uncomment this line to erase _all_ profiles at power-on. Needs FACTORY_RESET_ON_POWER_ON
37+
#define REF_STN_GNSS_DEBUG //Uncomment this line to output GNSS library debug messages on serialGNSS. Ref STn only. Needs ENABLE_DEVELOPER
3738

3839
//Define the RTK board identifier:
3940
// This is an int which is unique to this variant of the RTK Surveyor hardware which allows us
@@ -307,6 +308,7 @@ volatile bool uart2pinned = false; //This variable is touched by core 0 but chec
307308

308309
volatile static int combinedSpaceRemaining = 0; //Overrun indicator
309310
volatile static long fileSize = 0; //Updated with each write
311+
volatile static long filePosition = 0; //Updated with each write
310312
int bufferOverruns = 0; //Running count of possible data losses since power-on
311313

312314
bool zedUartPassed = false; //Goes true during testing if ESP can communicate with ZED over UART
@@ -452,7 +454,8 @@ uint8_t loggingIconDisplayed = 0; //Increases every 500ms while logging
452454
uint8_t espnowIconDisplayed = 0; //Increases every 500ms while transmitting
453455

454456
uint64_t lastLogSize = 0;
455-
bool logIncreasing = false; //Goes true when log file is greater than lastLogSize
457+
uint64_t lastLogPosition = 0;
458+
bool logIncreasing = false; //Goes true when log file is greater than lastLogSize or logPosition changes
456459
bool reuseLastLog = false; //Goes true if we have a reset due to software (rather than POR)
457460

458461
uint16_t rtcmPacketsSent = 0; //Used to count RTCM packets sent via processRTCM()
@@ -841,6 +844,11 @@ void updateLogs()
841844
lastLogSize = fileSize;
842845
logIncreasing = true;
843846
}
847+
else if (filePosition != lastLogPosition)
848+
{
849+
lastLogPosition = filePosition;
850+
logIncreasing = true;
851+
}
844852
else
845853
{
846854
log_d("No increase in file size");

Firmware/RTK_Surveyor/System.ino

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,14 @@ bool configureUbloxModule()
99

1010
//Turn on/off debug messages
1111
if (settings.enableI2Cdebug)
12+
{
13+
#if defined(ENABLE_DEVELOPER) && defined(REF_STN_GNSS_DEBUG)
14+
if (productVariant == REFERENCE_STATION)
15+
theGNSS.enableDebugging(serialGNSS); //Output all debug messages over serialGNSS
16+
else
17+
#endif
1218
theGNSS.enableDebugging(Serial, true); //Enable only the critical debug messages over Serial
19+
}
1320
else
1421
theGNSS.disableDebugging();
1522

@@ -512,9 +519,9 @@ bool setMessages()
512519
{
513520
bool response = true;
514521

515-
uint32_t spiOffset = 0; // Set to 1 if using SPI to convert UART1 keys to SPI
522+
uint32_t spiOffset = 0; // Set to 3 if using SPI to convert UART1 keys to SPI. This is brittle and non-perfect, but works.
516523
if (USE_SPI_GNSS)
517-
spiOffset = 1;
524+
spiOffset = 3;
518525

519526
int x = 0;
520527
while (x < MAX_UBX_MSG)
@@ -543,14 +550,14 @@ bool setMessages()
543550
rate = 1;
544551
}
545552

546-
response &= theGNSS.addCfgValset(settings.ubxMessages[x].msgConfigKey - spiOffset, rate);
553+
response &= theGNSS.addCfgValset(settings.ubxMessages[x].msgConfigKey + spiOffset, rate);
547554
}
548555
x++;
549556
}
550557
while (((x % 43) < 42) && (x < MAX_UBX_MSG)); // Limit 1st batch to 42. Batches after that will be (up to) 43 in size. It's a HHGTTG thing.
551558

552559
response &= theGNSS.sendCfgValset();
553-
log_d("sent Valset for message %d", x);
560+
log_d("sent Valset for message %d: %s", x, response ? "OK" : "ERROR");
554561
}
555562

556563
log_d("message config complete");

Firmware/RTK_Surveyor/Tasks.ino

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,7 @@ void handleGNSSDataTask(void *e)
409409

410410
sdBytesToRecord = ubxFile->write(&ringBuffer[sdTail], sliceToRecord);
411411
fileSize = ubxFile->fileSize(); //Update file size
412+
filePosition = ubxFile->position(); //Update file position
412413

413414
sdFreeSpace -= sliceToRecord; //Update remaining space on SD
414415

Firmware/RTK_Surveyor/menuMessages.ino

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,7 @@ void beginLogging(const char *customFileName)
374374

375375
fileSize = 0;
376376
lastLogSize = 0; //Reset counter - used for displaying active logging icon
377+
lastLogPosition = 0;
377378

378379
bufferOverruns = 0; //Reset counter
379380

Firmware/RTK_Surveyor/menuSystem.ino

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,14 @@ void menuDebug()
606606
settings.enableI2Cdebug ^= 1;
607607

608608
if (settings.enableI2Cdebug)
609+
{
610+
#if defined(ENABLE_DEVELOPER) && defined(REF_STN_GNSS_DEBUG)
611+
if (productVariant == REFERENCE_STATION)
612+
theGNSS.enableDebugging(serialGNSS); //Output all debug messages over serialGNSS
613+
else
614+
#endif
609615
theGNSS.enableDebugging(Serial, true); //Enable only the critical debug messages over Serial
616+
}
610617
else
611618
theGNSS.disableDebugging();
612619
}

0 commit comments

Comments
 (0)