Skip to content

Commit 644847b

Browse files
committed
Restructure NTRIP_SERVER_DATA - make the struct contents volatile
1 parent 8443240 commit 644847b

File tree

2 files changed

+24
-24
lines changed

2 files changed

+24
-24
lines changed

Firmware/RTK_Everywhere/NtripServer.ino

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ const RtkMode_t ntripServerMode = RTK_MODE_BASE_FIXED;
173173
//----------------------------------------
174174

175175
// NTRIP Servers
176-
volatile static NTRIP_SERVER_DATA ntripServerArray[NTRIP_SERVER_MAX];
176+
static NTRIP_SERVER_DATA ntripServerArray[NTRIP_SERVER_MAX];
177177

178178
//----------------------------------------
179179
// NTRIP Server Routines
@@ -184,7 +184,7 @@ volatile static NTRIP_SERVER_DATA ntripServerArray[NTRIP_SERVER_MAX];
184184
//----------------------------------------
185185
bool ntripServerConnectCaster(int serverIndex)
186186
{
187-
volatile NTRIP_SERVER_DATA *ntripServer = &ntripServerArray[serverIndex];
187+
NTRIP_SERVER_DATA *ntripServer = &ntripServerArray[serverIndex];
188188
const int SERVER_BUFFER_SIZE = 512;
189189
char serverBuffer[SERVER_BUFFER_SIZE];
190190

@@ -239,7 +239,7 @@ bool ntripServerConnectLimitReached(int serverIndex)
239239
{
240240
bool limitReached;
241241
int minutes;
242-
volatile NTRIP_SERVER_DATA *ntripServer = &ntripServerArray[serverIndex];
242+
NTRIP_SERVER_DATA *ntripServer = &ntripServerArray[serverIndex];
243243
int seconds;
244244

245245
// Retry the connection a few times
@@ -311,9 +311,9 @@ bool ntripServerEnabled(int serverIndex, const char ** line)
311311
{
312312
if (line)
313313
{
314-
if (settings.ntripServer_CasterHost[0] == 0)
314+
if (settings.ntripServer_CasterHost[serverIndex][0] == 0)
315315
*line = ", Caster host not specified!";
316-
else if (settings.ntripServer_CasterPort == 0)
316+
else if (settings.ntripServer_CasterPort[serverIndex] == 0)
317317
*line = ", Caster port not specified!";
318318
else
319319
*line = ", Mount point not specified!";
@@ -334,7 +334,7 @@ bool ntripServerEnabled(int serverIndex, const char ** line)
334334
//----------------------------------------
335335
void ntripServerPrintStateSummary(int serverIndex)
336336
{
337-
volatile NTRIP_SERVER_DATA *ntripServer = &ntripServerArray[serverIndex];
337+
NTRIP_SERVER_DATA *ntripServer = &ntripServerArray[serverIndex];
338338

339339
switch (ntripServer->state)
340340
{
@@ -362,7 +362,7 @@ void ntripServerPrintStateSummary(int serverIndex)
362362
//----------------------------------------
363363
void ntripServerPrintStatus(int serverIndex)
364364
{
365-
volatile NTRIP_SERVER_DATA *ntripServer = &ntripServerArray[serverIndex];
365+
NTRIP_SERVER_DATA *ntripServer = &ntripServerArray[serverIndex];
366366
uint64_t milliseconds;
367367
uint32_t days;
368368
byte hours;
@@ -410,7 +410,7 @@ void ntripServerPrintStatus(int serverIndex)
410410
//----------------------------------------
411411
void ntripServerProcessRTCM(int serverIndex, uint8_t incoming)
412412
{
413-
volatile NTRIP_SERVER_DATA *ntripServer = &ntripServerArray[serverIndex];
413+
NTRIP_SERVER_DATA *ntripServer = &ntripServerArray[serverIndex];
414414

415415
if (ntripServer->state == NTRIP_SERVER_CASTING)
416416
{
@@ -464,7 +464,7 @@ void ntripServerProcessRTCM(int serverIndex, uint8_t incoming)
464464
//----------------------------------------
465465
void ntripServerResponse(int serverIndex, char *response, size_t maxLength)
466466
{
467-
volatile NTRIP_SERVER_DATA *ntripServer = &ntripServerArray[serverIndex];
467+
NTRIP_SERVER_DATA *ntripServer = &ntripServerArray[serverIndex];
468468
char *responseEnd;
469469

470470
// Make sure that we can zero terminate the response
@@ -483,7 +483,7 @@ void ntripServerResponse(int serverIndex, char *response, size_t maxLength)
483483
//----------------------------------------
484484
void ntripServerRestart(int serverIndex)
485485
{
486-
volatile NTRIP_SERVER_DATA *ntripServer = &ntripServerArray[serverIndex];
486+
NTRIP_SERVER_DATA *ntripServer = &ntripServerArray[serverIndex];
487487

488488
// Save the previous uptime value
489489
if (ntripServer->state == NTRIP_SERVER_CASTING)
@@ -496,7 +496,7 @@ void ntripServerRestart(int serverIndex)
496496
//----------------------------------------
497497
void ntripServerSetState(int serverIndex, uint8_t newState)
498498
{
499-
volatile NTRIP_SERVER_DATA * ntripServer;
499+
NTRIP_SERVER_DATA * ntripServer;
500500

501501
ntripServer = &ntripServerArray[serverIndex];
502502
if (settings.debugNtripServerState)
@@ -548,7 +548,7 @@ void ntripServerStop(int serverIndex, bool shutdown)
548548
{
549549
bool enabled;
550550
int index;
551-
volatile NTRIP_SERVER_DATA *ntripServer = &ntripServerArray[serverIndex];
551+
NTRIP_SERVER_DATA *ntripServer = &ntripServerArray[serverIndex];
552552

553553
if (ntripServer->networkClient)
554554
{
@@ -612,7 +612,7 @@ void ntripServerUpdate(int serverIndex)
612612
const char * line = "";
613613

614614
// Get the NTRIP data structure
615-
volatile NTRIP_SERVER_DATA *ntripServer = &ntripServerArray[serverIndex];
615+
NTRIP_SERVER_DATA *ntripServer = &ntripServerArray[serverIndex];
616616

617617
// Shutdown the NTRIP server when the mode or setting changes
618618
DMW_if

Firmware/RTK_Everywhere/settings.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -385,34 +385,34 @@ enum PeriodDisplayValues
385385

386386
#ifdef COMPILE_NETWORK
387387

388-
// NTRIP Server data - the array is declared volatile in NtripServer.ino
388+
// NTRIP Server data
389389
typedef struct
390390
{
391391
// Network connection used to push RTCM to NTRIP caster
392392
NetworkClient *networkClient;
393-
uint8_t state;
393+
volatile uint8_t state;
394394

395395
// Count of bytes sent by the NTRIP server to the NTRIP caster
396-
uint32_t bytesSent;
396+
volatile uint32_t bytesSent;
397397

398398
// Throttle the time between connection attempts
399399
// ms - Max of 4,294,967,295 or 4.3M seconds or 71,000 minutes or 1193 hours or 49 days between attempts
400-
uint32_t connectionAttemptTimeout;
401-
uint32_t lastConnectionAttempt;
402-
int connectionAttempts; // Count the number of connection attempts between restarts
400+
volatile uint32_t connectionAttemptTimeout;
401+
volatile uint32_t lastConnectionAttempt;
402+
volatile int connectionAttempts; // Count the number of connection attempts between restarts
403403

404404
// NTRIP server timer usage:
405405
// * Reconnection delay
406406
// * Measure the connection response time
407407
// * Receive RTCM correction data timeout
408408
// * Monitor last RTCM byte received for frame counting
409-
uint32_t timer;
410-
uint32_t startTime;
411-
int connectionAttemptsTotal; // Count the number of connection attempts absolutely
409+
volatile uint32_t timer;
410+
volatile uint32_t startTime;
411+
volatile int connectionAttemptsTotal; // Count the number of connection attempts absolutely
412412

413413
// Better debug printing by ntripServerProcessRTCM
414-
uint32_t rtcmBytesSent;
415-
uint32_t previousMilliseconds;
414+
volatile uint32_t rtcmBytesSent;
415+
volatile uint32_t previousMilliseconds;
416416
} NTRIP_SERVER_DATA;
417417

418418
#endif // COMPILE_NETWORK

0 commit comments

Comments
 (0)