Ethernet Networking on Fez Spider with NETMF 4.2

Hi,
I am trying to use my Ethernet module with my fez spider. I wrote a test app to check the network config. When I run it, it prints out the following output:

IP Address: 0.0.0.0
DHCP Enabled: True
Subnet Mask: 0.0.0.0
Gateway: 0.0.0.0

When I open MFDeploy, I can connect to it(over USB) and it all seems fine. But when I open the network configuration and try to apply changes (to anything), It shows the following error: “Invalid configuration data from Plug-In”.

My question is: How can I make it get an IP address, and what Is the error from MFDeploy?

Welcome to the forum.

How about showing us the code you are using to initialize the Ethernet module? Placing the module on the designer surface does not initialize the module.

Don’t use MFDeploy to set network configuration info. It does not work with the latest SDK(https://www.ghielectronics.com/docs/40/netmf-4.2-developer Known issues). User the FEZ Config tool from https://www.ghielectronics.com/support/.net-micro-framework.

2 Likes

Thanks for the reply!

Here is my code:


void ProgramStarted()
        {
            Debug.Print("Program Started");

            ethernet.UseDHCP();

            ethernet.NetworkUp += OnNetworkUp;
            ethernet.NetworkDown += OnNetworkDown;
        }

        void OnNetworkDown(GTM.Module.NetworkModule sender, GTM.Module.NetworkModule.NetworkState state)
        {
            Debug.Print("Network Down");
        }

        void OnNetworkUp(GTM.Module.NetworkModule sender, GTM.Module.NetworkModule.NetworkState state)
        {
            Debug.Print("Network Up");

            var NetworkSettings = ethernet.NetworkSettings;
            Debug.Print("IP Address: " + NetworkSettings.IPAddress);
            Debug.Print("DHCP Enabled: " + NetworkSettings.IsDhcpEnabled);
            Debug.Print("Subnet Mask: " + NetworkSettings.SubnetMask);
            Debug.Print("Gateway: " + NetworkSettings.GatewayAddress);
        }

I used the config tool that you specified and set the MAC address. Now, when I run my program, It throws the following exception:

Exception System.Exception - CLR_E_WRONG_TYPE (1)

#### Message: 
#### Microsoft.SPOT.Net.NetworkInformation.NetworkInterface::GetAllNetworkInterfaces [IP: 0015] ####
#### GHI.Premium.Net.NetworkInterfaceExtension::.ctor [IP: 0022] ####
#### GHI.Premium.Net.EthernetBuiltIn::.ctor [IP: 0005] ####
#### Gadgeteer.Modules.GHIElectronics.Ethernet_J11D::.ctor [IP: 0042] ####
#### EthernetTest.Program::InitializeModules [IP: 0016] ####

Thanks,
Wasabi Fan

You have to open the interface and assign the network stack to the interface. (if you are using 4.2 and latest sdk.

using GHI.Premium.Net
 
ethernet.Interface.CableConnectivityChanged += new EthernetBuiltIn.CableConnectivityChangedEventHandler(CableConnectivityChanged);
ethernet.Interface.NetworkAddressChanged += new NetworkInterfaceExtension.NetworkAddressChangedEventHandler(NetworkAddressChanged);
 
ethernet.Interface.Open();
 
NetworkInterfaceExtension.AssignNetworkingStackTo(ethernet.Interface);
 
//if (!ethernet.Interface.NetworkInterface.IsDhcpEnabled)
//  ethernet.Interface.NetworkInterface.EnableDhcp();
ethernet.Interface.NetworkInterface.EnableStaticIP(IPv4Address, SubnetMask, GatewayAddress);

Can not find NetworkInterfaceExtension in .NET MF 4.3, was it removed or moved to another assembly?