Cerbuino and ENC28

Hello,
I need a simple task: start the ENC28 on my Cerbuino, and get an IP from DHCP.
Quite simple, but I cannot complete it :frowning:
Iā€™ve looked for samples and forum but really nothing was clear.

Someone from GHI can provide me some way to get it?

thanks

Try something like this:


private NetworkInterface _ni;

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

            try
            {
                _ni = NetworkInterface.GetAllNetworkInterfaces()[0];

                if (!_ni.IsDhcpEnabled)
                    _ni.EnableDhcp();

                if (_ni.IPAddress != "0.0.0.0")
                    Debug.Print("IP Address:" + _ni.IPAddress);
            }
            catch (Exception exception)
            {
                throw new ArgumentException("Could not resolve host via DNS.", exception);
            }
         }

Thank you. In fact I was trying something similar inspired by http://www.ghielectronics.com/community/codeshare/entry/606:



 Dim interfaces() = Microsoft.SPOT.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces

            Try

                Dim eth1 = interfaces(0)
                If Not eth1.IsDhcpEnabled Then eth1.EnableDhcp()

                Do

                    eth1 = Microsoft.SPOT.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces(0)

                    Thread.Sleep(1000)

                Loop Until eth1.IPAddress <> "0.0.0.0"

                IsNetworkRunning = True

            Catch ex As Exception
                IsNetworkRunning = False
            End Try

However my eth1.IPAddress is always ā€œ0.0.0.0ā€ :frowning:

The code I posted is what I use in a lot of my projects (Cerberus with a ENC28) and it works well, example:

or

I really donā€™t know :frowning:

If I assign a static address with


eth1.EnableStaticIP ("172.30.98.60", "255.255.255.0", "172.30.98.1") 

I can ping the board (after a while, and sometimes after detach and reattach the cable)

With DHCP still always 0.0.0.0
My DHCP server is ok. Iā€™ve also changed switch port and also cable to be sure.
If your code works, it really has no sense.

p.s. Canada? You are really lucky: itā€™s so beautifulā€¦:slight_smile:

Iā€™ve found that my DHCP server is releasing IP address when I switch to eth1.EnableDhcp. I can found the MAC addresses reported by eth1.EnableDhcp in my release table.

Se the problem is that the board doesnā€™t ā€œload itā€ā€¦ :frowning:

Question: may I inizialize the ENC28 before to use it? The MAC seems quite strangeā€¦

@ baz - you can set the macadress with the Fez Config Tool or simply at program start :


NetworkInterface.GetAllNetworkInterfaces()[0].PhysicalAddress = new byte[] { 0x00, 0x75, 0x65, 0xde, 0xac, 0xaa };

This seems like one of the scenarios that weā€™ve heard (I have it too) where the DHCP lease offered by the DHCP server isnā€™t working exactly as expected in the netmf IP stack. I donā€™t think thereā€™s an easy way to diagnose this without network traces to check the responses - I also donā€™t have a link to the work item or the thread here that talked about it (will update this post if I can find them). Edit: hereā€™s the thread that has some insights http://www.ghielectronics.com/community/forum/topic?id=12032&page=2 edit2: this is the only work item I could find that had 4.2 DHCP relevance https://netmf.codeplex.com/workitem/1655 so Iā€™ve added the above thread to the comments and voted.

I think that this is the problem :frowning:

Iā€™ve assigned a MAC address to my board but this didnā€™t change anything. The board doesnā€™t load the IP assigned by my DHCP server.
Iā€™d I statically assign the address, it works.

I also voted to the thread. However itā€™s incredible I cannot create an object that is plug-and-play on networks using this kind of devices. MS: what a great framework! :frowning:

@ Baz, the framework took the lwIP implementation lwIP - A Lightweight TCP/IP stack - Summary [Savannah] in the 4.2 version, and therefore I suspect that the framework is a victim of a potential issue here - and before anyone pipes up, yes I work for Microsoft (not anything to do with netmf) so obviously I am somewhat protective, but itā€™s important to delve into this reported problem in the correct way.

Can someone share their test code? I have an ENC28 on the way so I can test my Cobra2 with wired and with my (failing) router and help collect more information

@ baz - I experienced same problem on custom board, but with Cerberus firmware.
Problem was with INT pin on the board. Make sure that pin is available and not reserved for other features.

@ slawek Iā€™m sorry for the newbie question, butā€¦ what is the INT pin on may Cerbuino?

Thanks

@ baz -

http://www.ghielectronics.com/downloads/schematic/FEZ_Cerbuino_Bee_SCH.PDF

FEZ Cerbuino, Socket 1, Pin 3 goes to the PA14

Also make sure that SPI works correctly.
You can test it with SPI loopback.
Connect a wire between PB5 and PB4 pins.
Create a project ā€œExample 1ā€ from http://www.ghielectronics.com/docs/14/spi.
Add some data in tx_data array as

tx_data[0]=44;tx_data[0]=55;

and etc.
Insert breakpoint at

MySPI.WriteRead(tx_data, rx_data); 

In rx_data array data should be the same as in tx_data

@ Brett: my VB code is:

        Dim interfaces() = Microsoft.SPOT.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces
                

Dim eth1 = interfaces(0)

Dim mac As Byte() = {&H0, &H88, &H50, &HB2, &HDE, &HD3}
eth1.PhysicalAddress = mac

If Not eth1.IsDhcpEnabled Then eth1.EnableDhcp()

Do

                    eth1 = Microsoft.SPOT.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces(0)

                    Thread.Sleep(1000)
Loop Until eth1.IPAddress <> "0.0.0.0"


In fact the second access to GetAllNetworkInterfaces is not required, it was just a test to see if there was some problem updating internal objects references.

thank you for assistance and for your clarification

@ baz

Did u resolve your problem?

No :frowning:
Iā€™ve tried to understand your suggestion, but I simply have the Cerbuino connected to the ENC using the provided cabled gadgeteer cable. So pins and so on are connected using that cables.

However the NIC works well, just the DHCP doesnā€™t load received address, so I think that connections and other similar things are ok.

on the Cerbuino that pin is part of the socket 1 where the Enc28 is plugged in, and only place where you can plug it inā€¦

not sure what can be done to make it availableā€¦

iā€™m experiencing the same issue with Cerbuino no DHCPā€¦

Cheers,
Jay.

DHCP simply doesntā€™ work on current version of MF :frowning:
It works only sometimes, but most of DHCP servers are not ā€œsupportedā€. Really bad.

@ baz - do you have any of our premium devices?

cerbuino bee