Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EthernetClass::socketRecvAvailable() is not updated when called multiple times #259

Open
Bascy opened this issue Apr 25, 2024 · 0 comments · May be fixed by #261
Open

EthernetClass::socketRecvAvailable() is not updated when called multiple times #259

Bascy opened this issue Apr 25, 2024 · 0 comments · May be fixed by #261
Labels
topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project

Comments

@Bascy
Copy link

Bascy commented Apr 25, 2024

When EthernetClass::socketRecvAvailable() is called multiple times, i.e. to wait for a minimum number of chars to reac, the returned number of recived bytes is not updated in between.

SSLClient (https://github.com/govorox/SSLClient.git) needs this in ssl__client.cpp, where in client_net_recv_timeout the process will wait until the expected number of bytes is received or a timeout is triggers.

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;
  }
  return ret;
}

This solves the problem I have with SSLClient

uint16_t EthernetClass::socketRecvAvailable(uint8_t s)
{
  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;
}
@I-Connect I-Connect linked a pull request Apr 27, 2024 that will close this issue
@per1234 per1234 added topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project labels Apr 27, 2024
@per1234 per1234 linked a pull request Apr 27, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants