Commit c1243981 authored by Andre Bernet's avatar Andre Bernet
Browse files

Timeout to exit the new loop in case we can't find something to send. Should...

Timeout to exit the new loop in case we can't find something to send. Should never happen, but better safe than sorry.
parent 58973381
......@@ -135,6 +135,7 @@ const uint16_t frSkyDataIdTable[] = {
#define __USE_C99_MATH // for roundf()
#define SMARTPORT_BAUD 57600
#define SMARTPORT_SERVICE_TIMEOUT_MS 1 // max allowed time to find a value to send
static serialPort_t *smartPortSerialPort = NULL; // The 'SmartPort'(tm) Port.
......@@ -270,6 +271,8 @@ void checkSmartPortTelemetryState(void)
void handleSmartPortTelemetry(void)
uint32_t smartPortLastServiceTime = millis();
if (!smartPortTelemetryEnabled) {
......@@ -292,6 +295,12 @@ void handleSmartPortTelemetry(void)
while (smartPortHasRequest) {
// Ensure we won't get stuck in the loop if there happens to be nothing available to send in a timely manner - dump the slot if we loop in there for too long.
if ((millis() - smartPortLastServiceTime) > SMARTPORT_SERVICE_TIMEOUT_MS) {
smartPortHasRequest = 0;
// we can send back any data we want, our table keeps track of the order and frequency of each data type we send
uint16_t id = frSkyDataIdTable[smartPortIdCnt];
if (id == 0) { // end of table reached, loop back
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment