Skip to content

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

Open
@Bascy

Description

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

Metadata

Assignees

No one assigned

    Labels

    topic: codeRelated to content of the project itselftype: imperfectionPerceived defect in any part of project

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions