Ethernet
Ethernet copied to clipboard
w5100 buffer overflow
From @WildOrangutan on May 14, 2015 22:49
Hi! Please implement something like this, to avoid w5100 buffer overflow, when constantly sending data as fast as possible:
int EthernetClient::free() {
if (_sock != MAX_SOCK_NUM)
return W5100.getTXFreeSize(_sock);
return 0;
}
And then use it in examples like this:
while (file.available() > 0) {
if (client.free() > 0) { // This was key to solving the issue
c = file.read();
client.print((char)c);
} else { // No free buffer? Ok, I'll wait a couple of millis...
delay(1);
}
}
file.close();
Source: http://www.toptal.com/c/how-i-made-a-fully-functional-arduino-weather-station-for-300
Copied from original issue: arduino/Arduino#3144