CommandStation-EX icon indicating copy to clipboard operation
CommandStation-EX copied to clipboard

Add a retry loop to Ethernet Connection

Open FrightRisk opened this issue 4 years ago • 0 comments

Using the ENC28J60 Ethernet board - cheap but works well once connected. One issue with this board is the time it takes to determine if "Ethernet cable is not connected". It was a 50/50 split on whether it would see the cable was connected or not. This lead me to believe that is may be a timing issue -- so I added a simple retry loop to see if this was the issue -- after adding loop I connect 100% of the time (so far).

PaulS added following in EthernetInterface.cpp just prior to check of linkStatus == LinkOFF on line 71 (or so).

long startmilli = millis(); while ((millis() - startmilli) < 5500) { DIAG(F("Ethernet.begin checking")); if (Ethernet.linkStatus() == LinkON) break;

DIAG(F("Ethernet.begin pausing"));
delay(1000);

}

FrightRisk avatar May 18 '21 23:05 FrightRisk