Teensy 4.1 Network not responding over time

roni.fli

New member
Connecting two sockets to Teensy 4.1 , all works well but after a few hours
the Teensy does not respond to Ethernet , neither can reconnect.
Serial output still works,
Teensy is alive , and when resetting Or reprogramming then connection can be established again.
We try to use the Teensy to replace all of our IO controllers and stability is priority #1

EthernetServer server(50001);
EthernetServer respondEth(50002);

bool Net_Connected = false;


IPAddress Net_IP()
{
return Ethernet.localIP();
}

String toString(const IPAddress& address) {
return String() + address[0] + "." + address[1] + "." + address[2] + "." + address[3];
}


bool Net_init(IPAddress ip)
{
Serial.println("Waiting for Network...");
delay(1000);
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress subnet(255, 255, 0, 0);
IPAddress dns(0, 0, 0, 0);

if (ip[0] == 0)
Ethernet.begin(mac); //DHCP
else
Ethernet.begin(mac, ip, dns, dns, subnet);
if (Ethernet.hardwareStatus() == EthernetNoHardware) {
Serial.println("Ethernet shield was not found. !");
while (true) {
delay(1);
}
}
if (Ethernet.linkStatus() == LinkOFF) {
Serial.println("Ethernet cable is not connected.");
}
server.begin();
respondEth.begin();

Serial.println("net Init Done.. IP:" + toString(Net_IP()));
return Ethernet.hardwareStatus() != EthernetNoHardware;
}

void loop()
{
if (elapesedMillis > 5000)
{
digitalWrite(13, !digitalRead(13));
Serial.println(String(elapesedMillis)+" "+String(respondEth.available()));
elapesedMillis = 0;
}

EthernetClient client = server.available();
if (client) {
Serial.println("Client Connected");
if (!alreadyConnected)
{
//client.flush();
client.setConnectionTimeout(3000);
client.setTimeout(3000);
alreadyConnected = true;
}

if (client.available() > 0)
{
int len = client.readBytesUntil(10, buffer, 256);
if (len != 0)
{
String str = String(buffer);
String cmd = str.substring(0, len);
String result = ParseCommand(cmd, client);
delay(1);
if (result != "")
client.print(result + "\n");
}
}
}
responder = respondEth.available(); //Send back messages to PC
if (responder) {

}


}
 
Did you find a solution to your issue? I’m dealing with something that sounds similar — wondering if it was a problem with how the network was setup or some other external fix?
 
Teensy ethernet disconnection

Did you find a solution to your issue? I’m dealing with something that sounds similar — wondering if it was a problem with how the network was setup or some other external fix?

We added additional USB IO in order to remote reset the teensy
 
Back
Top