Go Down

Topic: sketch stays on Ethernet.begin when no ethernet connection (Read 501 times) previous topic - next topic

ScottG

I was trying out this Time NTP sketch: (http://arduino.cc/en/Tutorial/UdpNtpClient?action=sourceblock&num=1).   If the ethernet cable is not plugged in, my sketch stays on if (Ethernet.begin(mac) == 0) and never moves on.  I figured this would timeout after a while.
I have Arduino 1.01 with a Leonardo and Ethernet shield R3.

Code: [Select]

void setup()
{
// Open serial communications and wait for port to open:
  Serial.begin(9600);
   while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }
  // start Ethernet and UDP
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // no point in carrying on, so do nothing forevermore:
    for(;;)
      ;
  }
  Udp.begin(localPort);
}

SurferTim

Mine times out ok on a R2 ethernet shield and a Mega 2560. I disconnected the CAT5 and uploaded the sketch. It takes about a minute to print a fail. I checked with UdpNtpClient and DhcpAddressPrinter sketches.

edit: I removed the memory card from the microSD slot for both tests.

ScottG

I tried it again and it timed out after 62 seconds.  I guess I didn't wait long enough before.

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy