Native TCP/IP support and in-field update on all GHI-NETMF products

We have two new leading-edge features that add more to the GHI’s long list of [italic]exclusive[/italic] features :slight_smile:

  1. WIZnet support. This is not an experimental driver but a commercially and professionally supported driver for your networking needs. It includes TCP server/client, UDP datagram and DNS. DHCP is coming soon too! The interface is standard .NET sockets so no learning curve is needed. All you have to do is initialize the wiznet driver with the correct IOs and that is it. Joe, our networking expert, will follow up with an example on how this is done.

  2. We have added an in-field update feature that allows you to update the firmware remotely! Combine that with the new wiznet networking support and now your device can update itself from the internet. You can update from SD card or USB drive as well. This is all explained in documentation but more tutorials will come explaining it all. The community is also welcome to help us out with the tutorials and we will surly get you some experience points.

Known issue: Installing the SDK over the previous one works but will remove the templates for some reason! We recommend that you uninstall the old GHI SDK before installing the new one.

Do not forget to update the firmware [italic]and[/italic] the GHI assemblies in your project.

There are some more features and fixes that are all listed on the release notes [url]http://www.tinyclr.com/release-notes-beta/[/url]
See the beta page for more details [url]http://www.tinyclr.com/beta/[/url]

Note: Only experienced users have access to the beta download. A public release will be out in about two weeks.

Please only use the “Beta Release” board to discuss [url]http://www.tinyclr.com/forum/12/946/[/url]

Here is an example on how to get started with Native TCP/IP made for WIZnet W5100:

First, If you are using one of the Ethernet shields made for arduino, you need to make a small hardware issue fix, for more reliable performance:
The reset signal on these shields are not connected to any of the digital IO which is wrong. To solve this you have to bend out the reset pin on the shield and connect it to one of the available IOs as you see in the picture.
I connected the the Ethernet shield’s reset signal to Di9.

Second, here is a simple example that I took from NETMF SDK examples (SocketServer example)and edited it to got it working with our library for W5100. only minor addition is needed as you can see because the new libraries made to be compatible with the original System.Net libraries.
Note: You need to add the following libraries (assemblies) GHIElectronics.NETMF.W5100 and Microsoft.SPOT.Hardware.

Do NOT add the original Socket Microsoft Libraries!


using System;
using System.Threading;

using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;

using GHIElectronics.NETMF.FEZ;
using GHIElectronics.NETMF.Net;
using GHIElectronics.NETMF.Net.Sockets;
using GHIElectronics.NETMF.Net.NetworkInformation;
using System.Text;
using Socket = GHIElectronics.NETMF.Net.Sockets.Socket;

namespace FEZ_Application1
{
 public static class MySocketServer
    {
        public static void Main()
        {
            const Int32 c_port = 80;
            byte[] ip = { 192, 168, 0, 200 };
            byte[] subnet = { 255, 255, 255, 0 };
            byte[] gateway = { 192, 168, 0, 1 };
            byte[] mac = { 43, 185, 44, 2, 206, 127 };
            WIZnet_W5100.Enable(SPI.SPI_module.SPI1, (Cpu.Pin)FEZ_Pin.Digital.Di10, (Cpu.Pin)FEZ_Pin.Digital.Di9);
            NetworkInterface.EnableStaticIP(ip, subnet, gateway, mac);
            NetworkInterface.EnableStaticDns(new byte[]{192,168,0,1});
            Socket server = new Socket(AddressFamily.InterNetwork,
            SocketType.Stream, ProtocolType.Tcp);
            IPEndPoint localEndPoint = new IPEndPoint(IPAddress.Any, c_port);
            server.Bind(localEndPoint);
            server.Listen(1);//Int32.MaxValue);

            while (true)
            {
                // Wait for a client to connect.
                Socket clientSocket = server.Accept();

                // Process the client request.  true means asynchronous.
                new ProcessClientRequest(clientSocket, true);
            }
        }

    /// <summary>
    /// Processes a client request.
    /// </summary>
        internal sealed class ProcessClientRequest
        {
            private Socket m_clientSocket;

            /// <summary>
            /// The constructor calls another method to handle the request, but can 
            /// optionally do so in a new thread.
            /// </summary>
            /// <param name="clientSocket"></param>
            /// <param name="asynchronously"></param>
            public ProcessClientRequest(Socket clientSocket, Boolean asynchronously)
            {
                m_clientSocket = clientSocket;

                if (asynchronously)
                    // Spawn a new thread to handle the request.
                    new Thread(ProcessRequest).Start();
                else ProcessRequest();
            }

            /// <summary>
            /// Processes the request.
            /// </summary>
            private void ProcessRequest()
            {
                const Int32 c_microsecondsPerSecond = 1000000;

                // 'using' ensures that the client's socket gets closed.
                using (m_clientSocket)
                {
                    // Wait for the client request to start to arrive.
                    Byte[] buffer = new Byte[1024];
                    if (m_clientSocket.Poll(5 * c_microsecondsPerSecond,
                        SelectMode.SelectRead))
                    {
                        // If 0 bytes in buffer, then the connection has been closed, 
                        // reset, or terminated.
                        if (m_clientSocket.Available == 0)
                            return;

                        // Read the first chunk of the request (we don't actually do 
                        // anything with it).
                        Int32 bytesRead = m_clientSocket.Receive(buffer,
                            m_clientSocket.Available, SocketFlags.None);

                        // Return a static HTML document to the client.
                        String s =
                            "HTTP/1.1 200 OK\r\nContent-Type: text/html; charset=utf-8\r\n\r\n<html><head><title>.NET Micro Framework Web Server on USBizi Chipset </title></head>" +
                           "<body><bold><a href=\"http://www.tinyclr.com/\">Learn more about the .NET Micro Framework with FEZ by clicking here</a></bold></body></html>";
                        m_clientSocket.Send(Encoding.UTF8.GetBytes(s));
                    }
                }
            }
        }
    }
}

Now you have a simple web server 8)

Yay! Can’t wait to try IFU on my Cobra!

FEZ Cobra do not need this new feature! Cobra has a full blown TCP/IP stack with wifi, PPP and million other things :slight_smile: This new feature is bring networking to the other FEZes, like FEZ Panda.

I think Chris means the In-Field Update (IFU) ;D

Really looking forward to seeing this working!