I’m testing some code ported to 4.3 to FEZHydra. I starting to check ethernet code and doesn.t work.
static EthernetENC28J60 CreateEthernetInterface()
{
foreach (NetworkInterface nic in NetworkInterface.GetAllNetworkInterfaces())
{
Debug.Print(" -> " + nic.NetworkInterfaceType.ToString());
}
// ********** FEZHydra ****
//Eth1 = new EthernetENC28J60(SPI.SPI_module.SPI1, GHI.Pins.Generic.GetPin('A', 29),
// GHI.Pins.Generic.GetPin('D', 17), GHI.Pins.Generic.GetPin('A', 13), 4000);
//Eth1 = new EthernetENC28J60(SPI.SPI_module.SPI1, GHI.Pins.G400.PB13,
// GHI.Pins.G400.PB8 , GHI.Pins.G400.PB9, 4000);
Eth1 = new EthernetENC28J60(SPI.SPI_module.SPI1, (Cpu.Pin) 45, (Cpu.Pin) 40, (Cpu.Pin) 41, 4000); //socket 3
//Eth1 = new EthernetENC28J60(SPI.SPI_module.SPI1, (Cpu.Pin) 46, (Cpu.Pin) 34, (Cpu.Pin) 11, 4000); // socket 4
return Eth1;
}
static void StartEthernet()
{
Eth1 = CreateEthernetInterface();
NetworkChange.NetworkAddressChanged += new NetworkAddressChangedEventHandler(Eth1_NetworkAddressChanged);
NetworkChange.NetworkAvailabilityChanged += new NetworkAvailabilityChangedEventHandler(Eth1_CableConnectivityChanged);
Eth1.Open();
Eth1.NetworkInterface.EnableStaticIP(_boardIp, _boardNetmask, _boardGw); // class C net
string [] DnsAddresses = new string[] { "8.8.8.8" , "192.168.20.1"};
Eth1.NetworkInterface.EnableStaticDns(DnsAddresses);
Eth1.NetworkInterface.PhysicalAddress = new byte[] { 0x00, 0xC0, 0x03, 0x00, 0xC1, 0x05 }; // MACADDR: 00-C0-03-00-C1-03
if (!Eth1.CableConnected)
{
NetworkAvailablityBlocking = new ManualResetEvent(false);
do
{
if (!Eth1.CableConnected)
{
Debug.Print("Ethernet cable is not connected yet.");
}
else
break;
}
while (!NetworkAvailablityBlocking.WaitOne(5000, false));
}
while (IPAddress.GetDefaultLocalAddress() == IPAddress.Any)
{
Debug.Print("IP address is not set yet.");
}
Debug.Print("IP address is set " + Eth1.NetworkInterface.IPAddress.ToString() + " - " + EthernetENC28J60.ActiveInterface.IPAddress);
}
static void Eth1_NetworkAddressChanged(object sender, EventArgs e)
{
Debug.Print("New address for The built-in Ethernet Network Interface ");
Debug.Print("Is DhCp enabled: " + Eth1.NetworkInterface.IsDhcpEnabled);
Debug.Print("Is DynamicDnsEnabled enabled: " + Eth1.NetworkInterface.IsDynamicDnsEnabled);
Debug.Print("NetworkInterfaceType " + Eth1.NetworkInterface.NetworkInterfaceType);
Debug.Print("Network settings:");
Debug.Print("IP Address: " + Eth1.NetworkInterface.IPAddress);
Debug.Print("Subnet Mask: " + Eth1.NetworkInterface.SubnetMask);
Debug.Print("Default Getway: " + Eth1.NetworkInterface.GatewayAddress);
Debug.Print("Number of DNS servers:" + Eth1.NetworkInterface.DnsAddresses.Length);
for (int i = 0; i < Eth1.NetworkInterface.DnsAddresses.Length; i++)
Debug.Print("DNS Server " + i.ToString() + ":" + Eth1.NetworkInterface.DnsAddresses[i]);
Debug.Print("----------------------------------------------");
}
The ENC28 module is created runtime and not via gadgeteer GUI and is plugged on socket 3 (S) (but same result on socket 4).
The board is not pingable but arp is resolved to correct mac addr.
I’ve no clue. Did I forget something for 4.3 eth initialization ?