Skip to content

Commit fb16908

Browse files
committed
Remove SD sync from write task. Increase RX buffer to 4k. Increase equiv buffer in SPP library.
1 parent d30036a commit fb16908

File tree

3 files changed

+38
-30
lines changed

3 files changed

+38
-30
lines changed

Firmware/RTK_Surveyor/RTK_Surveyor.ino

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const int FIRMWARE_VERSION_MINOR = 8;
4646

4747
#define COMPILE_WIFI //Comment out to remove all WiFi functionality
4848
#define COMPILE_BT //Comment out to disable all Bluetooth
49-
//#define ENABLE_DEVELOPER //Uncomment this line to enable special developer modes (don't check power button at startup)
49+
#define ENABLE_DEVELOPER //Uncomment this line to enable special developer modes (don't check power button at startup)
5050

5151
//Define the RTK board identifier:
5252
// This is an int which is unique to this variant of the RTK Surveyor hardware which allows us
@@ -215,13 +215,15 @@ HardwareSerial serialGNSS(2);
215215
#define RXD2 16
216216
#define TXD2 17
217217

218-
#define SERIAL_SIZE_RX (1024 * 2) //Should match buffer size in BluetoothSerial.cpp. Reduced from 16384 to make room for WiFi/NTRIP server capabilities
218+
#define SERIAL_SIZE_RX (1024 * 4) //Should match buffer size in BluetoothSerial.cpp. Reduced from 16384 to make room for WiFi/NTRIP server capabilities
219219
uint8_t rBuffer[SERIAL_SIZE_RX]; //Buffer for reading from F9P to SPP
220-
uint8_t wBuffer[SERIAL_SIZE_RX]; //Buffer for writing from incoming SPP to F9P
221220
TaskHandle_t F9PSerialReadTaskHandle = NULL; //Store handles so that we can kill them if user goes into WiFi NTRIP Server mode
221+
const uint8_t F9PSerialReadTaskPriority = 1; //3 being the highest, and 0 being the lowest
222+
223+
#define SERIAL_SIZE_TX (1024 * 2)
224+
uint8_t wBuffer[SERIAL_SIZE_TX]; //Buffer for writing from incoming SPP to F9P
222225
TaskHandle_t F9PSerialWriteTaskHandle = NULL; //Store handles so that we can kill them if user goes into WiFi NTRIP Server mode
223226
const uint8_t F9PSerialWriteTaskPriority = 1; //3 being the highest, and 0 being the lowest
224-
const uint8_t F9PSerialReadTaskPriority = 1;
225227

226228
TaskHandle_t pinUART2TaskHandle = NULL; //Dummy task to start UART2 on core 0.
227229
volatile bool uart2pinned = false; //This variable is touched by core 0 but checked by core 1. Must be volatile.
@@ -438,9 +440,36 @@ void updateLogs()
438440
}
439441
}
440442

441-
//Report file sizes to show recording is working
442443
if (online.logging == true)
443444
{
445+
//Force file sync every 5000ms
446+
if (millis() - lastUBXLogSyncTime > 5000)
447+
{
448+
if (xSemaphoreTake(xFATSemaphore, fatSemaphore_shortWait_ms) == pdPASS)
449+
{
450+
if (productVariant == RTK_SURVEYOR)
451+
digitalWrite(pin_baseStatusLED, !digitalRead(pin_baseStatusLED)); //Blink LED to indicate logging activity
452+
453+
long startWriteTime = micros();
454+
ubxFile.sync();
455+
long stopWriteTime = micros();
456+
totalWriteTime += stopWriteTime - startWriteTime; //Used to calculate overall write speed
457+
458+
if (productVariant == RTK_SURVEYOR)
459+
digitalWrite(pin_baseStatusLED, !digitalRead(pin_baseStatusLED)); //Return LED to previous state
460+
461+
updateDataFileAccess(&ubxFile); // Update the file access time & date
462+
463+
lastUBXLogSyncTime = millis();
464+
xSemaphoreGive(xFATSemaphore);
465+
} //End xFATSemaphore
466+
else
467+
{
468+
log_d("Semaphore failed to yield");
469+
}
470+
}
471+
472+
//Report file sizes to show recording is working
444473
if (millis() - lastFileReport > 5000)
445474
{
446475
long fileSize = 0;

Firmware/RTK_Surveyor/Tasks.ino

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ void F9PSerialWriteTask(void *e)
1616
if (inTestMode == false)
1717
{
1818
//Pass bytes to GNSS receiver
19-
auto s = SerialBT.readBytes(wBuffer, SERIAL_SIZE_RX);
19+
auto s = SerialBT.readBytes(wBuffer, sizeof(wBuffer));
2020
serialGNSS.write(wBuffer, s);
2121

2222
if (settings.enableTaskReports == true)
@@ -47,7 +47,7 @@ void F9PSerialReadTask(void *e)
4747
{
4848
while (serialGNSS.available())
4949
{
50-
auto s = serialGNSS.readBytes(rBuffer, SERIAL_SIZE_RX);
50+
auto s = serialGNSS.readBytes(rBuffer, sizeof(rBuffer));
5151

5252
//If we are actively survey-in then do not pass NMEA data from ZED to phone
5353
if (systemState == STATE_BASE_TEMP_SETTLE || systemState == STATE_BASE_TEMP_SURVEY_STARTED)
@@ -88,32 +88,11 @@ void F9PSerialReadTask(void *e)
8888
{
8989
ubxFile.write(rBuffer, s);
9090

91-
//Force file sync every 5000ms
92-
if (millis() - lastUBXLogSyncTime > 5000)
93-
{
94-
if (productVariant == RTK_SURVEYOR)
95-
digitalWrite(pin_baseStatusLED, !digitalRead(pin_baseStatusLED)); //Blink LED to indicate logging activity
96-
97-
long startWriteTime = micros();
98-
taskYIELD();
99-
ubxFile.sync();
100-
taskYIELD();
101-
long stopWriteTime = micros();
102-
totalWriteTime += stopWriteTime - startWriteTime; //Used to calculate overall write speed
103-
104-
if (productVariant == RTK_SURVEYOR)
105-
digitalWrite(pin_baseStatusLED, !digitalRead(pin_baseStatusLED)); //Return LED to previous state
106-
107-
updateDataFileAccess(&ubxFile); // Update the file access time & date
108-
109-
lastUBXLogSyncTime = millis();
110-
}
111-
11291
xSemaphoreGive(xFATSemaphore);
11392
} //End xFATSemaphore
11493
else
11594
{
116-
log_d("F9SerialRead: Semaphore failed to yield");
95+
log_d("Semaphore failed to yield");
11796
}
11897
} //End maxLogTime
11998
} //End logging

Firmware/RTK_Surveyor/src/BluetoothSerial/BluetoothSerial.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ static esp_err_t _spp_queue_packet(uint8_t *data, size_t len){
178178
//Above 50kbps it becomes unstable
179179

180180
//const uint16_t SPP_TX_MAX = 330; //Original
181-
const uint16_t SPP_TX_MAX = 1024*2; //Should match the SERIAL_SIZE_RX buffer size in RTK_Surveyor.ino
181+
const uint16_t SPP_TX_MAX = 1024*4; //Should match the SERIAL_SIZE_RX buffer size in RTK_Surveyor.ino
182182
static uint8_t _spp_tx_buffer[SPP_TX_MAX];
183183
static uint16_t _spp_tx_buffer_len = 0;
184184

0 commit comments

Comments
 (0)