Skip to content

Commit f679296

Browse files
authored
Merge pull request #629 from LeeLeahy2/rb-offset
Define type for the RING buffer offset
2 parents 19a6968 + a45c847 commit f679296

File tree

4 files changed

+17
-13
lines changed

4 files changed

+17
-13
lines changed

Firmware/RTK_Surveyor/PvtClient.ino

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,11 @@ const int pvtClientStateNameEntries = sizeof(pvtClientStateName) / sizeof(pvtCli
153153
static NetworkClient * pvtClient;
154154
static IPAddress pvtClientIpAddress;
155155
static uint8_t pvtClientState;
156-
static volatile uint16_t pvtClientTail;
156+
static volatile RING_BUFFER_OFFSET pvtClientTail;
157157
static volatile bool pvtClientWriteError;
158158

159159
//----------------------------------------
160-
// PVT Client Routines
160+
// PVT Client handleGnssDataTask Support Routines
161161
//----------------------------------------
162162

163163
// Send PVT data to the NMEA server
@@ -250,6 +250,10 @@ void pvtClientSetState(uint8_t newState)
250250
}
251251
}
252252

253+
//----------------------------------------
254+
// PVT Client Routines
255+
//----------------------------------------
256+
253257
// Start the PVT client
254258
bool pvtClientStart()
255259
{

Firmware/RTK_Surveyor/PvtServer.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ static volatile uint8_t pvtServerClientDataSent;
7474
static volatile uint8_t pvtServerClientWriteError;
7575
static NetworkClient * pvtServerClient[PVT_SERVER_MAX_CLIENTS];
7676
static IPAddress pvtServerClientIpAddress[PVT_SERVER_MAX_CLIENTS];
77-
static volatile uint16_t pvtServerClientTails[PVT_SERVER_MAX_CLIENTS];
77+
static volatile RING_BUFFER_OFFSET pvtServerClientTails[PVT_SERVER_MAX_CLIENTS];
7878

7979
//----------------------------------------
8080
// PVT Server handleGnssDataTask Support Routines

Firmware/RTK_Surveyor/Tasks.ino

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ const int ringBufferConsumerEntries = sizeof(ringBufferConsumer) / sizeof(ringBu
6262
// Locals
6363
//----------------------------------------
6464

65-
volatile static uint16_t dataHead; // Head advances as data comes in from GNSS's UART
65+
volatile static RING_BUFFER_OFFSET dataHead; // Head advances as data comes in from GNSS's UART
6666
volatile int32_t availableHandlerSpace; // settings.gnssHandlerBufferSize - usedSpace
6767
volatile const char *slowConsumer;
6868

@@ -339,12 +339,12 @@ void gnssReadTask(void *e)
339339
}
340340

341341
// Process a complete message incoming from parser
342-
// If we get a complete NMEA/UBX/RTCM sentence, pass on to SD/BT/TCP interfaces
342+
// If we get a complete NMEA/UBX/RTCM sentence, pass on to SD/BT/PVT interfaces
343343
void processUart1Message(PARSE_STATE *parse, uint8_t type)
344344
{
345345
int32_t bytesToCopy;
346346
const char *consumer;
347-
uint16_t remainingBytes;
347+
RING_BUFFER_OFFSET remainingBytes;
348348
int32_t space;
349349
int32_t use;
350350

@@ -424,7 +424,7 @@ void processUart1Message(PARSE_STATE *parse, uint8_t type)
424424
}
425425

426426
// If new data is in the ringBuffer, dole it out to appropriate interface
427-
// Send data out Bluetooth, record to SD, or send over TCP
427+
// Send data out Bluetooth, record to SD, or send to network clients
428428
// Each device (Bluetooth, SD and network client) gets its own tail. If the
429429
// device is running too slowly then data for that device is dropped.
430430
// The usedSpace variable tracks the total space in use in the buffer.
@@ -438,16 +438,14 @@ void handleGnssDataTask(void *e)
438438
uint32_t startMillis;
439439
int32_t usedSpace;
440440

441-
static uint16_t btTail; // BT Tail advances as it is sent over BT
442-
static uint16_t tcpTailEthernet; // TCP client tail
443-
static uint16_t sdTail; // SD Tail advances as it is recorded to SD
441+
static RING_BUFFER_OFFSET btTail; // BT Tail advances as it is sent over BT
442+
static RING_BUFFER_OFFSET sdTail; // SD Tail advances as it is recorded to SD
444443

445444
// Initialize the tails
446445
btTail = 0;
447446
pvtClientZeroTail();
448447
pvtServerZeroTail();
449448
sdTail = 0;
450-
tcpTailEthernet = 0;
451449

452450
while (true)
453451
{
@@ -530,7 +528,7 @@ void handleGnssDataTask(void *e)
530528
}
531529

532530
//----------------------------------------------------------------------
533-
// Send data to the WiFi TCP clients
531+
// Send data to the network clients
534532
//----------------------------------------------------------------------
535533

536534
startMillis = millis();
@@ -1377,7 +1375,7 @@ bool tasksStartUART2()
13771375
&gnssReadTaskHandle, // Task handle
13781376
settings.gnssReadTaskCore); // Core where task should run, 0=core, 1=Arduino
13791377

1380-
// Reads data from circular buffer and sends data to SD, SPP, or TCP
1378+
// Reads data from circular buffer and sends data to SD, SPP, or network clients
13811379
if (handleGnssDataTaskHandle == nullptr)
13821380
xTaskCreatePinnedToCore(handleGnssDataTask, // Function to call
13831381
"handleGNSSData", // Just for humans

Firmware/RTK_Surveyor/settings.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,8 @@ typedef struct WiFiNetwork
281281

282282
#define MAX_WIFI_NETWORKS 4
283283

284+
typedef uint16_t RING_BUFFER_OFFSET;
285+
284286
typedef struct _PARSE_STATE *P_PARSE_STATE;
285287

286288
// Parse routine

0 commit comments

Comments
 (0)