Main Site Documentation

Ethernet Problem


#1

Thank you very much for your answer, “Wouter Huysentruit” and “ransomhall” !

I have tried your suggestion, but it doesn’t work.http://www.tinyclr.com/forum/21/5998/

I find a very interesting situation, if I write codes as follow:



using System;
using System.Threading;
using System.Net;
using System.Net.Sockets;
using System.Text;

using Microsoft.SPOT;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Presentation.Media;
using Microsoft.SPOT.Touch;

using Gadgeteer.Networking;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using Gadgeteer.Modules.GHIElectronics;



namespace Ethernet_test
{
    public partial class Program
    {


        // This method is run when the mainboard is powered up or reset.   
        void ProgramStarted()
        {

            ethernet.UseDHCP();

            //ethernet.NetworkUp += new GTM.Module.NetworkModule.NetworkEventHandler(ethernet_NetworkUp);

            Debug.Print("Connected to network.");
            Debug.Print("IP address: " + ethernet.NetworkSettings.IPAddress);
            WebServer.StartLocalServer("192.168.1.200", 80);



            // Use Debug.Print to show messages in Visual Studio's "Output" window during debugging.
            Debug.Print("Program Started");


        }

       /* void ethernet_NetworkUp(GTM.Module.NetworkModule sender, GTM.Module.NetworkModule.NetworkState state)
        {
            Debug.Print("Connected to network.");
            Debug.Print("IP address: " + ethernet.NetworkSettings.IPAddress);
            WebServer.StartLocalServer("192.168.1.200", 80);
        }*/

    }
}



In the windows output I can get the right result.
It doesn’t matter with connectting or un connectting the network cable while my program is running.

But if I write codes like as follow:


using System;
using System.Threading;
using System.Net;
using System.Net.Sockets;
using System.Text;

using Microsoft.SPOT;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Presentation.Media;
using Microsoft.SPOT.Touch;

using Gadgeteer.Networking;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using Gadgeteer.Modules.GHIElectronics;



namespace Ethernet_test
{
    public partial class Program
    {


        // This method is run when the mainboard is powered up or reset.   
        void ProgramStarted()
        {

            ethernet.UseDHCP();

            ethernet.NetworkUp += new GTM.Module.NetworkModule.NetworkEventHandler(ethernet_NetworkUp);





            // Use Debug.Print to show messages in Visual Studio's "Output" window during debugging.
            Debug.Print("Program Started");


        }

        void ethernet_NetworkUp(GTM.Module.NetworkModule sender, GTM.Module.NetworkModule.NetworkState state)
        {
            Debug.Print("Connected to network.");
            Debug.Print("IP address: " + ethernet.NetworkSettings.IPAddress);
            WebServer.StartLocalServer("192.168.1.200", 80);
        }

    }
}


the windows output show me:



“Microsoft.SPOT.Debugger.CorDebug.dll” (Verwaltet): “C:\Programme\GHI Electronics\GHI NETMF v4.1 SDK\Assemblies\le\GHIElectronics.NETMF.Hardware.dll” geladen
"Microsoft.SPOT.Debugger.CorDebug.dll" (Verwaltet): “C:\Programme\GHI Electronics\GHI .NET Gadgeteer SDK\Mainboards\FEZSpider\NETMF 4.1\le\GHIElectronics.Gadgeteer.FEZSpider.dll” geladen, Symbole geladen.
“Microsoft.SPOT.Debugger.CorDebug.dll” (Verwaltet): “C:\Dokumente und Einstellungen\Zalud\eigene dateien\visual studio 2010\Projects\Ethernet_test\Ethernet_test\bin\Debug\le\Ethernet_test.exe” geladen, Symbole geladen.
Der Thread ‘’ (0x2) hat mit Code 0 (0x0) geendet.
Using mainboard GHIElectronics-FEZSpider version 1.0
Program Started

I have tried to unconnect and then later reconnect the network cable while myprogram is running.
But it doesn’t work.

I have even tried a simple example as follow:


using System;
using System.Threading;
using System.Net;
using System.Net.Sockets;
using System.Text;

using Microsoft.SPOT;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Presentation.Media;
using Microsoft.SPOT.Touch;

using Gadgeteer.Networking;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using Gadgeteer.Modules.GHIElectronics;



namespace Ethernet_test
{
    public partial class Program
    {


        // This method is run when the mainboard is powered up or reset.   
        void ProgramStarted()
        {

            ethernet.UseDHCP();

            ethernet.NetworkUp += new GTM.Module.NetworkModule.NetworkEventHandler(ethernet_NetworkUp);





            // Use Debug.Print to show messages in Visual Studio's "Output" window during debugging.
            Debug.Print("Program Started");


        }

        void ethernet_NetworkUp(GTM.Module.NetworkModule sender, GTM.Module.NetworkModule.NetworkState state)
        {
            Debug.Print("ethernet_NetworkUp Started");
        }

    }
}

the window output show me the same problem as follow



“Microsoft.SPOT.Debugger.CorDebug.dll” (Verwaltet): “C:\Programme\GHI Electronics\GHI .NET Gadgeteer SDK\Modules\Ethernet_J11D\NETMF 4.1\le\GTM.GHIElectronics.Ethernet_J11D.dll” geladen, Symbole geladen.
“Microsoft.SPOT.Debugger.CorDebug.dll” (Verwaltet): “C:\Programme\GHI Electronics\GHI NETMF v4.1 SDK\Assemblies\le\GHIElectronics.NETMF.Hardware.dll” geladen
"Microsoft.SPOT.Debugger.CorDebug.dll" (Verwaltet): “C:\Programme\GHI Electronics\GHI .NET Gadgeteer SDK\Mainboards\FEZSpider\NETMF 4.1\le\GHIElectronics.Gadgeteer.FEZSpider.dll” geladen, Symbole geladen.
“Microsoft.SPOT.Debugger.CorDebug.dll” (Verwaltet): “C:\Dokumente und Einstellungen\Zalud\eigene dateien\visual studio 2010\Projects\Ethernet_test\Ethernet_test\bin\Debug\le\Ethernet_test.exe” geladen, Symbole geladen.
Der Thread ‘’ (0x2) hat mit Code 0 (0x0) geendet.
Using mainboard GHIElectronics-FEZSpider version 1.0
Program Started

the “void ethernet_NetworkUp()” doesn’t work.

I am confused about it, can you give me some suggestions?

I look forward to your answer.


#2

If I remember correctly there are bugs in the DHCP Implementation,
try it using a static IP…

There should be no errors…


#3

I think I have used the static IP, I have a free Ethernet card in my computer and I set the IP “192.168.1.56”, I can show you a picture.

the IP of my “FEZ Spider” is “192.168.1.200”, I can see it from the LCD.

Maybe I am something wrong, if you find, please tell me.


#4

You got me wrong :slight_smile:

Try to use a static ip for your ethernet module

Like this:


            ethernet.UseStaticIP("192.168.1.200","255.255.255.0", "192.168.1.56", new string[]{"8.8.8.8"});


#5

Thank you sir!! it works!