From dd309a3705dde6de86b9d1ed46b757c7ea27e0ad Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Fri, 4 Nov 2022 15:39:35 +0100 Subject: [PATCH] Ethernet init order --- EthernetInterface.cpp | 18 ++++++++++++++---- version.h | 3 ++- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/EthernetInterface.cpp b/EthernetInterface.cpp index ddc71be..fe780b7 100644 --- a/EthernetInterface.cpp +++ b/EthernetInterface.cpp @@ -36,11 +36,11 @@ EthernetInterface * EthernetInterface::singleton=NULL; */ void EthernetInterface::setup() { - if (Ethernet.hardwareStatus() == EthernetNoHardware) - DIAG(F("Ethernet shield not detected or is a W5100")); - if (singleton!=NULL) + if (singleton!=NULL) { DIAG(F("Prog Error!")); - if (singleton=new EthernetInterface()) + return; + } + if ((singleton=new EthernetInterface())) return; DIAG(F("Ethernet not initialized")); }; @@ -67,6 +67,16 @@ EthernetInterface::EthernetInterface() return; } #endif + if (Ethernet.hardwareStatus() == EthernetNoHardware) + DIAG(F("Ethernet shield not detected or is a W5100")); + + unsigned long startmilli = millis(); + while ((millis() - startmilli) < 5500) { // Loop to give time to check for cable connection + if (Ethernet.linkStatus() == LinkON) + break; + DIAG(F("Ethernet waiting for link (1sec) ")); + delay(1000); + } } /** diff --git a/version.h b/version.h index d821db0..4804870 100644 --- a/version.h +++ b/version.h @@ -3,7 +3,8 @@ #include "StringFormatter.h" -#define VERSION "4.1.2" +#define VERSION "4.1.3" +// 4.1.3 Bugfix: Ethernet init order // 4.1.2 Bugfix: Ethernet shield W5100 does not report HW or link level // 4.1.1 Bugfix: preserve turnout format // Bugfix: parse multiple commands in one buffer string correctly (ex: )