arduino_uip
arduino_uip copied to clipboard
read and readBytes have different returns value when there is no data
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.
Thanks.