From d06b06ac205b9fcac01fef57d3e48a43931bf711 Mon Sep 17 00:00:00 2001 From: Max Date: Thu, 11 Nov 2021 21:04:02 +0700 Subject: [PATCH] Fixed infinity loop I found some time flag away not send then loop is infinite, Fixed by add timer --- src/socket.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/socket.cpp b/src/socket.cpp index 7dc83feb..df49762f 100644 --- a/src/socket.cpp +++ b/src/socket.cpp @@ -513,10 +513,11 @@ bool EthernetClass::socketSendUDP(uint8_t s) { SPI.beginTransaction(SPI_ETHERNET_SETTINGS); W5100.execCmdSn(s, Sock_SEND); - + uint32_t startWait = millis(); + /* +2008.01 bj */ while ( (W5100.readSnIR(s) & SnIR::SEND_OK) != SnIR::SEND_OK ) { - if (W5100.readSnIR(s) & SnIR::TIMEOUT) { + if ((W5100.readSnIR(s) & SnIR::TIMEOUT) || ((millis() - startWait) > 1000)) { /* +2008.01 [bj]: clear interrupt */ W5100.writeSnIR(s, (SnIR::SEND_OK|SnIR::TIMEOUT)); SPI.endTransaction();