Skip to content

Commit

Permalink
Reduces OOB processing when flow control enabled and processing UDP p…
Browse files Browse the repository at this point in the history
…ackets
  • Loading branch information
Veijo Pesonen committed Sep 17, 2018
1 parent f508b55 commit 1d0be78
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions ESP8266/ESP8266.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -644,8 +644,9 @@ int32_t ESP8266::recv_udp(int id, void *data, uint32_t amount, uint32_t timeout)
_smutex.lock();
setTimeout(timeout);

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

setTimeout();
Expand All @@ -671,6 +672,12 @@ int32_t ESP8266::recv_udp(int id, void *data, uint32_t amount, uint32_t timeout)
return len;
}
}

// Flow control, read from USART receive register only when no more data is buffered, and as little as possible
if (_serial_rts != NC) {
process_oob(timeout, false);
}

_smutex.unlock();

return NSAPI_ERROR_WOULD_BLOCK;
Expand Down

0 comments on commit 1d0be78

Please sign in to comment.