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.
The you can access the SD-card by writing htttp://192.168.0.200/SD or directly the file by writing http.//192.168.0.200/SD/BData.txt
The workflow is as follows:
The server checks if the incoming request is POST.
If so, the PostToSdWrite saves the file in the lastPOST-file
After that, the normal "Request handling" starts... This happens by looking at the parameter, in our case "upload"...
This triggers the method Upload(...) in the Server.cs (line 675)... As you can see there, it creates the directory if it doesn't exists and opens the file with FileStream fs = new FileStream(filePath, FileMode.Create, FileAccess.Write);
FileMode.Create should automatically create the file if it doesn't exist (it does this in my case, didn't have a BData.txt before uploading it)
Attached you can find the "tool" i use for uploading, sorry, I don't have a web-page that does it... As I mentioned before I think its important to use request.ContentType = "application/x-www-form-urlencoded";
Sorry that I cannot give you input on how to handle this in html-code, since I'm only a desktop-dev and have nothing to do with web-development *shame on me*
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. ----
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
Thank you very much for sharing your library. I've been learning a lot about networking and c# code.
I'm trying to modify your library so that the static IP address of the netduino could be changed through the browser. I'm still new to c# and networking code in general, so this is proving quite difficult for me. I've tried adding the following expansion method to the server class and adding it to the server via your AddResponse method.
This is more "best practice" and more readable. When concatinating a string with another "non-string"-object (in this case of type object I think), ToString() automatically gets called on the second object (That why you can write string foo = "myblablavariable" + 14; and don't have to write string foo = "myblablavariable" + (14).ToString())
Probably if you could post the exceptions thrown by a call of the method I could help you more.
This was also my first big project on networking and so I can't tell you if you have to do something before calling interf.EnableStaticIP(ipAddress, subnetMask, gateWay);
If we can't work it out I'm pretty sure Chris Walker can help us out, he's far more levels above me when it come to Micro Framework
A last question from my side: Why do you need the method?
When starting the server you can set the IP like in the following example:
Server WebServer = new Server(PinManagement.OnboardLED, 80, false, "192.168.0.200", "255.255.255.0", "192.168.0.1", "NETDUINOPLUS");
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. ----
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
Thank you for your reply and assistance Markus. I added a Debug print at the beginning of my newIP method like so to see if it was even getting called:
public void newIP(Request e, Hashtable h)
{
Debug.Print("newIP was called");
String ipAddress = "";
String subnetMask = "";
String gateWay = "";
And it wasn't. This is the output I got after using the above URL, including the exceptions you wanted to see:
Client connected
URL: newIP
Final byte count: 506
A first chance exception of type 'System.IO.IOException' occurred in Microsoft.SPOT.IO.dll
A first chance exception of type 'System.IO.IOException' occurred in Microsoft.SPOT.IO.dll
Sent 404 Not Found
Reqeust finished
I think there may be a chance I don't have the library set up properly to make modifications to it. As I said before I'm still new to c#, visual studio, and network code. I have two projects set up, one from your WebserverExecutable and one from your Webserver. I modify the code in Webserver, rebuild it after the changes I make, then I delete the reference to NeonMika.Webserver in the WebserverExecutable project and remake the reference to the newly rebuilt .dll file for the Webserver. Is that the proper way to make the changes I'm trying to implement to the library? It feels like I'm missing something.
I want to be able to change the IP of my netduino over the network so it can be managed remotely. It is actually being potentially used on a pretty large scale project for my employer. If I can get the devices to perform as needed, there may be as many as 100 netduinos deployed in one of our shops. Each will be attached to an RFID reader and will be hooked up to a controller for a manufacturing cell that makes parts. Our operators will have an RFID card given to them that will be read by the netduino to have the machine select the appropriate die set for their part and will tell the netduino how to collect data for the particular parts we're making. We need to be able to configure almost everything about the netduino remotely, as making changes to so many units locally would be tedious. It's a pretty cool project! I'd be more than happy to keep you up to date on how it turns out.
There is the "default way" how to start a project using NeonMika.Webserver.
I'm pretty sure it has to do with the webserver-code. Have you tried to debug Server.cs? Setting a breakpoint in WaitingForRequest and stepping through the code with F5, F10 and F11 enables you to inspect the code in real detail (especially F11).
It would be very interesting at which point the error occurs.
Sorry that I cannot point out more at this point. but if you find the code-line on which the error accurs I can try to help further
You project sounds really cool! Would be really nice to see NeonMika.Webserver participate in such a big project. Please keep me updated how it works out!
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. ----
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
I had the opportunity to work on my project again this morning. I set up a project as described in the post you linked to me, and now I can tell my newIP method is getting called. The request finishes and throws no errors, however the IP address doesn't change. Any idea what to do next?
Here's what my method currently looks like:
public void newIP(Request e, Hashtable h)
{
Debug.Print("newIP was called");
String ip = "";
String subnetMask = "";
String gateWay = "";
if (e.GetArguments.Contains("ip"))
{
if (e.GetArguments.Contains("subnet"))
{
if (e.GetArguments.Contains("gateway"))
{
ip = e.GetArguments["ip"].ToString();
subnetMask = e.GetArguments["subnet"].ToString();
gateWay = e.GetArguments["gateway"].ToString();
Debug.Print(ip + " " + subnetMask + " " + gateWay);
}
}
}
var interf = NetworkInterface.GetAllNetworkInterfaces()[0];
interf.EnableStaticIP(ip, subnetMask, gateWay);
NameService nameService = new NameService();
nameService.AddName("NETDUINOPLUS", NameService.NameType.Unique, NameService.MsSuffix.Default);
}
I just put those last two lines with the NameService method in. I wasn't sure if they'd be necessary or not. Here's the response I get from my debug output:
Hi Michael, I'm sorry, but I don't know much about the network-setting possibilities and methods of the N+. As recommended above I think it would be a good idea to contact Chris Walker or open another thread in the N+ Forum, I'm sure someone else can give you a hint.
I'm without internet this from now to monday, so I cannot look it up for you.
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. ----
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
Just wondered if this could work with the MiP library in order to use it on N GO! and standard netduino 1?
Also would it be possible to use MQTT with it?
Many thanks
Andy
Hi Andy!
I don't own a N GO! nor a standard netduino, so I don't know about the MiP library.
I also don't really know how the MQTT works, just saw some projects on here. I don't think that they use the default HTTP-header (which is eg. added when calling the netduino via the browser), so I don't think that it would work without adjusting the server. But I could imagine that a little hacking could work out to combine NeonMika.Webserver with one of the MQTT-projects Nothing is impossible
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. ----
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
I have Visual Studio 2010 Pro, and i can´t open neonmika webserver 1.2 executable in VS2010.
I make a new project in VS2010 with framework and start webserver en Program.cs. I get an uncontrolled exception: 'System.Net.Sockets.SocketException' en Microsoft.SPOT.Net.dll
That occurrs when NameService.cs is running on line:
int count = socket.ReceiveFrom(buffer, ref remoteEndPoint); // Blocking call, returns 0 when socket is closed
Then, I try change VS project .sln to version 11 and VS2010, but i get same exception.
I cannot tell if the project works in VS 2010, I developed it in VS 2012.
You could try to install VS 2012 express, this should be freely available for everybody. At least I think so, as a student every microsoft development tool is free for me
I only have 2012 and 2013 installed at the moment, so I'm sorry that I cannot test it at the moment. Please let us know if and how you get it working
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. ----
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
I want send serial commands, like "R1D\r\n" and process the reply (like "1FFFFF\r\n")
I tried with this code, and works, but when i put it in NeonMika's project fault at serial.Open()M
using System;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using Microsoft.SPOT;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.NetduinoPlus;
using System.IO;
using System.IO.Ports;
namespace NetduinoPlusApplication1
{
public class Program
{
public static void Main()
{
string comando = "R10\r\n";
byte[] utf8Bytes = System.Text.Encoding.UTF8.GetBytes(comando);
SerialPort serial = new SerialPort("COM1", 9600, Parity.None, 8, StopBits.One);
serial.Open();
while (true)
{
// Get full date & time
serial.Write(utf8Bytes, 0, utf8Bytes.Length);
getResponse(serial);
Thread.Sleep(1000);
}
}
private static void getResponse(SerialPort serial)
{
String response = "";
while (serial.BytesToRead > 0)
{
byte[] buf = new byte[1];
serial.Read(buf, 0, 1);
if (buf[0] != 0x0A)
{
response += (char)buf[0];
}
else
{
Debug.Print(response);
break;
}
}
}
}
}
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. ----
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------