Skip to content

Commit d06b06a

Browse files
authored
Fixed infinity loop
I found some time flag away not send then loop is infinite, Fixed by add timer
1 parent 5cdcdbc commit d06b06a

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/socket.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -513,10 +513,11 @@ bool EthernetClass::socketSendUDP(uint8_t s)
513513
{
514514
SPI.beginTransaction(SPI_ETHERNET_SETTINGS);
515515
W5100.execCmdSn(s, Sock_SEND);
516-
516+
uint32_t startWait = millis();
517+
517518
/* +2008.01 bj */
518519
while ( (W5100.readSnIR(s) & SnIR::SEND_OK) != SnIR::SEND_OK ) {
519-
if (W5100.readSnIR(s) & SnIR::TIMEOUT) {
520+
if ((W5100.readSnIR(s) & SnIR::TIMEOUT) || ((millis() - startWait) > 1000)) {
520521
/* +2008.01 [bj]: clear interrupt */
521522
W5100.writeSnIR(s, (SnIR::SEND_OK|SnIR::TIMEOUT));
522523
SPI.endTransaction();

0 commit comments

Comments
 (0)