Skip to content

Commit 7ded2f3

Browse files
committed
More refactoring...
1 parent 10620cb commit 7ded2f3

File tree

8 files changed

+86
-26
lines changed

8 files changed

+86
-26
lines changed

Firmware/RTK_Surveyor/Base.ino

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,23 @@ bool configureUbloxModuleBase()
3535

3636
response &= theGNSS.addCfgValset(UBLOX_CFG_NAVSPG_DYNMODEL, (dynModel)settings.dynamicModel); // Set dynamic model
3737

38+
//RTCM is only available on ZED-F9P modules
39+
//
40+
//For most RTK products, the GNSS is interfaced via both I2C and UART1. Configuration and PVT/HPPOS messages are
41+
//configured over I2C. Any messages that need to be logged are output on UART1, and received by this code using
42+
//serialGNSS.
3843
//In base mode the RTK device should output RTCM over all ports:
3944
//(Primary) UART2 in case the Surveyor is connected via radio to rover
4045
//(Optional) I2C in case user wants base to connect to WiFi and NTRIP Caster
4146
//(Seconday) USB in case the Surveyor is used as an NTRIP caster connected to SBC or other
4247
//(Tertiary) UART1 in case Surveyor is sending RTCM to phone that is then NTRIP Caster
48+
//
49+
//But, on the Reference Station, the GNSS is interfaced via SPI. It has no access to I2C and UART1.
50+
//We use the GNSS library's built-in logging buffer to mimic UART1. The code in Tasks.ino reads
51+
//data from the logging buffer as if it had come from UART1.
52+
//So for that product - in Base mode - we can only output RTCM on SPI, USB and UART2.
53+
//If we want to log the RTCM messages, we need to add them to the logging buffer inside the GNSS library.
54+
//If we want to pass them along to (e.g.) radio, we do that using processRTCM (defined below).
4355

