Cerbuino Bee + Enc28

Hello,

I’m just trying to get a Cerbuino + Enc28 Module to work. I’m not interested in using the Gadgeteer platform just NetMF.

I initialized the module with

 public class Program
    {
        private static EthernetENC28J60 netif;

        public static void Main()
        {
            NetworkChange.NetworkAvailabilityChanged += NetworkChange_NetworkAvailabilityChanged;
            NetworkChange.NetworkAddressChanged += NetworkChange_NetworkAddressChanged;

            netif = new EthernetENC28J60(SPI.SPI_module.SPI1, Generic.GetPin('A', 13), Generic.GetPin('A', 14), Generic.GetPin('B', 10));
            netif.Open();
            netif.EnableDhcp();
            netif.EnableDynamicDns();

            var led = new OutputPort(Generic.GetPin('B', 2), false);
            while (true)
            {

                led.Write(true);
                Thread.Sleep(500);
                led.Write(false);
                Thread.Sleep(500);

              
            }
        }

        private static void NetworkChange_NetworkAddressChanged(object sender, Microsoft.SPOT.EventArgs e)
        {

            if (netif.IPAddress != "0.0.0.0")
            {
                //If I plug the network calbe into the socket netif.IPAddress = "0.0.0.0"
                //If I unplug it, then netif.IPAddress has the last IP it had before

            }

        }

        private static void NetworkChange_NetworkAvailabilityChanged(object sender, NetworkAvailabilityEventArgs e)
        {
            Debug.Print("Network availability: " + e.IsAvailable.ToString());
        }

    }

It seems the network address changed event is firing before the netif.IPAddress property is set with the latest value. Seems it always is the old value?

Any suggestions?

Best regards,

Alex

@ Alex111 - Are you using the latest firmware?

FEZ Config reports this:

Loader (TinyBooter) version information:
4.3.4.0 on this computer.
4.3.3.0 on this device.

The Loader (TinyBooter) not up to date. <<<

Firmware (TinyCLR) version information:
4.3.6.0 on this computer.
4.3.6.0 on this device.

The Firmware (TinyCLR) is up to date. <<<
Please wait for the device to reboot…

@ Alex111 - If you check the IPAddress outside of the event and just use the event to signal another thread to begin working, does everything work?

Yes, but I think this is not the intended use case of the NetworkAddressChanged event.

I think everyone would expect that the IP in the event would have the correct value. Even in your sample code this is expected… I think this has to be treated like a bug? What do you think?

@ Alex111 - We will take a look and see if we can find anything. For now, do not rely on the IPAddress property within that event.

Do you have a public bugtracking information, where I could see when this issue is solved?

@ Alex111 - We have a task tracker for confirmed issues. We have not confirmed this issue yet. We will update the thread as we get more information.

@ John - I have been using the RS21 module recently, and I noticed that the IP address is not available when the network changed or IP address changed event occurs. When I get the IP address changed event, I start a thread which waits for the address to appear.

@ Mike - Roughly how long does it take to appear?

@ John - just a few seconds

A quick question. This seems for me like a bug. How does GHI go ahead with such informations. What is the timeline for this?

Is this behaviour on all platforms the same? or is it related to cerb platform?

What is the best place to report this bug officially, so that it gets solved with the next version?

The Task Tracker
https://www.ghielectronics.com/tracker/list/open

@ Alex111 - The network interface object that NETMF exposes is not update in real time. It’s a static copy. To update it, you must recreate the interface through a call to GetNetworkInterfaces that NETMF provides. We do make a call internally in the interface in the same event handler you use. Since NETMF events are not deterministic, your event handler can be called before ours meaning you will see the old stale data. The next SDK will add a RefreshNetworkInterface method that you can call to manually update the interface object before checking its properties.

1 Like