UIPEthernet: A plugin-replacement of the stock Arduino Ethernet library for ENC28J60 shields and breakout boards. Full support for persistent (streaming) TCP-connections and UDP (Client and Server each), ARP, ICMP, DHCP and DNS. Build around Adam Dunkels uIP Stack. Further developed version can be found on https://github.com/UIPEthernet/UIPEthernet
489
stars
212
forks
source link
read and readBytes have different returns value when there is no data #149
I have been integrating the library in a project that uses the readBytes function from a TCP Client. It was hard to find a problem related with the return value of readBytes, that seems to behave different than using the read function.
For example:
int read = client_.readBytes(buffer, size);
int read = client_.read(buffer, size);
Will return 1 and 0 respectively when trying to read a single byte from the card and there is no available data, as available() returns 0. I was expecting readBytes to return also 0, and no 1, as no data was read.
I have been trying to detect the problem in the code, but without luck. The function int UIPClient::read(uint8_t *buf, size_t size) is working fine as it is returning 0 bytes read both when calling readBytes or read, but there should be something more out there that is changing the value.
I have been integrating the library in a project that uses the
readBytes
function from a TCP Client. It was hard to find a problem related with the return value ofreadBytes
, that seems to behave different than using theread
function.For example:
Will return 1 and 0 respectively when trying to read a single byte from the card and there is no available data, as
available()
returns 0. I was expectingreadBytes
to return also 0, and no 1, as no data was read.I have been trying to detect the problem in the code, but without luck. The function
int UIPClient::read(uint8_t *buf, size_t size)
is working fine as it is returning 0 bytes read both when calling readBytes or read, but there should be something more out there that is changing the value.Thanks.