The Netduino forums have been replaced by new forums at community.wildernesslabs.co.
This site has been preserved for archival purposes only
and the ability to make new accounts or posts has been turned off.
Some time ago i added the "digital" word to the command, try it with this... And if you are still learning, have a look at "breakpoints" and step by step debugging (f10) in visual studio. This really helps finding code mistakes.
If you need help with NeonMika.Webserver, please just leave a note in the thread and/or contact me via Skype
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
--- Mistakes teach you important lessons. Every time you make one, you are one step closer to your goal. ----
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
Thanks for the update, with that change keyed into the address bar, It Works.
Maybe I have a version of your project before you made this change. Where do I look to see what version of your code I'm executing? Either way I'm gonna download & try it again.
The code I displayed back to you was from your original code and the documentation also shows it without the word Digital.
Again thank you for putting this together
Second I got a bug with it . Sometimes when I cancel file request the server stop response to any new requests.
I tracked the bug and I found it in this code
using (FileStream inputStream = new FileStream(filePath, FileMode.Open))
{
mainThread = Thread.CurrentThread;
Send200_OK(mType, (int)inputStream.Length, RequestArguments.Client);
byte[] readBuffer = new byte[Settings.FILE_BUFFERSIZE];
int sentBytes = 0;
//Sending parts in size of "Settings.FILE_BUFFERSIZE"
while (sentBytes < inputStream.Length)
{
int bytesRead = inputStream.Read(readBuffer, 0, readBuffer.Length);
try
{
Debug.Print("in try");
sentBytes += RequestArguments.Client.Send(readBuffer, bytesRead, SocketFlags.None);
}
catch (Exception ex) //ToDo: Error code if client closes browser during file transport
{
Debug.Print("Browser Closed");
System.Diagnostics.Debug.WriteLine(ex.Message);
return false;
}
Debug.Print("out of try");
}
}
return true;
the output
in try
out of try
in try
out of try
in try
A first chance exception of type 'System.Net.Sockets.SocketException' occurred in Microsoft.SPOT.Net.dll
Browser Closed
in try
out of try
in try
out of try
in try
out of try
in try
out of try
in try
out of try
in try
out of try
in try
out of try
in try
out of try
in try
out of try
in try
out of try
in try
out of try
in try
out of try
in try
out of try
in try
out of try
in try
out of try
in try
out of try
in try
out of try
in try
out of try
in try
out of try
in try
out of try
in try
out of try
in try
out of try
in try
out of try
in try
Failed allocation for 343 blocks, 4116 bytes
You need to use the "using" because sometimes (espacially if you send requests often and fast) your HttpWebResponse doesn't get "deconstructed" (was this the right term?). But this HAS to be done, otherwise the underlying Socket will keep blocking your new HttpWebRequest.
If you need help with NeonMika.Webserver, please just leave a note in the thread and/or contact me via Skype
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
--- Mistakes teach you important lessons. Every time you make one, you are one step closer to your goal. ----
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
Thanks Mark but this was not my prob
My prob with file response not HTTP. Sometimes if browser had been closed when loading file -ex. style.css- the server don't response to any new requests
it hangs in the try code and don't go to catch
If you need help with NeonMika.Webserver, please just leave a note in the thread and/or contact me via Skype
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
--- Mistakes teach you important lessons. Every time you make one, you are one step closer to your goal. ----
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
If you need help with NeonMika.Webserver, please just leave a note in the thread and/or contact me via Skype
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
--- Mistakes teach you important lessons. Every time you make one, you are one step closer to your goal. ----
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
Hello,
can you give me a little hint how I can connect and POST some text to remote IP address from Netduino+ without any request from outside (I want to use netduino to sent some request when motion sensor will discover movement or temperature will change)?
Regards
Netduino has some helper classes like HttpWebRequest etc., but i would suggest you to use Sockets.
To send a POST from Netduino to a server just create a Socket, bind it to the server's IP, and use mySocket.Write(...) to send the data.
Have a look at the wiki-page http://de.wikipedia....tocol#HTTP_POST to get some knowledge of http (if you don't have it already )
Greats, Markus
If you need help with NeonMika.Webserver, please just leave a note in the thread and/or contact me via Skype
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
--- Mistakes teach you important lessons. Every time you make one, you are one step closer to your goal. ----
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
If you need help with NeonMika.Webserver, please just leave a note in the thread and/or contact me via Skype
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
--- Mistakes teach you important lessons. Every time you make one, you are one step closer to your goal. ----
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
If you need help with NeonMika.Webserver, please just leave a note in the thread and/or contact me via Skype
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
--- Mistakes teach you important lessons. Every time you make one, you are one step closer to your goal. ----
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
ok my result is :
<Response>
<value_26>0</value_26>
<value_10>0</value_10>
<value_5>0</value_5>
</Response>
but I would have
<Response>
<id>26</id>
<value>0</value>
</Response>
<Response>
<id>10</id>
<value>0</value>
</Response>
<Response>
<id>26</id>
<value>0</value>
</Response>
Thank you for using Neonmika.Webserver. I sat down this night to develop a Little XML library which allows nested XML tags, Supports Arrays and hashtables, and a Little more. I will Post another reply when i uploaded the New Version, have to do some more debugging and speeding up
Greets Markus
If you need help with NeonMika.Webserver, please just leave a note in the thread and/or contact me via Skype
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
--- Mistakes teach you important lessons. Every time you make one, you are one step closer to your goal. ----
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
Here we go!
I am proudly presenting my little XML "library". So now you have support for nested XML.
Have a look at the following code to get a litte overview:
/// <summary>
/// Example for the useage of the new XML library
/// Use the hashtable if you don't need nested XML (like the standard xml responses)
/// If you need nested XML, use the XMLPair class. The Key-parameter is String.
/// As value the following types can be used to achieve nesting: XMLPair, XMLPair[] and Hashtable
/// </summary>
/// <param name="e"></param>
/// <param name="h"></param>
/// <returns></returns>
private void MultipleXML(RequestReceivedEventArgs e, Hashtable returnHashtable)
{
returnHashtable.Add("UseTheHashtable", "If you don't need nested XML");
XMLPair[] Phones = new XMLPair[2];
Phones[0] = new XMLPair("Phone");
Phones[1] = new XMLPair("Phone");
XMLPair[] PhoneAttributes0 = new XMLPair[2];
PhoneAttributes0[0] = new XMLPair("Type", "Nokia");
PhoneAttributes0[1] = new XMLPair("AvailableColours", new XMLPair[] {new XMLPair("Colour","Cyan"), new XMLPair("Colour","Black")});
Phones[0].Value = PhoneAttributes0;
XMLPair[] PhoneAttributes1 = new XMLPair[2];
PhoneAttributes1[0] = new XMLPair("Type", "HTC");
PhoneAttributes1[1] = new XMLPair("AvailableColours", new XMLPair("Colour", "Grey"));
Phones[1].Value = PhoneAttributes0;
returnHashtable.Add("Phones", Phones);
}
The above code will produce the following XML:
<!--XML created by NeonMika Webserver-->
<Response>
<Phones>
<Phone>
<Type>
Nokia
</Type>
<AvailableColours>
<Colour>
Cyan
</Colour>
<Colour>
Black
</Colour>
</AvailableColours>
</Phone>
<Phone>
<Type>
Nokia
</Type>
<AvailableColours>
<Colour>
Cyan
</Colour>
<Colour>
Black
</Colour>
</AvailableColours>
</Phone>
</Phones>
<UseTheHashtable>
If you don't need nested XML
</UseTheHashtable>
</Response>
If you need help with NeonMika.Webserver, please just leave a note in the thread and/or contact me via Skype
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
--- Mistakes teach you important lessons. Every time you make one, you are one step closer to your goal. ----
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
hello, great reactivity!
I just tried the test code "multixml" but I get the following error in the debuger when I call to the function / multixml:
customer connected
Final byte count: 315
Request URL = multixml
Start checking Requests
A first chance exception of type 'System.Exception' Occurred in NeonMika.XML.dll
WAS thrown exception: System.Exception
Puh, I'm not at home today and tomorrow, so I can't look into it...
Probably you can find the error by setting a breakpoint and walk step by step (F10 and F11) and watch in which line the exception is thrown.
I will look for the error asap. I'm really sorry, i tested it before uploading (it worked on my N+).
Greets, Markus
If you need help with NeonMika.Webserver, please just leave a note in the thread and/or contact me via Skype
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
--- Mistakes teach you important lessons. Every time you make one, you are one step closer to your goal. ----
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------