Hi all.
I'm doing a little project and i've found a few bugs/missing features in the ethernet library that comes with arduino 1.0
in some cases the library behavior don't match the documentation.
One example:
the function W5100Class::getRXReceivedSize is used internally by the various ethernet classes in the available() function to check how much data is waiting (if any).
this is what it looks like right now:
uint16_t W5100Class::getRXReceivedSize(SOCKET s)
{
uint16_t val=0,val1=0;
do {
val1 = readSnRX_RSR(s);
if (val1 != 0)
val = readSnRX_RSR(s);
}
while (val != val1);
return val;
}
as you can see there is an infinite loop until the register changes.
so instead of available() checking the current status it will actually wait until we get something.
this is a significant difference and means you can't use it to poll for data.
in my case i need to check if i get something and there is no guarantee i will get anything at all so blocking is very bad (program lockup).
another one is that Ethernet.begin() don't match the documentation and documentation
if you use the form:
Ethernet.begin(mac, ip, gateway) or
Ethernet.begin(mac, ip, gateway, subnet)
you will set your dns server to gateway and that may not necessarily be what you wanted and in the later one also set the your gateway to the netmask.
the relevant parts of the code is like this:
int begin(uint8_t *mac_address);
void begin(uint8_t *mac_address, IPAddress local_ip);
void begin(uint8_t *mac_address, IPAddress local_ip, IPAddress dns_server);
void begin(uint8_t *mac_address, IPAddress local_ip, IPAddress dns_server, IPAddress gateway);
void begin(uint8_t *mac_address, IPAddress local_ip, IPAddress dns_server, IPAddress gateway, IPAddress subnet);
personally i would have preferred if the dns was the last argument instead.
it would also have been nice if the dns parts was optional via either a define or some other way.
not all projects needs dns and in that case you don't need to waste code space for the dns class.