It is planned to install multiple devices on different customer network. So it’s not easy to install smart ethernet switches for all our customers network 
This is my test code.
Without network connection it works fine. When I connect a network cable, I got often timeouts and the application feeze after some hours.
public class Programm
{
private static SdCardController _sdCardReader;
private static I2CDevice _i2C;
private static SPI _spi1;
private static EthernetENC28J60 _eth;
private static SerialPort _serial;
public static void Main()
{
Utility.SetLocalTime(RealTimeClock.GetDateTime());
_i2C = new I2CDevice(new I2CDevice.Configuration(1, 100));
_spi1 = new SPI(new SPI.Configuration(G80.Gpio.PD10, false, 0, 0, false, true, 10000, SPI.SPI_module.SPI1));
var eeprom = new EeProm(_i2C, 81);
var macAddress = eeprom.ReadMacAddress();
_sdCardReader = new SdCardController();
_sdCardReader.Init();
var beeper = new OutputPort(G80.Gpio.PA15, false);
// Ethernet - set physical address (MAC)
_eth = new EthernetENC28J60(SPI.SPI_module.SPI2, G80.Gpio.PE2, G80.Gpio.PE1, G80.Gpio.PC13);
_eth.PhysicalAddress = macAddress;
_sdCardReader.Log("********************************");
_sdCardReader.Log("*********** Start Up ***********");
_sdCardReader.Log("********************************");
StartTestSerialPort();
while (true)
{
Thread.Sleep(1000);
#if !DEBUG
if (!GHI.Processor.Watchdog.Enabled)
{
GHI.Processor.Watchdog.Enable(5000);
}
GHI.Processor.Watchdog.ResetCounter();
#endif
}
}
private static void StartTestSerialPort()
{
var _worker = new Thread(() =>
{
_serial = new SerialPort("COM2", 19200, (Parity)0, 8, (StopBits)1);
_serial.DiscardInBuffer();
_serial.DiscardOutBuffer();
_serial.Open();
while (true)
{
TestSerialPort();
Thread.Sleep(2);
}
});
_worker.Start();
}
private static void TestSerialPort()
{
try
{
byte[] sendData = new byte[10] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09 };
var result = SendReceive(sendData, 1000, 10);
if (result == null)
{
_sdCardReader.Log("Serial timeout");
return;
}
// check result
if (result.Length != sendData.Length)
{
_sdCardReader.Log("Serial data invalid length");
return;
}
for (int i = 0; i < sendData.Length; i++)
{
if (sendData[i] != result[i])
{
_sdCardReader.Log("Serial data invalid result");
return;
}
}
}
catch (Exception ex)
{
_sdCardReader.LogException(ex);
}
}
private static byte[] SendReceive(byte[] writeBuffer, int timeout, int readLength)
{
var result = new byte[readLength];
_serial.DiscardInBuffer();
_serial.DiscardOutBuffer();
_serial.Write(writeBuffer, 0, writeBuffer.Length);
var end = DateTime.Now.AddMilliseconds(timeout);
var idx = 0;
while (_serial.BytesToRead > 0 || DateTime.Now <= end)
{
if (_serial.BytesToRead > 0)
{
var b = (byte)_serial.ReadByte();
if (idx < result.Length)
{
result[idx] = b;
idx++;
}
if (idx == readLength)
{
return result;
}
}
Thread.Sleep(1);
}
return null;
}
}