Skip to content

Commit 0b9a7f1

Browse files
committed
Logging: unique semaphore wait, reduce loop delay, add taskYIELD
1 parent b3e2a50 commit 0b9a7f1

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

Firmware/RTK_Surveyor/RTK_Surveyor.ino

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ int startCurrentLogTime_minutes = 0; //Mark when we start this specific log file
125125
//System crashes if two tasks access a file at the same time
126126
//So we use a semaphore to see if file system is available
127127
SemaphoreHandle_t sdCardSemaphore;
128-
TickType_t fatSemaphore_shortWait_ms = 50 / portTICK_PERIOD_MS;
128+
TickType_t loggingSemaphore_shortWait_ms = 10 / portTICK_PERIOD_MS;
129+
const TickType_t fatSemaphore_shortWait_ms = 10 / portTICK_PERIOD_MS;
129130
const TickType_t fatSemaphore_longWait_ms = 200 / portTICK_PERIOD_MS;
130131

131132
//Display used/free space in menu and config page

Firmware/RTK_Surveyor/Tasks.ino

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ void F9PSerialReadTask(void *e)
203203
{
204204
//Attempt to gain access to the SD card, avoids collisions with file
205205
//writing from other functions like recordSystemSettingsToFile()
206-
if (xSemaphoreTake(sdCardSemaphore, fatSemaphore_shortWait_ms) == pdPASS)
206+
if (xSemaphoreTake(sdCardSemaphore, loggingSemaphore_shortWait_ms) == pdPASS)
207207
{
208208
//Reduce bytes to send if we have more to send then the end of the buffer
209209
//We'll wrap next loop
@@ -240,7 +240,8 @@ void F9PSerialReadTask(void *e)
240240
//Let other tasks run, prevent watch dog timer (WDT) resets
241241
//----------------------------------------------------------------------
242242

243-
delay(10);
243+
delay(1);
244+
taskYIELD();
244245
}
245246
}
246247

Firmware/RTK_Surveyor/menuMessages.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -819,7 +819,7 @@ void updateLogTest()
819819
{
820820
setLogTestFrequencyMessages(rate, messages); //Set messages and rate for both UART1 and USB ports
821821

822-
fatSemaphore_shortWait_ms = semaphoreWait / portTICK_PERIOD_MS; //Update variable
822+
loggingSemaphore_shortWait_ms = semaphoreWait / portTICK_PERIOD_MS; //Update variable
823823

824824
startCurrentLogTime_minutes = millis() / 1000L / 60; //Mark now as start of logging
825825

0 commit comments

Comments
 (0)