Go Down

Topic: Ethernet cleint println() makes new packet every time (Read 2847 times) previous topic - next topic

dhunt

I think you should have success if you keep exploring the option to avoid the "while (readSnCR(s));" statement.

I found the RTR and RCR registers in the wiznet w5100 datasheet.  You can download a copy from here (sparkfun) or from the wiznet website.

mishoboss

#31
Aug 03, 2011, 02:48 pm Last Edit: Aug 03, 2011, 02:50 pm by mishoboss Reason: 1
SOLVED!

In the w5100.h there are two methods:

Code: [Select]
void W5100Class::setRetransmissionTime(uint16_t _timeout) {
 writeRTR(_timeout);
}

void W5100Class::setRetransmissionCount(uint8_t _retry) {
 writeRCR(_retry);
}


They are not used anywhere in the Ethernet library, so these get some default values. If you want to change these settings, just modify the begin() function in Ethernet.cpp to:

Code: [Select]
void EthernetClass::begin(uint8_t *mac, uint8_t *ip, uint8_t *gateway, uint8_t *subnet)
{
 W5100.init();
 W5100.setMACAddress(mac);
 W5100.setIPAddress(ip);
 W5100.setGatewayIp(gateway);
 W5100.setSubnetMask(subnet);
// Add the following two lines:
 W5100.setRetransmissionTime(50); // in milliseconds, 50 is a good value
 W5100.setRetransmissionCount(1); // tries just once
}


Now my Arduino freezes just for 50 millis every 12 seconds, which is acceptable.

Thank you, dhunt for pointing me in the right direction!

PaulS

It would be nice to see this added to the official version of the library, with default arguments for the begin method, so that a user could override the default values if desired.

Go Up