Project - FEZ Spider .Net Gadgeteer Button Pressed Display Webserver

FEZ Spider .Net Gadgeteer Button Pressed Display Webserver

This is a simple Webserver based on http://wiki.tinyclr.com/index.php?title=Webserver
with display output.

I was looking through many examples, but non worked with my FEZ Spider and Ethernet J11D.

So after hours, i figured out how to get it to work…

One Problem i had was that it didn’t work with a 5 m Ethernet Cable, changing to a 1 m one worked.

I’m sorry for any spelling mistakes, English isn’t my first language.

Comments are Welcome, specially on how i could improve this code.

i think it’s to complicated
if your using a spider youcan use the premium library
there is a complete webserver and client inside
mayby have a look at
http://www.tinyclr.com/codeshare/entry/367

you dont have to listen to a socket just using the event handlers

and be sorry my english is the same…

eth.NetworkUp += ...

doesn’t work for example

sorry i’m normaly using vb-coding
i think your initialization the ehternet is ok but then:

        GT.Networking.WebServer.StartLocalServer(.IPAddress, 80)

registeing a event handler
GT.Networking.WebEvent mvarWebHello = WebServer.SetupWebEvent(“Test”)

and the sub (void…) sorry it’s vb code but i think you can translate it


    Private Sub mvarWebHello_WebEventReceived(ByVal path As String, ByVal method As Gadgeteer.Networking.WebServer.HttpMethod, ByVal responder As Gadgeteer.Networking.Responder) 
        Dim mvarWebSite As String
        Dim mvarByte() As Byte

        Debug.Print("Anfrage Test Site")

        mvarWebSite = "<html><body><h1>Testseite</h1><h2><br>" + _
            DateTime.Now.ToString + "<br>" + _
            "<br>Hallo Welt</h2></body></html>"

        mvarByte = New System.Text.UTF8Encoding().GetBytes(mvarWebSite)

        responder.Respond(mvarByte, "text/html")

    End Sub

Hello, Are you using ENC28j60 Module?
I need to set up a UDP server using ENC28J60 and STM32F4 Discovery. But only SPI 3 is available free in these board. Please help me.

Regards
Vishal

@ vishalkm - posting the same question everywhere will make users not want to answer. Just a friendly advice.

@ vishalkm - [quote=“agp89”]
…FEZ Spider and Ethernet J11D.
[/quote]

Thank you, I need it urgently thats why i posted it in posts related to this. In the middle of project.

[/quote]

Thank you.

Hi,

I tried this example but cannot find the page you enter in the browser. I enter my ip-adress which I figured out via cmd. So the information is right.
The Display shows listening… and when I press button, then Button pressed!! But that’s all.
How can I find the page in the browser? I could see that you type 192.168.2.222. Is that nort ypur ip-adress or what I’m doing wrong?

I tried it with my own ip address that I found out via cmd --> ipconfig. So I’m sure that I enter the right ip adress but in the browser I get the message that it could not be connected.
Don’t you enter in the browser the IPv4-Adresse?That’s 192.168.2.109 on my pc.
I guess that I have connected wrongly. I put the network cable from ethernet to my router in LAN1. Is that right? Ethernet is in socket 7 like in the example and other modules are correct.

SB, what you need to do is find what the IP address of the Spider is, not of what your PC is. Do you know whether you’re using DHCP, and if so what the DHCP server shows for the IP address that you obtained? That’s the best place to look, in my view.

Then, in your browser, you need to enter the IP address of the device. If your PC’s address is 192.168.2.109, then your device should have a 192.168.2.x address, the only question is, what is X?

Of course you could also take a step back and debug the code and look at the IP address that the device is given. Heck, you could also expand the app to display the IP address on the display !

Hi Brett,
Dou you mean with ip of device the ip of the router or the ip of my router?
sorry for so many questions but i dont have much experience :frowning:
I just looked for dhcp what it means and I would say that I have dhcp because I don’t assign the ip address manually.

I just looked and saw that dhcp is deactivated when I look via cmd.
But in the router config in the browser it looks different. There it’s activated.

Can I add the device (modul manually)? But therefore I need the MAC…
What can I do with start and end-ip (s. attachment)?

there are 3 addresses that are important, but only 1 is really important for getting the web server to work from your PC.

Router-IP. This is the IP address of your home router. based on your PC’s network IPCONFIG info, that appears to be 192.168.2.1

PC-IP. This is 192.168.2.109, and is allocated by DHCP (you can see it’s allocated by 192.168.2.1, your router, towards the end of IPConfig output - not sure why you think it’s not using DHCP??)

Fez-IP. This is… ???

In image 3 we see that DHCP is on (Ein) and is allocating addresses from 100 to 199 in the subnet range 192.168.2.X. So if your Spider is set to use DHCP, and there are no other problems with your DHCP setup, your spider should be issued with an address from DHCP that is between 192.168.2.100 and 192.168.2.199.

So now, we see image 4. This looks to be the IP address leases. For some reason your Fez isn’t there.

So to diagnose this, I’d suggest you need to do:

ensure the Fez is set to use DHCP. Check using Fez Config, and check the code uses DHCP. This is something you’re going to have to dive into - if you don’t understand the depths of the code and networking, then I’d suggest you park this for a bit, get used to what’s going on in networking etc, and then revisit this later.

ensure the network layer initializes properly. Set breakpoints and use debug.print to check the program flow.

print out the IP address the Fez uses or is allocated, onto the screen.

… and then you’ll know the Fez-IP.

Once you know the Fez-IP, go to your browser, type that IP address, and bingo, you should get a connection.

Thank you very much for the useful information.
I looked in FEZ Config and find this information(s. attachment). All appeared after loading (button). Should I apply (button) and if yes which one?

Is the ip-adress in the program in visual studio the same like I try to open in the browser or are they different?

you can’t use 192.168.2.109 on both your PC and your Fez. You will get a conflict. Did you manually enter that at some stage?

Please refer to the IP addresses as I mentioned. Fez-IP, PC-IP.

PC-IP from your ipconfig output is 192.168.2.109. That is fine.

In Visual Studio, if you are STATICALLY applying an IP address, needs to be a different address to anything else on your network. Based on your DHCP server, you could use 192.168.2.199 safely, until you sort out why DHCP isn’t giving you a valid IP address.

At this stage I think you probably need a separate thread for your issue rather than polluting this thread about a specific project. Your issue is more fundamental than the project. Can you create a new thread.