Hi everybody, I have a FEZ Spider II and I’m starting using visual studio with C#.
I’m using this code, it starts a webserver at 192.168.100.2 (given though fez config), it takes a picture, but then when I want to see the pic, the uploading lasts too much and ends with half image uploaded and a debug error. Can you help me? Thanks.
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.Presentation.Shapes;
using Microsoft.SPOT.Touch;
using Gadgeteer.Networking;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using Gadgeteer.Modules.GHIElectronics;
namespace Ethernet2
{
public partial class Program
{
Gadgeteer.Networking.WebEvent hello;
Gadgeteer.Networking.WebEvent takePicture;
Gadgeteer.Networking.WebEvent seePicture;
GT.Picture pic = null;
// This method is run when the mainboard is powered up or reset.
void ProgramStarted()
{
ethernetJ11D.UseThisNetworkInterface();
ethernetJ11D.NetworkUp += new GTM.Module.NetworkModule.NetworkEventHandler(ethernet_NetworkUp);
ethernetJ11D.NetworkDown += new GTM.Module.NetworkModule.NetworkEventHandler(ethernet_NetworkDown);
camera.PictureCaptured += new Camera.PictureCapturedEventHandler(camera_PictureCaptured);
// Use Debug.Print to show messages in Visual Studio's "Output" window during debugging.
Debug.Print("Program Started");
}
void camera_PictureCaptured(Camera sender, GT.Picture picture)
{
pic = picture;
}
private void ethernet_NetworkDown(GTM.Module.NetworkModule sender, GTM.Module.NetworkModule.NetworkState state)
{
Debug.Print("Network is down!");
}
void ethernet_NetworkUp(GTM.Module.NetworkModule sender, GTM.Module.NetworkModule.NetworkState state)
{
Debug.Print("Network is up!");
Debug.Print("IP address: " + ethernetJ11D.NetworkSettings.IPAddress);
Gadgeteer.Networking.WebServer.StartLocalServer(ethernetJ11D.NetworkSettings.IPAddress, 80);
hello = Gadgeteer.Networking.WebServer.SetupWebEvent("hello");
hello.WebEventReceived += new WebEvent.ReceivedWebEventHandler(hello_WebEventReceived);
takePicture = Gadgeteer.Networking.WebServer.SetupWebEvent("takepicture");
takePicture.WebEventReceived += new WebEvent.ReceivedWebEventHandler(takePicture_WebEventReceived);
seePicture = Gadgeteer.Networking.WebServer.SetupWebEvent("seepicture");
seePicture.WebEventReceived += new WebEvent.ReceivedWebEventHandler(seePicture_WebEventReceived);
}
void seePicture_WebEventReceived(string path, WebServer.HttpMethod method, Responder responder)
{
if (pic != null)
{
responder.Respond(pic);
}
else
responder.Respond("Take picture first");
}
void takePicture_WebEventReceived(string path, WebServer.HttpMethod method, Responder responder)
{
responder.Respond("Taking picture");
camera.TakePicture();
}
void hello_WebEventReceived(string path, WebServer.HttpMethod method, Responder responder)
{
Debug.Print("Hello world");
responder.Respond("Hello world");
}
}
}
A first chance exception of type ‘System.Net.Sockets.SocketException’ occurred in Microsoft.SPOT.Net.dll
#### SocketException ErrorCode = 10060
#### SocketException ErrorCode = 10060
#### SocketException ErrorCode = 10060
Exception sending web event response (connection was probably terminated)
The thread ‘’ (0xc) has exited with code 0 (0x0).
I would not recommend using the gadgeteer core, especially with networking. Use the drivers to initialize networking maybe but from there use pure netmf code.
Ok I used the code in the example, but using the built in ethernet how can I use the J11D module? To make work the code I had to disconnect the module in the schematic, and so the functions to take and see the picture don’t work anymore because based on the module.
Moreover with the code I have a debug output:
Network address changed
Network availability: TRUE
but if I connect to 192.168.100.2 is not reachable.
Thank you @ RoSchmi
I used your code but still got the same error, and the image is not loaded.
I added all the file of webserver43, but the file with the bug was already correct (indeed I have problem not creating a webserver (that works) but when I want to see the picture taken).
I also added the whole project webserver43 but if I build it, it gives me error:
Error 1 Metadata file ‘C:\Users\Carl\Downloads\gadgeteer-43877\Main\GadgeteerCore\Gadgeteer43\bin\Debug\Gadgeteer.dll’ could not be found C:\Users\Carl\Downloads\gadgeteer-43877\Main\GadgeteerCore\Libraries\Core\WebServer43\CSC
As I understand your answer, that if you enter http://192.168.xxx.xxx/hello in the browser you get the answer hello world.
If this works, continue to set breakpoints in the responder Class.
@ RoSchmi - I put breakpoint in the responder class (responder.cs file) and it gives me no error.
I write hello->no problem
I write takePicture->no problem
I write seePicture->no problem, then the debug error appears
I rewrite hello->it works
@ Arcixx - I would now set breakpoints in every line of code in the responder class method SendResponse() and step through with F5 to see the command which really causes the exception.
What do you mean with : “I write seePicture->no Problem” ? Does the picture appear in your browser/http Client. Which browser are you using? Did you try to inactivate the firewall?
@ RoSchmi - so doing the line by line debug it still asks me a dispatcher.cs file, I press step out and it does another cycle, then the takepicture works (same for the seepicture).
When I write seepicture it executes untill line 13, it starts to load the image, then back to visual studio with the error and we are at line 17. I use mozilla and I have disabled firewall but still nothing.
:think: that’s strange. On my side the code works and the complete picture is loaded by the browser (internet explorer).
Did you verify with FEZConfig that you have the latest firmware and the matching GHI SDK on your PC.
Perhaps now it’s time to use wireshark to watch the net traffic between Spider II and PC.
@ RoSchmi - Yes everything updated and using netmf4.3
Maybe tomorrow or the day after I can try on a different pc.
I’m sorry but I don’t have any knowledge on wireshack, I have installed it but I don’t know what to watch.
If you can lead me we can try, by the way thank you for your patience.
@ Arcixx - I’ve had a couple of issues like this, spent two days troubleshooting a problem to have it disappear after a reboot. I’ve gotten to the point, I make sure I do a reboot prior to deploying in field code. Just curious if you tried that yet.
Yes, very strange.
I’m no expert on wireshark as well, but if you start it, start capture, start the Ethernet interface and write ip.addr == 192.168.100.2 in the filter Combo field and click Apply you should see the traffic of your PC and Spider II