arduino-libraries / Ethernet

Ethernet Library for Arduino
http://arduino.cc/
258 stars 264 forks source link

Example sketches print incorrect message: "Ethernet cable is not connected" when there is no client #111

Open bkelly13 opened 5 years ago

bkelly13 commented 5 years ago

Arduino DUE, Arduino Ethernet Shield 2, IDE 1.8.8, windows 10

Application: Web Server from David A Mellis and Tom Igoe, The text of the code was copied from here:

https://www.arduino.cc/en/Tutorial/WebServer

This appears to be a problem with function Ethernet.linkStatus() returning an incorrect status. It declares that the Ethernet cable is not connected when it is.

I modified this app by putting code at the top of the loop to blink the LED_BUILTIN. It does blink and the rate can be easily changed. A solid indicator that the app is properly downloaded.

After a reset the serial port displays:

Ethernet cable is not connected.  

Setup:

My desktop and Arduino board are hard cabled to a D-Link switch. I have verified that the Ethernet cables and switch are working correctly.

I can reproduce the fault with multiple Arduino Due boards and multiple Ethernet shields.

A ping from my computer does not solicit a reply.

Connect serial monitor port and it displays:

(time)  Ethernet WebServer Exaple
(time) Ethernet cable is not connected
(time) server is at 192.168.1.177
(time) Exiting setup
per1234 commented 5 years ago

Quote from @bkelly13:

Problem found. The Arduino IP was 192.168.1.177 while the router was set to 192.168.0.1. Changed the Arduino to 192.168.0.177 at it began responding to the browser. That was easy. Once I knew what to change. Thank you for your time.

bkelly13 commented 5 years ago

Still a problem My original problem was, probably and still is, the network mask did not allow my computer to go from 192.168.0.177 to 192.168.1.177. Changing the IP address of the board corrected that problem. However, when the app is started this series of messages is displayed

15:12:38.453 -> Ethernet WebServer Example
15:12:38.996 -> Ethernet cable is not connected.
15:12:39.030 -> server is at 192.168.0.174
15:12:39.064 -> Exiting setup

But when Chrome is started and provided that address, the serial port lights up with

15:12:53.276 -> new client
15:12:53.276 -> GET / HTTP/1.1
15:12:53.309 -> Host: 192.168.0.174
15:12:53.342 -> Connection: keep-alive

… and more

And Chrome connects and displays the results expected.

The error message that the Ethernet cable is not connected is incorrect. There is no client but the cable is connected.

bkelly13 commented 5 years ago

Update. When everything is functional but Chrome (or probably any browser) has not accessed the Arduino, the serial monitor displayed the the following:

14:45:52.840 -> Ethernet WebServer Example
14:45:53.370 -> Ethernet cable is not connected.
14:45:53.410 -> server is at 192.168.0.173
14:45:53.450 -> Exiting setup

When the correct IP address was entered into Chrome, the connection was made and the serial port began displaying the expected messages.

The Ethernet handler/driver does not differentiate between the states of: No Ethernet Cable Connected and that of: No Client connected

The distinction is significant.

paolovr70 commented 4 years ago

Hi, I have the same ISSUE. With ARDUINO DUE, Ethernet Shield w5500. The Ethernet webserver example works BUT at setup I receive the message "the cable is not connected" (but again the server works). Any idea of what is the problem? tjanks. p.

yangxu1231 commented 12 months ago

I couldn't even change the ip no matter what static IP I set. It always prints "server is at 192.80.63.98", this is not even an illegal IP address. My god, could anyone figure this out!