Skip to content

Commit

Permalink
Always update socketRecAvailable when called
Browse files Browse the repository at this point in the history
  • Loading branch information
I-Connect committed Apr 27, 2024
1 parent 78aeaf5 commit b8828d5
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions src/socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,16 +349,11 @@ int EthernetClass::socketRecv(uint8_t s, uint8_t *buf, int16_t len)

uint16_t EthernetClass::socketRecvAvailable(uint8_t s)
{
uint16_t ret = state[s].RX_RSR;
if (ret == 0) {
SPI.beginTransaction(SPI_ETHERNET_SETTINGS);
uint16_t rsr = getSnRX_RSR(s);
SPI.endTransaction();
ret = rsr - state[s].RX_inc;
state[s].RX_RSR = ret;
//Serial.printf("sockRecvAvailable s=%d, RX_RSR=%d\n", s, ret);
}
return ret;
SPI.beginTransaction(SPI_ETHERNET_SETTINGS);
uint16_t rsr = getSnRX_RSR(s);
SPI.endTransaction();
state[s].RX_RSR = rsr - state[s].RX_inc;
return state[s].RX_RSR;
}

// get the first byte in the receive queue (no checking)
Expand Down

0 comments on commit b8828d5

Please sign in to comment.