4456
if (USE_I2C_GNSS)
4557
{
@@ -48,7 +60,7 @@ bool configureUbloxModuleBase()
4860
response &= theGNSS.addCfgValset(UBLOX_CFG_MSGOUT_RTCM_3X_TYPE1084_I2C, 1);
4961
response &= theGNSS.addCfgValset(UBLOX_CFG_MSGOUT_RTCM_3X_TYPE1094_I2C, 1);
5062
response &= theGNSS.addCfgValset(UBLOX_CFG_MSGOUT_RTCM_3X_TYPE1124_I2C, 1);
51-
response &= theGNSS.addCfgValset(UBLOX_CFG_MSGOUT_RTCM_3X_TYPE1230_I2C, 10); //Enable message every 10 seconds
63+
response &= theGNSS.addCfgValset(UBLOX_CFG_MSGOUT_RTCM_3X_TYPE1230_I2C, 10); //Enable message every 10 cycles - note: this may conflict with settings and setMessages?
5264

5365
response &= theGNSS.addCfgValset(UBLOX_CFG_MSGOUT_RTCM_3X_TYPE1005_UART1, 1);
5466
response &= theGNSS.addCfgValset(UBLOX_CFG_MSGOUT_RTCM_3X_TYPE1074_UART1, 1);
@@ -57,18 +69,36 @@ bool configureUbloxModuleBase()
5769
response &= theGNSS.addCfgValset(UBLOX_CFG_MSGOUT_RTCM_3X_TYPE1124_UART1, 1);
5870
response &= theGNSS.addCfgValset(UBLOX_CFG_MSGOUT_RTCM_3X_TYPE1230_UART1, 10);
5971
}
60-
else
72+
else // SPI GNSS
6173
{
6274
response &= theGNSS.addCfgValset(UBLOX_CFG_MSGOUT_RTCM_3X_TYPE1005_SPI, 1);
6375
response &= theGNSS.addCfgValset(UBLOX_CFG_MSGOUT_RTCM_3X_TYPE1074_SPI, 1);
6476
response &= theGNSS.addCfgValset(UBLOX_CFG_MSGOUT_RTCM_3X_TYPE1084_SPI, 1);
6577
response &= theGNSS.addCfgValset(UBLOX_CFG_MSGOUT_RTCM_3X_TYPE1094_SPI, 1);
6678
response &= theGNSS.addCfgValset(UBLOX_CFG_MSGOUT_RTCM_3X_TYPE1124_SPI, 1);
67-
response &= theGNSS.addCfgValset(UBLOX_CFG_MSGOUT_RTCM_3X_TYPE1230_SPI, 10); //Enable message every 10 seconds
68-
69-
// Enable logging of these messages so the RTCM will be stored automatically in the logging buffer
70-
theGNSS.setRTCMLoggingMask( SFE_UBLOX_FILTER_RTCM_TYPE1005 | SFE_UBLOX_FILTER_RTCM_TYPE1074 | SFE_UBLOX_FILTER_RTCM_TYPE1084
71-
| SFE_UBLOX_FILTER_RTCM_TYPE1094 | SFE_UBLOX_FILTER_RTCM_TYPE1124 | SFE_UBLOX_FILTER_RTCM_TYPE1230 );
79+
response &= theGNSS.addCfgValset(UBLOX_CFG_MSGOUT_RTCM_3X_TYPE1230_SPI, 10); //Enable message every 10 cycles - note: this may conflict with settings and setMessages?
80+
81+
// Enable logging of these messages so the RTCM will be stored automatically in the logging buffer.
82+
// This mimics the data arriving via UART1.
83+
uint32_t logRTCMMessages = theGNSS.getRTCMLoggingMask();
84+
logRTCMMessages |= ( SFE_UBLOX_FILTER_RTCM_TYPE1005 | SFE_UBLOX_FILTER_RTCM_TYPE1074 | SFE_UBLOX_FILTER_RTCM_TYPE1084
85+
| SFE_UBLOX_FILTER_RTCM_TYPE1094 | SFE_UBLOX_FILTER_RTCM_TYPE1124 | SFE_UBLOX_FILTER_RTCM_TYPE1230 );
86+
theGNSS.setRTCMLoggingMask(logRTCMMessages);
87+
log_d("setRTCMLoggingMask 0x%X", logRTCMMessages);
88+
89+
// Update settings, otherwise setMessages could disable these again...
90+
for (int x = 0; x < MAX_UBX_MSG; x++)
91+
{
92+
if (settings.ubxMessages[x].msgClass == UBX_RTCM_MSB) // RTCM messages
93+
{
94+
if (settings.ubxMessages[x].filterMask & // This is quicker than checking the msgID
95+
( SFE_UBLOX_FILTER_RTCM_TYPE1005 | SFE_UBLOX_FILTER_RTCM_TYPE1074 | SFE_UBLOX_FILTER_RTCM_TYPE1084
96+
| SFE_UBLOX_FILTER_RTCM_TYPE1094 | SFE_UBLOX_FILTER_RTCM_TYPE1124))
97+
settings.ubxMessages[x].msgRate = 1;
98+
if (settings.ubxMessages[x].filterMask & SFE_UBLOX_FILTER_RTCM_TYPE1230)
99+
settings.ubxMessages[x].msgRate = 10;
100+
}
101+
}
72102
}
73103

74104
response &= theGNSS.addCfgValset(UBLOX_CFG_MSGOUT_RTCM_3X_TYPE1005_USB, 1);

Firmware/RTK_Surveyor/Begin.ino

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,7 @@ void configureGNSS()
696696

697697
theGNSS.setAutoPVTcallbackPtr(&storePVTdata); // Enable automatic NAV PVT messages with callback to storePVTdata
698698
theGNSS.setAutoHPPOSLLHcallbackPtr(&storeHPdata); // Enable automatic NAV HPPOSLLH messages with callback to storeHPdata
699-
699+
700700
//Configuring the ZED can take more than 2000ms. We save configuration to
701701
//ZED so there is no need to update settings unless user has modified
702702
//the settings file or internal settings.
@@ -938,7 +938,9 @@ bool beginExternalTriggers()
938938
systemPrintln("beginExternalTriggers config failed");
939939

940940
if (settings.enableExternalHardwareEventLogging == true)
941+
{
941942
theGNSS.setAutoTIMTM2callbackPtr(&eventTriggerReceived); //Enable automatic TIM TM2 messages with callback to eventTriggerReceived
943+
}
942944
else
943945
theGNSS.setAutoTIMTM2callbackPtr(nullptr);
944946

Firmware/RTK_Surveyor/FileSdFatMMC.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class FileSdFatMMC : public SdFile
5252
else
5353
return _file;
5454
#endif
55+
return false; // Keep the compiler happy
5556
};
5657

5758
size_t println(const char printMe[])
@@ -62,6 +63,7 @@ class FileSdFatMMC : public SdFile
6263
else
6364
return _file->println(printMe);
6465
#endif
66+
return 0; // Keep the compiler happy
6567
};
6668

