Skip to content

Commit 1d0be78

Browse files
author
Veijo Pesonen
committed
Reduces OOB processing when flow control enabled and processing UDP packets
1 parent f508b55 commit 1d0be78

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

ESP8266/ESP8266.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -644,8 +644,9 @@ int32_t ESP8266::recv_udp(int id, void *data, uint32_t amount, uint32_t timeout)
644644
_smutex.lock();
645645
setTimeout(timeout);
646646

647-
// Poll for inbound packets
648-
while (_parser.process_oob()) {
647+
// No flow control, drain the USART receive register ASAP to avoid data overrun
648+
if (_serial_rts == NC) {
649+
process_oob(timeout, true);
649650
}
650651

651652
setTimeout();
@@ -671,6 +672,12 @@ int32_t ESP8266::recv_udp(int id, void *data, uint32_t amount, uint32_t timeout)
671672
return len;
672673
}
673674
}
675+
676+
// Flow control, read from USART receive register only when no more data is buffered, and as little as possible
677+
if (_serial_rts != NC) {
678+
process_oob(timeout, false);
679+
}
680+
674681
_smutex.unlock();
675682

676683
return NSAPI_ERROR_WOULD_BLOCK;

0 commit comments

Comments
 (0)