Timeout for S.PORT Push to avoid it stays blocked undefinitely

This commit is contained in:
Bertrand Songis
2019-04-01 19:04:31 +02:00
parent a260a0eb4f
commit 5a4078331d
2 changed files with 14 additions and 0 deletions
+2
View File
@@ -183,6 +183,8 @@ void per10ms()
sdPoll10ms();
#endif
outputTelemetryBuffer.per10ms();
heartbeat |= HEART_TIMER_10MS;
}
+12
View File
@@ -176,11 +176,22 @@ class OutputTelemetryBuffer {
void setDestination(uint8_t value)
{
destination.value = value;
timeout = 200; /* 2s */
}
void per10ms()
{
if (timeout > 0) {
if (--timeout == 0)
reset();
}
}
void reset()
{
destination.value = TELEMETRY_ENDPOINT_NONE;
size = 0;
timeout = 0;
}
bool isAvailable()
@@ -224,6 +235,7 @@ class OutputTelemetryBuffer {
uint8_t data[16];
};
uint8_t size;
uint8_t timeout;
TelemetryEndpoint destination;
};