Go Down

Topic: Reducing W5100 module Ethernet Timeout when using DHCP? (Read 1 time) previous topic - next topic

billmit


I've read some bits on reducing Ethernet timeout in Arduino 1.0 using:

W5100.setRetransmissionTime(0x07D0);
W5100.setRetransmissionCount(3);

Unfortunately, this does not seem to work with Arduino 1.0 and a DHCP ethernet call like:

  if (Ethernet.begin(mac) == 0) {

Instead, with no Ethernet cable inserted in my RJ45 jack, I have to wait several mintues for a timeout....not good :D.
I've tracked through the Ethernet libs and it looks like I'm stuck in a loop inside of sendUDP (in socket.cpp) waiting for an OK or a TIMEOUT which, unfortunately, seems to take several minutes (!) when there's no ethernet connection.

The call trace from my Ethernet.begin look like:

w5100.setMACAddress()
w5100.setIPAddress()
dhcp.beginWithDHCP()
dhcpUpdSocket.begin()
send_DHCP_MESSAGE()
sendUDP()

(I've messed with the values passed for timeouts into beginWithDHCP too, to no avail)

How are others dealing with the apparent lack of functioning timeout on Ethernet.begin when using DHCP?   It would be very nice if there was some instant way to tell if, say, there's not Ethernet cable even inserted in the jack....

#1
Jan 28, 2013, 04:05 pm Last Edit: Jan 28, 2013, 04:18 pm by jstamour802 Reason: 1
I would like to bump this, because this is a big problem for me as well now.

For me, it takes between a minute and a minute and a half to timeout.

Essentially my code needs to work either direct connected to PC or through a switch, so I need the timeout to occur around 30 seconds or so to be reasonable.  


Edit: I think I solved it myself. Inside Dhcp.h, there is a response timeout constant of 60,000. I just changed it to 10,000 (10 seconds), and now timeout occurs about 12-13 seconds af
ter a reset.

public:
  IPAddress getLocalIp();
  IPAddress getSubnetMask();
  IPAddress getGatewayIp();
  IPAddress getDhcpServerIp();
  IPAddress getDnsServerIp();

  int beginWithDHCP(uint8_t *, unsigned long timeout = 10000, unsigned long responseTimeout = 4000);
};

Go Up