Monday 11 February 2013

Gadgeteer Ethernet J11D module not working in NETMF 4.2 projects

I had some problems getting an Ethernet module working with my Gadgeteer mainboard in a NetMF 4.2 project last night, so i thought i'd share how i got it working.

I'm using a Fez Spider mainboard and Ethernet J11D module and it seems that the Ethernet module works a bit differently under NetMF 4.2 that what i'm used to.





















Adding the Ethernet module to the Gadgeteer visual designer in the same way as other modules will cause a null reference exception.

We no longer need to add the Ethernet module to the designer. Instead we use the EthernetBuiltIn class and the NetworkInterfaceExtension.AssignNetworkingStackTo method.

You can find some sample code to get the Ethernet module working below.

You'll need to add a reference to GHI.Premium.Net for the EthernetBuiltIn class.

 static readonly EthernetBuiltIn Ethernet = new EthernetBuiltIn();  
   
     void ProgramStarted()  
     {  
       Debug.Print("Program Started");  
   
       Ethernet.Open();  
   
       NetworkInterfaceExtension.AssignNetworkingStackTo(Ethernet);  
   
       Ethernet.NetworkAddressChanged += new NetworkInterfaceExtension.NetworkAddressChangedEventHandler(Ethernet_NetworkAddressChanged);  
   
       Ethernet.NetworkInterface.EnableDhcp();  
     }  
   
     void Ethernet_NetworkAddressChanged(object sender, EventArgs e)  
     {  
       Debug.Print("Network Address Changed");  
       Debug.Print(Ethernet.NetworkInterface.IPAddress);  
     }  

This code should be enough to get you started with the Ethernet module under NETMF 4.2

2 comments:

  1. I like this post very much, Its a real nice situation to read and receive information.
    I had bug my error by using this post. Same error I was facing but its no more now..

    Leased line quote

    ReplyDelete
  2. Hi,
    Thanks for this post.Actually I didn't know about leased line but now I understand it better."A leased line connects two locations for private voice and/or data telecommunication service. Not a dedicated cable, a leased line is actually a reserved circuit between two points. Leased lines can span short or long distances.An Internet leased line is a premium internet connectivity product, delivered over fiber normally, which is dedicated and provides uncontended, symmetrical speeds, full-duplex. It is also known as an ethernet leased line, DIA line, data circuit or private circuit" Thanks.

    ReplyDelete