Main Site Documentation

Error on Gadgeteer.Modules.GHIElectronics.HttpResponse.Send


#1

I have an error with the following code using the FEZ Spider:


using System;
using System.Collections;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Presentation.Media;
using Microsoft.SPOT.Touch;

using GHI.Premium.System;
using GHI.Premium.USBHost;
using Gadgeteer.Networking;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using Gadgeteer.Modules.GHIElectronics;

namespace GadgeteerApp2
{
    public partial class Program
    {

	private static void HandleHttpRequest(GTM.GHIElectronics.HttpStream request, string requestedURL)
        	{
            	
            	string action = "Unkown action";
            	if (requestedURL == "/index.html")
           	 {
               	 action = "Hello World";
            	}
            	else
            	{
               	 action = "Unknown action";
            	}

            	request.Response.HeaderData["Content-type"] = "text/html; charset=utf-8";
            	request.Response.HeaderData["Connection"] = "close";
           	request.Response.HeaderData["Cache-Control"] = "no-cache";
           	request.Response.StatusCode = GTM.GHIElectronics.HttpResponse.ResponseStatus.OK;
            	request.Response.Send("<html><head><title>Webpage</title><META http-equiv=Content-Type content=\"text/html; charset=windows-1252\"></head><body>HELLO!</body></html>");
        	}

        	void wifi_RN171_HttpRequestReceived(GTM.GHIElectronics.HttpStream request)
        	{
            		string requestedURL = request.Request.URL;
            		
            		if (requestedURL == "/index.html")
            		{
                		request.Response.HeaderData["Content-type"] = "text/html";
               		 request.Response.HeaderData["Connection"] = "close";
               	 	request.Response.HeaderData["Cache-Control"] = "no-cache";
               	 	request.Response.StatusCode = GTM.GHIElectronics.HttpResponse.ResponseStatus.OK;
             		}
        	}
      }
}

The Error comes in the Debug; here are the Debug statements in the Output.

Assembly: mscorlib (4.2.0.0)
Assembly: Microsoft.SPOT.Native (4.2.0.0)
Assembly: Microsoft.SPOT.Security.PKCS11 (4.2.0.0)
Assembly: System.Security (4.2.0.0)
Loading Deployment Assemblies.

Attaching deployed file.

Assembly: Gadgeteer.WebServer (2.42.0.0) Attaching deployed file.
Assembly: Microsoft.SPOT.Net.Security (4.2.0.0) Attaching deployed file.
Assembly: GTM.GHIElectronics.UsbHost (1.1.2.0) Attaching deployed file.
Assembly: Microsoft.SPOT.Net (4.2.0.0) Attaching deployed file.
Assembly: Gadgeteer.SPI (2.42.0.0) Attaching deployed file.
Assembly: GHI.Premium.IO (4.2.10.0) Attaching deployed file.
Assembly: Microsoft.SPOT.Hardware.PWM (4.2.0.1) Attaching deployed file.
Assembly: GHIElectronics.Gadgeteer.FEZSpider (1.1.2.0) Attaching deployed file.
Assembly: GTM.GHIElectronics.UsbClientSP (1.1.2.0) Attaching deployed file.
Assembly: Microsoft.SPOT.Hardware.SerialPort (4.2.0.0) Attaching deployed file.
Assembly: Gadgeteer.WebClient (2.42.0.0) Attaching deployed file.
Assembly: GHI.Premium.System (4.2.10.0) Attaching deployed file.
Assembly: System.Net.Security (4.2.0.0) Attaching deployed file.
Assembly: System (4.2.0.0) Attaching deployed file.
Assembly: Microsoft.SPOT.Touch (4.2.0.0) Attaching deployed file.
Assembly: GadgeteerApp2 (1.0.0.0) Attaching deployed file.
Assembly: GHI.Premium.USBHost (4.2.10.0) Attaching deployed file.
Assembly: Gadgeteer.DaisyLink (2.42.0.0) Attaching deployed file.
Assembly: System.Http (4.2.0.0) Attaching deployed file.

