Main Site Documentation

Issue on pinging ethernet


#1

Hi , I have written a simple application as follows :

string[] dnsAddresses = {"192.168.1.1"};

      void ProgramStarted()
        {

            if (!ethernet.Interface.IsOpen)
            {
                ethernet.Interface.Open();
            }
            ethernet.Interface.NetworkInterface.EnableDhcp();
            NetworkInterfaceExtension.AssignNetworkingStackTo(ethernet.Interface);
            ethernet.UseStaticIP("192.168.1.5", "255.255.255.0", "192.168.1.1");
            ethernet.UseDHCP();
            ethernet.Interface.NetworkInterface.EnableStaticIP("192.168.1.5", "255.255.255.0", "192.168.1.1");
            ethernet.Interface.NetworkInterface.EnableStaticDns(dnsAddresses);
            ethernet.Interface.NetworkInterface.EnableDhcp();
            while (true) 
            {
                multicolorLed.BlinkOnce(GT.Color.Green);
                Thread.Sleep(300);

                multicolorLed.BlinkOnce(GT.Color.Red);
                Thread.Sleep(300);
            } 

        }

and I connected an ethernet cable directly from my laptop to the ethernet_J11D module

and my network configuration is as the attached picture

IP=192.168.1.4
subnet mask : 255.255.255.0
default gateway : 192.168.1.1

when I run the application the LED begins to blip repeadedly but when I try to ping the ethernet ip address : 192.168.1.5 using the command prompt I get the message destination host unreachable

I wonder If there is anything wrong with my code or It’s related to network configuration ?

thanks in advance


#2

@ andre.m -

Thanks alot ! I changed my code to the following code and now I can ping the ethernet :

       string[] dnsAddresses = {"192.168.1.1"};


       
        void ProgramStarted()
        {

            if (!ethernet.Interface.IsOpen)
            {
                ethernet.Interface.Open();
            }
            NetworkInterfaceExtension.AssignNetworkingStackTo(ethernet.Interface);
            ethernet.Interface.NetworkInterface.EnableStaticIP("192.168.1.5", "255.255.255.0", "192.168.1.1");
            ethernet.Interface.NetworkInterface.EnableStaticDns(dnsAddresses);
            
            while (true) 
            {
                multicolorLed.BlinkOnce(GT.Color.Green);
                Thread.Sleep(300);

                multicolorLed.BlinkOnce(GT.Color.Red);
                Thread.Sleep(300);
            } 

        }