Main Site Documentation

Built in ethernet never detects cable - 4.3 SDK


#1

So far I am having a blast with the FEZ Cerbuino Net mainboard. However, I’m stuck on networking. I’m using the code straight from here - https://www.ghielectronics.com/docs/30/networking#3123 :

var netif = new EthernetBuiltIn();
netif.Open();
var hasNetwork = netif.NetworkIsAvailable;
var hasCable = netif.CableConnected;
netif.EnableDhcp();
netif.EnableDynamicDns();

It looks like it’s never even detecting that the cable is plugged in - the network activity LEDs never light up and hasCable is always false.

When it hits EnableDhcp() it throws this exception:

Microsoft.SPOT.Net.NetworkInformation.NetworkInterface::UpdateConfiguration
Microsoft.SPOT.Net.NetworkInformation.NetworkInterface::EnableDhcp
GHI.Networking.BaseInterface::EnableDhcp
Deployer.App.Program::SetUpEthernet
Deployer.App.Program::ProgramStarted
Deployer.App.Program::Main

I have tried several cables, to no avail. Any ideas would be welcome.

Thanks!
Rob (Spamagnet)


#2

try to open after enables?


#3

Like this?

_ethernet = new EthernetBuiltIn();
_ethernet.EnableDhcp();
_ethernet.EnableDynamicDns();
_ethernet.Open();

while (_ethernet.IPAddress == "0.0.0.0")
{
	var hasNetwork = _ethernet.NetworkIsAvailable;
	var hasCable = _ethernet.CableConnected;
	Debug.Print("Waiting for DHCP");
	Thread.Sleep(250);
}

Interestingly, when I do that it does [em]not[/em] throw an exception. But it still does not detect that the cable is plugged in. The while() loop runs forever.

I have also tried setting the addresses statically:

 {"8.8.8.8", "192.168.1.1"};
const string staticIp = "192.168.1.177";
const string netMask = "255.255.255.0";
const string gatewayIp = "192.168.1.1";
try
{
	_ethernet = new EthernetBuiltIn();
	//_ethernet.EnableDhcp();
	//_ethernet.EnableDynamicDns();
	_ethernet.EnableStaticIP(staticIp, netMask, gatewayIp);
	_ethernet.EnableStaticDns(dnsAddresses);
	_ethernet.Open();

	while (_ethernet.IPAddress == "0.0.0.0")
	{
		var hasNetwork = _ethernet.NetworkIsAvailable;
		var hasCable = _ethernet.CableConnected;
		Debug.Print("Waiting for DHCP");
		Thread.Sleep(250);
	}
...

This still does not detect the cable or network.

Thanks for the idea!
Rob (Spamagnet)


#4

I could be wrong but hasnt this been a know bug for awhile? I don’t even bother checking for cable anymore and haven’t for at least a year.


#5

I’m not sure if it matters, but did you set the MAC address?


#6

@ Spamagnet - Since you are using the FEZ Cerbuino Net, you want to use the EthernetENC28 object, not EthernetBuiltIn.


#7

and, if non-gadgeteer, you should add these code before open the interface:

      NetworkChange.NetworkAvailabilityChanged += new NetworkAvailabilityChangedEventHandler(NetworkChange_NetworkAvailabilityChanged);
            NetworkChange.NetworkAddressChanged += new NetworkAddressChangedEventHandler(NetworkChange_NetworkAddressChanged);

#8

So are these the right parameters to create the object?

netif = new EthernetENC28J60(SPI.SPI_module.SPI1,
                Cpu.Pin.GPIO_Pin1, Cpu.Pin.GPIO_Pin2, Cpu.Pin.GPIO_Pin3);

(from here https://www.ghielectronics.com/docs/30/networking#3123 )

Thanks John!
Regards,
Rob (Spamagnet)


#9

@ Spamagnet - You’ll want the following pins:


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

The pins in the document are only placeholders to be filled in with the ones for your specific board.


#10

Thank you John! I will unfortunately be out of town for a few days but I will try this as soon as I can.

Regards,
Rob (Spamagnet)


#11

var eth = new EthernetENC28J60(SPI.SPI_module.SPI1,
                GHI.Pins.Generic.GetPin('A', 13),
                GHI.Pins.Generic.GetPin('A', 14),
                GHI.Pins.Generic.GetPin('B', 10));
eth.EnableDhcp();
eth.EnableDynamicDns();
eth.Open();
while (eth.IPAddress == "0.0.0.0")
{
	Debug.Print("Waiting for DHCP");
	Thread.Sleep(250);
}

I tried the above code and the loop never exits. The activity lights never turn on. I have tried multiple cables and several different Ethernet switches.

I also tried this with the same effect:


var eth = Mainboard.Ethernet;
...

Any ideas on how to troubleshoot/debug this further?

Thanks!
Rob (Spamagnet)


#12

Did you see the comment from John?


#13

@ Spamagnet
Looks OK for Cebuino Bee. I use a somewhat different sequence and it works (MF, not Gadgeteer)

   static EthernetENC28J60 Eth1;

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

#14

[quote=“Mike”]Did you see the comment from John?
[/quote]
Yes, and it looked like he included the specific pins for my board in his response. I tried those pin assignments and got the same results. If there is other documentation on the pins for my specific board I have yet to find it.

[quote=“Lurch”]I use a somewhat different sequence and it works…
[/quote]
Actually it looks like the pin assignments in your code is identica to minel. A13 / A14 / B10.

Thanks all!

Regards,
Rob (Spamagnet)


#15

@ Spamagnet - Do either of the lights turn on when you insert the cable after startup?


#16

No, the lights never come on.


#17

Do you actually have a “live” Ethernet cable ?? I assume they do come on when you have it inserted when you apply power?


#18

@ Brett - I have tried several “known good” cables, connected to my switch and directly to my router. None of the Ethernet lights have lit up at any point.

Hmmmm …

In desperation, I tried connecting the cable directly to my laptop. This time both activity lights did indeed come on. I will try setting a static IP address and see if I can actually talk to it.


#19

Apparently some of the digital I/O pins conflict with the Ethernet controller. After I moved the connections I had on those pins everything appears to be working.

Thanks to everyone!

Rob (Spamagnet)