Skip to content

Commit ad2172b

Browse files
committed
Decrease serial buffer to match SPP buffer to prevent SPP congestion. Add delays to prio1 tasks for WDT pet.
1 parent fbea788 commit ad2172b

File tree

4 files changed

+17
-10
lines changed

4 files changed

+17
-10
lines changed

Firmware/RTK_Surveyor/Begin.ino

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ void startUART2Tasks()
236236
"F9Read", //Just for humans
237237
readTaskStackSize, //Stack Size
238238
NULL, //Task input parameter
239-
1, //Priority, with 3 (configMAX_PRIORITIES - 1) being the highest, and 0 being the lowest.
239+
F9PSerialReadTaskPriority, //Priority
240240
&F9PSerialReadTaskHandle); //Task handle
241241

242242
if (F9PSerialWriteTaskHandle == NULL)
@@ -245,7 +245,7 @@ void startUART2Tasks()
245245
"F9Write", //Just for humans
246246
writeTaskStackSize, //Stack Size
247247
NULL, //Task input parameter
248-
0, //Priority, with 3 (configMAX_PRIORITIES - 1) being the highest, and 0 being the lowest.
248+
F9PSerialWriteTaskPriority, //Priority
249249
&F9PSerialWriteTaskHandle); //Task handle
250250
}
251251

@@ -452,6 +452,6 @@ void beginSystemState()
452452
"BtnCheck", //Just for humans
453453
buttonTaskStackSize, //Stack Size
454454
NULL, //Task input parameter
455-
0, //Priority, with 3 (configMAX_PRIORITIES - 1) being the highest, and 0 being the lowest.
455+
ButtonCheckTaskPriority, //Priority, with 3 (configMAX_PRIORITIES - 1) being the highest, and 0 being the lowest.
456456
&ButtonCheckTaskHandle); //Task handle
457457
}

Firmware/RTK_Surveyor/RTK_Surveyor.ino

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@
4141
const int FIRMWARE_VERSION_MAJOR = 1;
4242
const int FIRMWARE_VERSION_MINOR = 5;
4343

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

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

219-
#define SERIAL_SIZE_RX 4096 //Reduced from 16384 to make room for WiFi/NTRIP server capabilities
219+
#define SERIAL_SIZE_RX (1024 * 2) //Should match buffer size in BluetoothSerial.cpp. Reduced from 16384 to make room for WiFi/NTRIP server capabilities
220220
uint8_t rBuffer[SERIAL_SIZE_RX]; //Buffer for reading from F9P to SPP
221221
uint8_t wBuffer[SERIAL_SIZE_RX]; //Buffer for writing from incoming SPP to F9P
222222
TaskHandle_t F9PSerialReadTaskHandle = NULL; //Store handles so that we can kill them if user goes into WiFi NTRIP Server mode
223223
TaskHandle_t F9PSerialWriteTaskHandle = NULL; //Store handles so that we can kill them if user goes into WiFi NTRIP Server mode
224+
const uint8_t F9PSerialWriteTaskPriority = 1; //Priority, with 3 being the highest, and 0 being the lowest.
225+
const uint8_t F9PSerialReadTaskPriority = 1;
224226

225227
TaskHandle_t pinUART2TaskHandle = NULL; //Dummy task to start UART2 on core 0.
226228
bool uart2pinned = false;
@@ -273,6 +275,7 @@ Button *setupBtn = NULL; //We can't instantiate the buttons here because we don'
273275
Button *powerBtn = NULL;
274276

275277
TaskHandle_t ButtonCheckTaskHandle = NULL;
278+
const uint8_t ButtonCheckTaskPriority = 1; //Priority, with 3 being the highest, and 0 being the lowest.
276279
const int buttonTaskStackSize = 2000;
277280

278281
const int shutDownButtonTime = 2000; //ms press and hold before shutdown

Firmware/RTK_Surveyor/Tasks.ino

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,13 @@ void F9PSerialWriteTask(void *e)
2828
Serial.printf("I heard: %c\n", incoming);
2929
incomingBTTest = incoming; //Displayed during system test
3030
}
31+
delay(1); //Poor man's way of feeding WDT. Required to prevent Priority 1 tasks from causing WDT reset
3132
taskYIELD();
3233
}
3334
}
3435
#endif
3536

37+
delay(1); //Poor man's way of feeding WDT. Required to prevent Priority 1 tasks from causing WDT reset
3638
taskYIELD();
3739
}
3840
}
@@ -116,10 +118,12 @@ void F9PSerialReadTask(void *e)
116118
} //End maxLogTime
117119
} //End logging
118120

121+
delay(1); //Poor man's way of feeding WDT. Required to prevent Priority 1 tasks from causing WDT reset
119122
taskYIELD();
120123

121124
} //End Serial.available()
122125

126+
delay(1); //Poor man's way of feeding WDT. Required to prevent Priority 1 tasks from causing WDT reset
123127
taskYIELD();
124128
}
125129
}
@@ -414,7 +418,7 @@ void ButtonCheckTask(void *e)
414418
}
415419
} //End Platform = RTK Facet
416420

417-
delay(1); //Yield to other tasks. Pet WDT.
421+
delay(1); //Poor man's way of feeding WDT. Required to prevent Priority 1 tasks from causing WDT reset
418422
taskYIELD();
419423
}
420424
}

Firmware/RTK_Surveyor/src/BluetoothSerial/BluetoothSerial.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,8 @@ static esp_err_t _spp_queue_packet(uint8_t *data, size_t len){
169169
//Above 50kbps it becomes unstable
170170

171171
//const uint16_t SPP_TX_MAX = 330; //Original
172-
const uint16_t SPP_TX_MAX = 512*4;
173-
static uint8_t _spp_tx_buffer[SPP_TX_MAX];
172+
const uint16_t SPP_TX_MAX = 1024*2; //Should match the SERIAL_SIZE_RX buffer size in RTK_Surveyor.ino
173+
static uint8_t _spp_tx_buffer[SPP_TX_MAX];
174174
static uint16_t _spp_tx_buffer_len = 0;
175175

176176
static bool _spp_send_buffer(){

0 commit comments

Comments
 (0)