WiFi RedPine Exception when trying to run the demo

Im trying to run the WiFi Demo:

http://www.ghielectronics.com/downloads/NETMF/Library%20Documentation/html/7481f4d9-b4bc-f53d-e6bb-3a1ae861c9ef.htm

IM getting this output:
The debugging target runtime is loading the application assemblies and starting execution.
Ready.

‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files\Microsoft .NET Micro Framework\v4.1\Assemblies\le\mscorlib.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files\Microsoft .NET Micro Framework\v4.1\Assemblies\le\Microsoft.SPOT.Native.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files\Microsoft .NET Micro Framework\v4.1\Assemblies\le\Microsoft.SPOT.Hardware.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files\Microsoft .NET Micro Framework\v4.1\Assemblies\le\Microsoft.SPOT.Hardware.SerialPort.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files\GHI Electronics\GHI NETMF v4.1 SDK\Assemblies\le\GHIElectronics.NETMF.System.dll’
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files\Microsoft .NET Micro Framework\v4.1\Assemblies\le\Microsoft.SPOT.Net.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files\GHI Electronics\GHI NETMF v4.1 SDK\Assemblies\le\GHIElectronics.NETMF.Net.dll’
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files\Microsoft .NET Micro Framework\v4.1\Assemblies\le\System.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘c:\users\oki\documents\visual studio 2010\Projects\WifiDemo\WifiDemo\bin\Debug\le\FEZ Cobra Console Application.exe’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files\GHI Electronics\GHI NETMF v4.1 SDK\Assemblies\le\FEZCobra_GHIElectronics.NETMF.FEZ.dll’
The thread ‘’ (0x2) has exited with code 0 (0x0).
Version Number is 4.3.0
#### Exception GHIElectronics.NETMF.Net.WiFi+HardwareException - 0x00000000 (1) ####
#### Message:
#### GHIElectronics.NETMF.Net.WiFi::Enable [IP: 008d] ####
#### RTIP_RedPine_test.Program::Main [IP: 001b] ####
A first chance exception of type ‘GHIElectronics.NETMF.Net.WiFi.HardwareException’ occurred in GHIElectronics.NETMF.Net.dll
#### Exception System.Exception - 0xffffffff (1) ####
#### Message:
#### GHIElectronics.NETMF.Net.RS21Driver::SetBootloadOption [IP: 0000] ####
#### GHIElectronics.NETMF.Net.WiFi::UpdateFirmware [IP: 0027] ####
#### RTIP_RedPine_test.Program::Main [IP: 0045] ####
A first chance exception of type ‘System.Exception’ occurred in GHIElectronics.NETMF.Net.dll
An unhandled exception of type ‘System.Exception’ occurred in GHIElectronics.NETMF.Net.dll

There is a known issue with this component. Search the forum and you’ll find plenty of details. A new SDK is supposedly close to release to resolve this.

When will the SDK be ? anyway of resovling this issue ?

You and me both (+ others) want to know the answer to the first question. GHI is waiting on an impending firmware update from RedPines. The answer to the second question is wait for the update.

