Go Down

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


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:
   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:


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.


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!

via Egeo 16
Torino, 10131