6769
bool open(const char *filepath, oflag_t mode)
@@ -86,6 +88,7 @@ class FileSdFatMMC : public SdFile
8688
return false;
8789
}
8890
#endif
91+
return false; // Keep the compiler happy
8992
};
9093

9194
uint32_t size()
@@ -96,6 +99,7 @@ class FileSdFatMMC : public SdFile
9699
else
97100
return _file->size();
98101
#endif
102+
return 0; // Keep the compiler happy
99103
};
100104

101105
uint32_t position()
@@ -106,6 +110,7 @@ class FileSdFatMMC : public SdFile
106110
else
107111
return _file->position();
108112
#endif
113+
return 0; // Keep the compiler happy
109114
};
110115

111116
int available()
@@ -116,7 +121,8 @@ class FileSdFatMMC : public SdFile
116121
else
117122
return _file->available();
118123
#endif
119-
};
124+
return 0; // Keep the compiler happy
125+
};
120126

121127
int read(uint8_t *buf, uint16_t nbyte)
122128
{
@@ -126,7 +132,8 @@ class FileSdFatMMC : public SdFile
126132
else
127133
return _file->read(buf, nbyte);
128134
#endif
129-
};
135+
return 0; // Keep the compiler happy
136+
};
130137

131138
size_t write(const uint8_t *buf, size_t size)
132139
{
@@ -136,6 +143,7 @@ class FileSdFatMMC : public SdFile
136143
else
137144
return _file->write(buf, size);
138145
#endif
146+
return 0; // Keep the compiler happy
139147
};
140148

141149
void close()

Firmware/RTK_Surveyor/Form.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ static void handleFirmwareFileDownload(AsyncWebServerRequest *request)
289289
logmessage += " deleted";
290290
if (USE_SPI_MICROSD)
291291
sd->remove(fileName);
292-
#ifdef COMPLIE_SD_MMC
292+
#ifdef COMPILE_SD_MMC
293293
else
294294
SD_MMC.remove(fileName);
295295
#endif

Firmware/RTK_Surveyor/Rover.ino

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,15 @@ bool configureUbloxModuleRover()
3333
response &= theGNSS.addCfgValset(UBLOX_CFG_NAVSPG_DYNMODEL, (dynModel)settings.dynamicModel); // Set dynamic model
3434

3535
//RTCM is only available on ZED-F9P modules
36+
//
37+
//For most RTK products, the GNSS is interfaced via both I2C and UART1. Configuration and PVT/HPPOS messages are
38+
//configured over I2C. Any messages that need to be logged are output on UART1, and received by this code using
39+
//serialGNSS. So in Rover mode, we want to disable any RTCM messages on I2C (and USB and UART2).
40+
//
41+
//But, on the Reference Station, the GNSS is interfaced via SPI. It has no access to I2C and UART1. So for that
42+
//product - in Rover mode - we want to leave any RTCM messages enabled on SPI so they can be logged if desired.
3643
if (zedModuleType == PLATFORM_F9P)
3744
{
38-
//Disable RTCM sentences from being generated on I2C, USB, and UART2. (Don't disable on UART1.)
3945
if (USE_I2C_GNSS)
4046
{
4147
response &= theGNSS.addCfgValset(UBLOX_CFG_MSGOUT_RTCM_3X_TYPE1005_I2C, 0);
@@ -45,15 +51,6 @@ bool configureUbloxModuleRover()
4551
response &= theGNSS.addCfgValset(UBLOX_CFG_MSGOUT_RTCM_3X_TYPE1124_I2C, 0);
4652
response &= theGNSS.addCfgValset(UBLOX_CFG_MSGOUT_RTCM_3X_TYPE1230_I2C, 0);
4753
}
48-
else
49-
{
50-
response &= theGNSS.addCfgValset(UBLOX_CFG_MSGOUT_RTCM_3X_TYPE1005_SPI, 0);
51-
response &= theGNSS.addCfgValset(UBLOX_CFG_MSGOUT_RTCM_3X_TYPE1074_SPI, 0);
52-
response &= theGNSS.addCfgValset(UBLOX_CFG_MSGOUT_RTCM_3X_TYPE1084_SPI, 0);
53-
response &= theGNSS.addCfgValset(UBLOX_CFG_MSGOUT_RTCM_3X_TYPE1094_SPI, 0);
54-
response &= theGNSS.addCfgValset(UBLOX_CFG_MSGOUT_RTCM_3X_TYPE1124_SPI, 0);
55-
response &= theGNSS.addCfgValset(UBLOX_CFG_MSGOUT_RTCM_3X_TYPE1230_SPI, 0);
56-
}
5754

5855
response &= theGNSS.addCfgValset(UBLOX_CFG_MSGOUT_RTCM_3X_TYPE1005_USB, 0);
5956
response &= theGNSS.addCfgValset(UBLOX_CFG_MSGOUT_RTCM_3X_TYPE1074_USB, 0);

Firmware/RTK_Surveyor/System.ino

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,9 @@ bool configureUbloxModule()
207207
log_d("Module config block 3 complete");
208208

209209
if (zedModuleType == PLATFORM_F9R)
210+
{
210211
response &= theGNSS.setAutoESFSTATUS(true, false); //Tell the GPS to "send" each ESF Status, but do not update stale data when accessed
212+
}
211213

212214
return (response);
213215
}
@@ -522,19 +524,39 @@ bool setMessages()
522524
do
523525
{
524526
if (settings.ubxMessages[x].supported & zedModuleType)
525-
response &= theGNSS.addCfgValset(settings.ubxMessages[x].msgConfigKey - spiOffset, settings.ubxMessages[x].msgRate);
527+
{
528+
uint8_t rate = settings.ubxMessages[x].msgRate;
529+
530+
// If the GNSS is SPI, we need to make sure that NAV_PVT, NAV_HPPOSLLH and ESF_STATUS remained enabled
531+
// (but not enabled for logging)
532+
if (USE_SPI_GNSS)
533+
{
534+
if (settings.ubxMessages[x].msgClass == UBX_CLASS_NAV)
535+
if ((settings.ubxMessages[x].msgID == UBX_NAV_PVT) || (settings.ubxMessages[x].msgID == UBX_NAV_HPPOSLLH))
536+
rate = 1;
537+
if (settings.ubxMessages[x].msgClass == UBX_CLASS_ESF)
538+
if (settings.ubxMessages[x].msgID == UBX_ESF_STATUS)
539+
if (zedModuleType == PLATFORM_F9R)
540+
rate = 1;
541+
if (settings.ubxMessages[x].msgClass == UBX_CLASS_TIM)
542+
if (settings.ubxMessages[x].msgID == UBX_TIM_TM2)
543+
rate = 1;
544+
}
545+
546+
response &= theGNSS.addCfgValset(settings.ubxMessages[x].msgConfigKey - spiOffset, rate);
547+
}
526548
x++;
527549
}
528-
while (((x % 40) < 39) && (x < MAX_UBX_MSG)); // Limit 1st batch to 39. Batches after that will be (up to) 40 in size.
550+
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.
529551

530552
response &= theGNSS.sendCfgValset();
531553
log_d("sent Valset for message %d", x);
532554
}
533555

534556
log_d("message config complete");
535557

536-
// settings.ubxMessages contains a mix or UBX, NMEA and RTCM messages
537558
// For SPI GNSS products, we need to add each message to the GNSS Library logging buffer
559+
// to mimic UART1
538560
if (USE_SPI_GNSS)
539561
{
540562
uint32_t logRTCMMessages = 0;
@@ -587,7 +609,7 @@ bool setMessagesUSB()
587609
response &= theGNSS.addCfgValset(settings.ubxMessages[x].msgConfigKey + 2, settings.ubxMessages[x].msgRate);
588610
x++;
589611
}
590-
while (((x % 40) < 39) && (x < MAX_UBX_MSG)); // Limit 1st batch to 39. Batches after that will be (up to) 40 in size.
612+
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.
591613

592614
response &= theGNSS.sendCfgValset();
593615
log_d("sent Valset for message %d", x);

Firmware/RTK_Surveyor/menuBase.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ bool removeFileSD(const char* fileName)
547547
removed = true;
548548
}
549549
}
550-
#ifdef COMPPILE_SD_MMC
550+
#ifdef COMPILE_SD_MMC
551551
else
552552
{
553553
if (SD_MMC.exists(fileName))

Firmware/RTK_Surveyor/settings.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ typedef enum
6060
} ProductVariant;
6161
ProductVariant productVariant = RTK_SURVEYOR;
6262

63+
// Macros which show if: the GNSS is I2C or SPI; the microSD is SPI or SDIO
6364
#define USE_SPI_GNSS ((productVariant & PRODUCT_HAS_SPI_GNSS) > 0)
6465
#define USE_I2C_GNSS (!USE_SPI_GNSS)
6566
#define USE_MMC_MICROSD ((productVariant & PRODUCT_HAS_MMC_MICROSD) > 0)

0 commit comments

Comments
 (0)