Pages: [1]   Go Down
Author Topic: Reducing W5100 module Ethernet Timeout when using DHCP?  (Read 1268 times)
0 Members and 1 Guest are viewing this topic.
Seattle Area
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


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 smiley-grin.
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....
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 21
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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);
};
« Last Edit: January 28, 2013, 10:18:19 am by jstamour802 » Logged

Pages: [1]   Go Up
Jump to: