Main Site Documentation

(solved) Http Server


#1

Not 100% sure what I changed, but its working now.

I’m running Firmware Version: 4.7.1.0
I’m running SDK Version: 1.0.17

I’m using MS VS C# 2010 Express

I have FEZ Panda II w/ connect shield

Background: I have a garage that has been broken into several times. As a first step I’d like to set up a system that email/text me when one of the doors open or close. I’ve been having some problems with the email/text part so I thought I’d try something simpler.

The network part is working.
I can ping 192.168.1.213 -t and get continual pings. I can unplug the Ethernet cable from the FEZ board and pings stop.

Part I cannot get to work is the webserver. If I open a browser and type in the IP address it just times out. Code is posted below, In a reply I will post the debug info.

Note: I posted earlier about email problem, that turned out to be a glitch and a reboot of my PC fixed it.


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;
public class Program
{
    public static void Main()
    {

        byte[] ip = { 192, 168, 1, 213 };
        byte[] subnet = { 255, 255, 255, 0 };
        byte[] gateway = { 192, 168, 1, 1 };
        byte[] mac = { 0x00, 0x26, 0x1C, 0x7B, 0x29, 0xE8 };
        WIZnet_W5100.Enable(SPI.SPI_module.SPI1, (Cpu.Pin)FEZ_Pin.Digital.Di10, (Cpu.Pin)FEZ_Pin.Digital.Di7, true);
        NetworkInterface.EnableStaticIP(ip, subnet, gateway, mac);
        NetworkInterface.EnableStaticDns(new byte[] { 192, 168, 1, 1 });

        const Int32 c_port = 80;

        HttpListener listener = new HttpListener("http", c_port);
        listener.Start();
        while (true)
        {
            HttpListenerResponse response = null;
            HttpListenerContext context = null;
            try
            {
                context = listener.GetContext();
                response = context.Response;
                // We are ignoring the request, assuming GET
                // HttpListenerRequest request = context.Request;
                // Sends response:
                response.StatusCode = (int)HttpStatusCode.OK;
                byte[] HTML = Encoding.UTF8.GetBytes("<html><body><h1>FEZ Panda</h1><p>Hello!</p></body></html>");
                response.ContentType = "text/html";
                response.OutputStream.Write(HTML, 0, HTML.Length);
                response.Close();
            }
            catch
            {
                if (context != null)
                {
                    context.Close();
                }
            }
        }
    }
}


#2

Rebooting…

Done.

Create TS.

Loading start at 4ebac, end 56d84

Attaching file.

Assembly: mscorlib (4.1.2821.0) (3880 RAM - 33236 ROM - 19134 METADATA)

AssemblyRef = 0 bytes ( 0 elements)

TypeRef = 0 bytes ( 0 elements)

FieldRef = 0 bytes ( 0 elements)

MethodRef = 0 bytes ( 0 elements)

TypeDef = 1112 bytes ( 139 elements)

FieldDef = 272 bytes ( 135 elements)

MethodDef = 1572 bytes ( 786 elements)

Attributes = 0 bytes ( 0 elements)

TypeSpec = 16 bytes ( 4 elements)

Resources = 232 bytes ( 29 elements)

Resources Files = 16 bytes ( 2 elements)

Resources Data = 437 bytes

Strings = 1551 bytes

Signatures = 2126 bytes

ByteCode = 11702 bytes

Loading Deployment Assemblies.

Attaching deployed file.

Assembly: GHIElectronics.NETMF.W5100.Http (4.1.7.0) (2856 RAM - 35312 ROM - 12312 METADATA)

AssemblyRef = 8 bytes ( 2 elements)

TypeRef = 212 bytes ( 53 elements)

FieldRef = 8 bytes ( 2 elements)

MethodRef = 540 bytes ( 135 elements)

TypeDef = 408 bytes ( 51 elements)

FieldDef = 336 bytes ( 168 elements)

MethodDef = 804 bytes ( 402 elements)

Attributes = 0 bytes ( 0 elements)

TypeSpec = 4 bytes ( 1 elements)

Resources = 0 bytes ( 0 elements)

Resources Files = 0 bytes ( 0 elements)

Resources Data = 0 bytes

Strings = 8391 bytes

Signatures = 1764 bytes

ByteCode = 14483 bytes

Attaching deployed file.

Assembly: FEZ Panda II Application1 (1.0.0.0) (412 RAM - 2088 ROM - 844 METADATA)

AssemblyRef = 20 bytes ( 5 elements)

TypeRef = 96 bytes ( 24 elements)

FieldRef = 0 bytes ( 0 elements)

MethodRef = 84 bytes ( 21 elements)

TypeDef = 40 bytes ( 5 elements)

FieldDef = 16 bytes ( 7 elements)

MethodDef = 12 bytes ( 5 elements)

Attributes = 0 bytes ( 0 elements)

TypeSpec = 0 bytes ( 0 elements)

Resources = 16 bytes ( 2 elements)

Resources Files = 8 bytes ( 1 elements)

Resources Data = 13 bytes

Strings = 754 bytes

Signatures = 168 bytes

ByteCode = 307 bytes

Attaching deployed file.

Assembly: GHIElectronics.NETMF.System (4.1.7.0) (488 RAM - 2496 ROM - 1465 METADATA)

AssemblyRef = 12 bytes ( 3 elements)

TypeRef = 48 bytes ( 12 elements)

FieldRef = 0 bytes ( 0 elements)

MethodRef = 56 bytes ( 14 elements)

TypeDef = 80 bytes ( 10 elements)

FieldDef = 28 bytes ( 14 elements)

MethodDef = 84 bytes ( 41 elements)

Attributes = 0 bytes ( 0 elements)

TypeSpec = 0 bytes ( 0 elements)

Resources = 0 bytes ( 0 elements)

Resources Files = 0 bytes ( 0 elements)

Resources Data = 0 bytes

Strings = 549 bytes

Signatures = 213 bytes

ByteCode = 349 bytes

Attaching deployed file.

Assembly: Microsoft.SPOT.Hardware (4.1.2821.0) (1752 RAM - 11440 ROM - 7371 METADATA)

AssemblyRef = 8 bytes ( 2 elements)

TypeRef = 124 bytes ( 31 elements)

FieldRef = 24 bytes ( 6 elements)

MethodRef = 120 bytes ( 30 elements)

TypeDef = 496 bytes ( 62 elements)

FieldDef = 176 bytes ( 88 elements)

MethodDef = 444 bytes ( 222 elements)

Attributes = 0 bytes ( 0 elements)

TypeSpec = 0 bytes ( 0 elements)

Resources = 0 bytes ( 0 elements)

Resources Files = 0 bytes ( 0 elements)

Resources Data = 0 bytes

Strings = 1329 bytes

Signatures = 1067 bytes

ByteCode = 2611 bytes

Attaching deployed file.

Assembly: Microsoft.SPOT.Native (4.1.2821.0) (1144 RAM - 6516 ROM - 4479 METADATA)

AssemblyRef = 4 bytes ( 1 elements)

TypeRef = 80 bytes ( 20 elements)

FieldRef = 0 bytes ( 0 elements)

MethodRef = 60 bytes ( 15 elements)

TypeDef = 336 bytes ( 42 elements)

FieldDef = 192 bytes ( 95 elements)

MethodDef = 224 bytes ( 111 elements)

Attributes = 48 bytes ( 6 elements)

TypeSpec = 0 bytes ( 0 elements)

Resources = 72 bytes ( 9 elements)

Resources Files = 8 bytes ( 1 elements)

Resources Data = 747 bytes

Strings = 648 bytes

Signatures = 595 bytes

ByteCode = 418 bytes

Attaching deployed file.

Assembly: GHIElectronics.NETMF.Hardware (4.1.7.0) (1268 RAM - 8732 ROM - 5109 METADATA)

AssemblyRef = 12 bytes ( 3 elements)

TypeRef = 100 bytes ( 25 elements)

FieldRef = 0 bytes ( 0 elements)

MethodRef = 104 bytes ( 26 elements)

TypeDef = 320 bytes ( 40 elements)

FieldDef = 128 bytes ( 64 elements)

MethodDef = 312 bytes ( 156 elements)

Attributes = 0 bytes ( 0 elements)

TypeSpec = 0 bytes ( 0 elements)

Resources = 0 bytes ( 0 elements)

Resources Files = 0 bytes ( 0 elements)

Resources Data = 0 bytes

Strings = 2190 bytes

Signatures = 697 bytes

ByteCode = 1301 bytes

Attaching deployed file.

Assembly: GHIElectronics.NETMF.W5100 (4.1.7.0) (1028 RAM - 11556 ROM - 4106 METADATA)

AssemblyRef = 12 bytes ( 3 elements)

TypeRef = 100 bytes ( 25 elements)

FieldRef = 0 bytes ( 0 elements)

MethodRef = 132 bytes ( 33 elements)

TypeDef = 192 bytes ( 24 elements)

FieldDef = 88 bytes ( 43 elements)

MethodDef = 244 bytes ( 122 elements)

Attributes = 0 bytes ( 0 elements)

TypeSpec = 0 bytes ( 0 elements)

Resources = 0 bytes ( 0 elements)

Resources Files = 0 bytes ( 0 elements)

Resources Data = 0 bytes

Strings = 1450 bytes

Signatures = 734 bytes

ByteCode = 5872 bytes

Attaching deployed file.

Assembly: FEZPanda_II_GHIElectronics.NETMF.FEZ (4.1.7.0) (304 RAM - 904 ROM - 495 METADATA)

AssemblyRef = 12 bytes ( 3 elements)

TypeRef = 44 bytes ( 11 elements)

FieldRef = 0 bytes ( 0 elements)

MethodRef = 20 bytes ( 5 elements)

TypeDef = 72 bytes ( 9 elements)

FieldDef = 12 bytes ( 6 elements)

MethodDef = 4 bytes ( 2 elements)

Attributes = 0 bytes ( 0 elements)

TypeSpec = 0 bytes ( 0 elements)

Resources = 0 bytes ( 0 elements)

Resources Files = 0 bytes ( 0 elements)

Resources Data = 0 bytes

Strings = 182 bytes

Signatures = 35 bytes

ByteCode = 98 bytes

Resolving.

Total: (11268 RAM - 112280 ROM - 55315 METADATA)

AssemblyRef = 88 bytes ( 22 elements)

TypeRef = 804 bytes ( 201 elements)

FieldRef = 32 bytes ( 8 elements)

MethodRef = 1116 bytes ( 279 elements)

TypeDef = 3056 bytes ( 382 elements)

FieldDef = 1248 bytes ( 620 elements)

MethodDef = 3700 bytes ( 1847 elements)

DebuggingInfo = 1864 bytes

Attributes = 48 bytes ( 6 elements)

TypeSpec = 20 bytes ( 5 elements)

Resources Files = 96 bytes ( 4 elements)

Resources = 320 bytes ( 40 elements)

Resources Data = 1197 bytes

Strings = 17044 bytes

Signatures = 7399 bytes

ByteCode = 37141 bytes

The debugging target runtime is loading the application assemblies and starting execution.
Ready.

‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.1\Assemblies\le\mscorlib.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.1\Assemblies\le\Microsoft.SPOT.Native.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.1\Assemblies\le\Microsoft.SPOT.Hardware.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files (x86)\GHI Electronics\GHI NETMF v4.1 SDK\Assemblies\le\GHIElectronics.NETMF.W5100.dll’
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files (x86)\GHI Electronics\GHI NETMF v4.1 SDK\Assemblies\le\GHIElectronics.NETMF.W5100.Http.dll’
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Users\Modified(took out my name)\Desktop\FEZ Panda II HTTP\FEZ Panda II Application1\bin\Debug\le\FEZ Panda II Application1.exe’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files (x86)\GHI Electronics\GHI NETMF v4.1 SDK\Assemblies\le\GHIElectronics.NETMF.System.dll’
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files (x86)\GHI Electronics\GHI NETMF v4.1 SDK\Assemblies\le\GHIElectronics.NETMF.Hardware.dll’
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded 'C:\Program Files (x86)\GHI Electronics\GHI NETMF v4.1 SDK\Assemblies\le\FEZPanda_II_GHIElectronics.NETMF.FEZ.dll’
The thread ‘’ (0x2) has exited with code 0 (0x0).