1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-12-23 21:01:25 +01:00

try to recover from ringbuffer read problem

This commit is contained in:
Harald Barth 2022-08-06 19:07:35 +02:00
parent 42c35a11e1
commit 803db81c8f

View File

@ -236,6 +236,17 @@ void WifiESP::loop() {
if (clientId >= 0) {
if ((unsigned int)clientId > clients.size()) {
// something is wrong with the ringbuffer position
// or client has disconnected
outboundRing->info();
// try to recover by reading out to nowhere
int count=outboundRing->count();
for(int i=0;i<count;i++) {
int c = outboundRing->read();
if (c < 0) {
DIAG(F("Ringread fail at %d"),i);
break;
}
}
outboundRing->info();
} else {
// we have data to send in outboundRing