Assembly: Gadgeteer.Serial (2.42.0.0) Attaching deployed file.
Assembly: GHI.Premium.Hardware (4.2.10.0) Attaching deployed file.
Assembly: GTM.GHIElectronics.WiFi_RN171 (1.0.2.0) Attaching deployed file.
Assembly: GTM.GHIElectronics.Display_TE35 (1.1.3.0) Attaching deployed file.
Assembly: Microsoft.SPOT.TinyCore (4.2.0.0) Attaching deployed file.
Assembly: System.IO (4.2.0.0) Attaching deployed file.
Assembly: Microsoft.SPOT.Hardware (4.2.0.0) Attaching deployed file.
Assembly: Microsoft.SPOT.Graphics (4.2.0.0) Attaching deployed file.
Assembly: Microsoft.SPOT.IO (4.2.0.0) Attaching deployed file.

Assembly: Gadgeteer (2.42.0.0) Resolving.

Resolve: unknown method: Gadgeteer.Modules.GHIElectronics.HttpResponse.Send

Error: ff000000

Waiting for debug commands…

Any ideas of what may be causing this error?


#2

Welcome to the forum.

What version of the firmware is on your device?


#3

The firmware is version 4.2.10.1


#4

@ andre.m - A USBHost is also being used in this program. Commenting out the “using Gadgeteer.Modules.GHIElectronics” causes an error asking for a “missing directive or assembly reference”


#5

Update:
I have further simplified the code using Example 1: Simple Server (Found here: https://www.ghielectronics.com/docs/178/wifi-rn171-module).


using System;
using System.Collections;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Presentation.Media;
using Microsoft.SPOT.Touch;

using GHI.Premium.System;
using GHI.Premium.USBHost;
using Gadgeteer.Networking;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using Gadgeteer.Modules.GHIElectronics;

namespace GadgeteerApp2
{
    public partial class Program
    {
        void ProgramStarted()
        {
	Debug.Print("Program Started begin");

	wifi_RN171.Initialize(GTM.GHIElectronics.WiFi_RN171.SocketProtocol.TCP_Server); //Init as TCP Server

              wifi_RN171.EnableHttpServer(); //Enable HTTP Parsing    
       
              wifi_RN171.HttpRequestReceived += new GTM.GHIElectronics.WiFi_RN171.HttpRequestReceivedHandler(wifi_RN171_HttpRequestReceived);
        }	
	
        void wifi_RN171_HttpRequestReceived(GTM.GHIElectronics.HttpStream request)
        {
            	string requestedURL = request.Request.URL;
            
	if (requestedURL == "/index.html")
               {
                request.Response.HeaderData["Content-type"] = "text/html";
                request.Response.HeaderData["Connection"] = "close";
                request.Response.HeaderData["Cache-Control"] = "no-cache";
                request.Response.StatusCode = GTM.GHIElectronics.HttpResponse.ResponseStatus.OK;

                // All you have to do is send the document data through the response object.
                // Header data is automatically applied for you when you chose to send.
                request.Response.Send(System.Text.Encoding.UTF8.GetBytes("<html><head></head><body>HELLO!</body></html>"));
                } 
               
        }
    }
}

The following is the end of the Debug Outputs where the error occurs:

Using mainboard GHI Electronics FEZSpider version 1.0
Program Started begin
#### Exception System.Exception - CLR_E_WRONG_TYPE (4) ####
#### Message:
#### System.Text.UTF8Encoding::GetChars [IP: 0000] ####
#### Gadgeteer.Modules.GHIElectronics.WiFi_RN171::_Serial_Data_Received [IP: 0009] ####
#### Gadgeteer.Modules.GHIElectronics.WiFi_RN171::_Serial_Listen [IP: 0031] ####
A first chance exception of type ‘System.Exception’ occurred in mscorlib.dll
An unhandled exception of type ‘System.Exception’ occurred in mscorlib.dll

Any suggestions?


#6

@ rlasnik - What is the nature of the request, and what source does it originate from?


#7

@ rlasnik Are you using the RN171 module? Possibly this link will add info https://www.ghielectronics.com/community/forum/topic?id=12286&page=1

@ James “Default baud rate issue has been resolved and will make it into the next SDK along with a method to change the baudrate at runtime. We will review your other proposed changes for applicability.”

Any progress James? When is the next release?


#8

@ KG1 -

the SDK is done and available. Find it under Support->.Net Micro Framework., step 3 You want “NETMF and Gadgeteer Package 2013 R2”


#9

Hi Jeff, Please confirm that the changes to the RN171 module that James talked about have been included in "NETMF and Gadgeteer Package 2013 R2"
Kevin


#10

sorry for the delay! – Yes default baud rate, and the ability to change it are in the new sdk.


#11

Thank you Jeff. I can see the changes in the new source code.