Wait… man im in the middle of making my thesis the deadline is to january, and I have the WiFi, and other stuff but the WiFi is crucial for the communication :/. Hurry up with that SDK guys ;(

The exception you are getting is not related to the bugs we are fixing. Please let me see the code you are using in your project and take a picture of how you connected the wifi module to your board. It is FEZ Cobra isn’t it?

@ Joe - sorry for spreading rumors :frowning:

The Code :


/// Add these libraries to your project's References
/// System
/// Microsoft.SPOT.Hardware
/// Microsoft.SPOT.Net
/// GHIElectronics.NETMF.System
/// GHIElectronics.NETMF.Net
using System;
using Microsoft.SPOT;

using System.Threading;
using System.Net.Sockets;
using Microsoft.SPOT.Net.NetworkInformation;
using GHIElectronics.NETMF.Net;
using Microsoft.SPOT.Hardware;
using System.Net;

namespace RTIP_RedPine_test
{
    public class Program
    {
        static public bool network_is_read = false;
        public static void Main()
        {
            NetworkChange.NetworkAvailabilityChanged += new NetworkAvailabilityChangedEventHandler(NetworkChange_NetworkAvailabilityChanged);
            while (true)
            {
                try
                {
                    //WiFi.Enable(WiFi.HardwareModule.RS9110_N_11_21_1_Compatible, SPI.SPI_module.SPI2, (Cpu.Pin)10, (Cpu.Pin)18, (Cpu.Pin)20);// FEZ Spider Socket 6
                    WiFi.Enable(WiFi.HardwareModule.RS9110_N_11_21_1_Compatible,SPI.SPI_module.SPI2, (Cpu.Pin)2, (Cpu.Pin)26, (Cpu.Pin)3);//EMX DevSys
                    //WiFi.Enable(WiFi.HardwareModule.RS9110_N_11_21_1_Compatible, SPI.SPI_module.SPI2, (Cpu.Pin)64 + 9, (Cpu.Pin)19, (Cpu.Pin)64 + 8);//ChipworkX DevSys
                }
                catch (WiFi.HardwareException e)
                {

                    if (e.errorCode == WiFi.HardwareException.ErrorCode.CommunicationTimeout || e.errorCode == WiFi.HardwareException.ErrorCode.FirmwareVersionMismatch)
                    {
                        //WiFi.UpdateFirmware(WiFi.HardwareModule.RS9110_N_11_21_1_Compatible, SPI.SPI_module.SPI2, (Cpu.Pin)10, (Cpu.Pin)18, (Cpu.Pin)20);// FEZ Spider Socket 6
                        //WiFi.Enable(WiFi.HardwareModule.RS9110_N_11_21_1_Compatible, SPI.SPI_module.SPI2, (Cpu.Pin)10, (Cpu.Pin)18, (Cpu.Pin)20);// FEZ Spider Socket 6

                        WiFi.UpdateFirmware(WiFi.HardwareModule.RS9110_N_11_21_1_Compatible, SPI.SPI_module.SPI1, (Cpu.Pin)2, (Cpu.Pin)26, (Cpu.Pin)3);//EMX DevSys
                        WiFi.Enable(WiFi.HardwareModule.RS9110_N_11_21_1_Compatible, SPI.SPI_module.SPI1, (Cpu.Pin)2, (Cpu.Pin)26, (Cpu.Pin)3);//EMX DevSys

                        //WiFi.UpdateFirmware(WiFi.HardwareModule.RS9110_N_11_21_1_Compatible, SPI.SPI_module.SPI2, (Cpu.Pin)64 + 9, (Cpu.Pin)19, (Cpu.Pin)64 + 8);//ChipworkX DevSys
                        //WiFi.Enable(WiFi.HardwareModule.RS9110_N_11_21_1_Compatible, SPI.SPI_module.SPI2, (Cpu.Pin)64 + 9, (Cpu.Pin)19, (Cpu.Pin)64 + 8);
                    }
                    else if (e.errorCode == WiFi.HardwareException.ErrorCode.CommunicationFailure)
                    {
                        Debug.Print("Check WiFi module hardware connections and SPI/signals configurations");
                        Thread.Sleep(Timeout.Infinite);
                    }
                   
                }

                if (WiFi.IsEnabled)
                {
                    Debug.Print("Searching for WiFi APs");
                    AccessPointInfo[] ScanResp = WiFi.Scan();
                    if (ScanResp != null)
                    {
                        Debug.Print("Total Available Network are " + ScanResp.Length.ToString());
                        foreach (AccessPointInfo x in ScanResp)
                        {
                            Debug.Print(x.SSID);
                        }
                    }
                    int i = 0;
                    for (i = 0; i < ScanResp.Length; i++)
                    {
                        if (string.Compare(ScanResp[i].SSID, "somenetwork") == 0)
                        {
                            break;
                        }
                    }
                    try
                    {
                        if (i < ScanResp.Length)
                        {
                            Debug.Print("Connecting to " + ScanResp[i].SSID);
                            WiFi.ConnectInfrastructure(ScanResp[i], "password");
                            network_is_read = true;
                        }
                        else
                            Debug.Print("The netwrok you are looking for is not there");
                    }
                    catch
                    {
                        Debug.Print("Faild to connect to the Wireless AP");
                    }

                    if (network_is_read)
                    {
                        Debug.Print("WiFi link is ready!");

                        Debug.Print("Enable DHCP");
                        try
                        {
                            NetworkInterface[] netif = NetworkInterface.GetAllNetworkInterfaces();

                            // Static IP
                            /*****************************/
                            //netif[0].EnableStaticIP("192.168.1.222", "255.255.255.0", "192.168.1.1");
                            //netif[0].EnableStaticDns(new string[] { "10.1.10.1" });

                            // Dynamic IP
                            /*****************************/
                            if (!netif[0].IsDhcpEnabled)
                                netif[0].EnableDhcp();// This function is blocking
                            else
                            {
                                netif[0].RenewDhcpLease();// This function is blocking
                            }
                            network_is_read = true;
                            Debug.Print("Network settings:");
                            Debug.Print("IP Address: " + netif[0].IPAddress);
                            Debug.Print("Subnet Mask: " + netif[0].SubnetMask);
                            Debug.Print("Default Getway: " + netif[0].GatewayAddress);
                            Debug.Print("DNS Server: " + netif[0].DnsAddresses[0]);


                        }
                        catch (SocketException e)
                        {
                            Debug.Print("DHCP Faild");
                            if (e.ErrorCode == 11003)
                                Debug.Print(" WiFi module stopped responding. Re-Enable");
                        }

                        Debug.Print("Test DNS");
                        try
                        {
                            IPHostEntry myIP = Dns.GetHostEntry("www.ghielectronics.com");

                            if (myIP != null)
                            {
                                Debug.Print(myIP.HostName + ": " + myIP.AddressList[0].ToString());
                            }
                        }
                        catch (SocketException e)
                        {
                            Debug.Print("Faild to Get the host entry of the FQN from DNS server!");
                            if (e.ErrorCode == 11003)
                                Debug.Print(" WiFi module stopped responding. Re-Enable");
                        }
                        Thread.Sleep(3000);
                        Debug.Print("Disconnect WiFi link.");
                        WiFi.Disconnect();
                        Thread.Sleep(5000);

                    }

                    Debug.Print("Disable WiFi interface");
                    WiFi.Disable();
                }
                Thread.Sleep(Timeout.Infinite);
            }

        }

        static void NetworkChange_NetworkAvailabilityChanged(object sender, NetworkAvailabilityEventArgs e)
        {
            if (e.IsAvailable)
            {
                if (WiFi.IsLinkConnected)
                {
                    Debug.Print("WiFi connection was established!");
                }
            }
            else
            {
                if (!WiFi.IsLinkConnected)
                {
                    Debug.Print("WiFi connection was dropped or disconnected!");
                    network_is_read = false;
                }
            }
        }

    }
}

And i made a board which is consistant with the atached schema. (Plus i have two capacitors of course :slight_smile: 220uF electrolyte + .47 uF).

I checked the board like couple of times - it seems ok + i get a green LED put on and off when the debug is caught.

PLZ Help Me Out

It Falls into :

 if (e.errorCode == WiFi.HardwareException.ErrorCode.CommunicationTimeout || e.errorCode == WiFi.HardwareException.ErrorCode.FirmwareVersionMismatch)
                    {
                        //WiFi.UpdateFirmware(WiFi.HardwareModule.RS9110_N_11_21_1_Compatible, SPI.SPI_module.SPI2, (Cpu.Pin)10, (Cpu.Pin)18, (Cpu.Pin)20);// FEZ Spider Socket 6
                        //WiFi.Enable(WiFi.HardwareModule.RS9110_N_11_21_1_Compatible, SPI.SPI_module.SPI2, (Cpu.Pin)10, (Cpu.Pin)18, (Cpu.Pin)20);// FEZ Spider Socket 6
 
                        WiFi.UpdateFirmware(WiFi.HardwareModule.RS9110_N_11_21_1_Compatible, SPI.SPI_module.SPI1, (Cpu.Pin)2, (Cpu.Pin)26, (Cpu.Pin)3);//EMX DevSys
                        WiFi.Enable(WiFi.HardwareModule.RS9110_N_11_21_1_Compatible, SPI.SPI_module.SPI1, (Cpu.Pin)2, (Cpu.Pin)26, (Cpu.Pin)3);//EMX DevSys
 
                        //WiFi.UpdateFirmware(WiFi.HardwareModule.RS9110_N_11_21_1_Compatible, SPI.SPI_module.SPI2, (Cpu.Pin)64 + 9, (Cpu.Pin)19, (Cpu.Pin)64 + ;//ChipworkX DevSys
                        //WiFi.Enable(WiFi.HardwareModule.RS9110_N_11_21_1_Compatible, SPI.SPI_module.SPI2, (Cpu.Pin)64 + 9, (Cpu.Pin)19, (Cpu.Pin)64 + ;

With an error Code 2 - then Then catches the exception ( when moving into )

HELP ME OUT PLZ

Yes its Fez Cobra + I attached a photo but you will get more out of it from the schematic I added earlier
I’m Waiting for any helpy

Common Guys …

Any ideas ? Suggestions ? this is the backbone of my Thesis :frowning: the deadline is near…

OK

I use the UEXT connector,

I noticed that when i accidently switched it to SPI2 - the LED went on and it tried to Update The Firmware, but when in SPI1 i get an exception to check the hardware connections PLZ Help me

Oki,

Make sure you have the latest firmware on your board and latest SDK installed. Also make sure your references in your code are ok… if not sure, remove them and add them again…

I aslo use a redpine module on a custom board and that works properly in combination with EMX, but sometimes also receive exceptions, for example in WiFi.Scan(…) or others.

If you receive an exceptions from WiFi or Network related methods, simply try the call again.
like:


 AccessPointInfo[] accessPointInfo = null;
            int retryCounter;
            for (retryCounter = 0; retryCounter < 10; retryCounter++)
            {
                try
                {
                    accessPointInfo = WiFi.Scan("yourSSID");
                    if (accessPointInfo != null && accessPointInfo.Length != 0)
                        break;
                }
                catch (Exception ex)
                {
                    DebugHelper.DebugPrint("Wifi Scan Exception: " + ex.Message);
                    continue;
                }
            }
            if (retryCounter == 10)
            {
                RouterLed.Blink();
                Thread.Sleep(Timeout.Infinite);
            }

            for (retryCounter = 0; retryCounter < 10; retryCounter++)
            {
                try
                {
                    WiFi.ConnectInfrastructure(accessPointInfo[0], Configuration.Settings.PassPhrase);
                    break;
                }
                catch (Exception exception)
                {
                    DebugHelper.DebugPrint("Wifi Connect Exception: " + exception.Message);
                    Thread.Sleep(100);
                }
            }

WiFi.UpdateFirmware(WiFi.HardwareModule.RS9110_N_11_21_1_Compatible, SPI.SPI_module.SPI1, (Cpu.Pin)2, (Cpu.Pin)26, (Cpu.Pin)3);//EMX DevSys
                        WiFi.Enable(WiFi.HardwareModule.RS9110_N_11_21_1_Compatible, SPI.SPI_module.SPI1, (Cpu.Pin)2, (Cpu.Pin)26, (Cpu.Pin)3);//EMX DevSys
 

This configuration matches the UEXT pin mapping on EMX Dev Sys only.

Please change the configurations according to how you wired the signals. I think this might work:

WiFi.UpdateFirmware(WiFi.HardwareModule.RS9110_N_11_21_1_Compatible, SPI.SPI_module.SPI2, (Cpu.Pin)2, (Cpu.Pin)26, (Cpu.Pin)3);// FEZ Cobra
                    WiFi.Enable(WiFi.HardwareModule.RS9110_N_11_21_1_Compatible, SPI.SPI_module.SPI2, (Cpu.Pin)2, (Cpu.Pin)26, (Cpu.Pin)3);// FEZ Cobra

For more information take a look ath Enable() and UpdateFirmware() mothod detailed documentation.

If the Green LED goes on on the module then it is enabled.

Thx Joe

It appears that i thought of the FEZ Cobra as a developement of EMX, and used that, i accidently made SPI2 once and that caused the green led to blink - but when it tried to update it used the SPI1 which ended with an exception