mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-25 17:25:20 +03:00
Timeout to exit the new loop in case we can't find something to send. Should never happen, but better safe than sorry.
This commit is contained in:
parent
58973381c5
commit
c124398105
1 changed files with 9 additions and 0 deletions
|
@ -135,6 +135,7 @@ const uint16_t frSkyDataIdTable[] = {
|
||||||
#define __USE_C99_MATH // for roundf()
|
#define __USE_C99_MATH // for roundf()
|
||||||
#define SMARTPORT_BAUD 57600
|
#define SMARTPORT_BAUD 57600
|
||||||
#define SMARTPORT_UART_MODE MODE_RXTX
|
#define SMARTPORT_UART_MODE MODE_RXTX
|
||||||
|
#define SMARTPORT_SERVICE_TIMEOUT_MS 1 // max allowed time to find a value to send
|
||||||
#define SMARTPORT_NOT_CONNECTED_TIMEOUT_MS 7000
|
#define SMARTPORT_NOT_CONNECTED_TIMEOUT_MS 7000
|
||||||
|
|
||||||
static serialPort_t *smartPortSerialPort = NULL; // The 'SmartPort'(tm) Port.
|
static serialPort_t *smartPortSerialPort = NULL; // The 'SmartPort'(tm) Port.
|
||||||
|
@ -270,6 +271,8 @@ void checkSmartPortTelemetryState(void)
|
||||||
|
|
||||||
void handleSmartPortTelemetry(void)
|
void handleSmartPortTelemetry(void)
|
||||||
{
|
{
|
||||||
|
uint32_t smartPortLastServiceTime = millis();
|
||||||
|
|
||||||
if (!smartPortTelemetryEnabled) {
|
if (!smartPortTelemetryEnabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -292,6 +295,12 @@ void handleSmartPortTelemetry(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
while (smartPortHasRequest) {
|
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;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// we can send back any data we want, our table keeps track of the order and frequency of each data type we send
|
// 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];
|
uint16_t id = frSkyDataIdTable[smartPortIdCnt];
|
||||||
if (id == 0) { // end of table reached, loop back
|
if (id == 0) { // end of table reached, loop back
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue