Netduino home hardware projects downloads community

Jump to content


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.

hari

Member Since 21 Aug 2010
Offline Last Active Nov 29 2012 04:04 AM
-----

#9423 netduino XBee Sample

Posted by hari on 13 February 2011 - 05:46 PM

Coincidentally, I was playing with xbees the other day and made these two videos.
One end is a FEZ Domino, the other end is a Netduino.
Not exactly a tutorial, but you may find it interesting.

http://www.youtube.com/watch?v=3BaEKbKiCIo

You may want to watch this one on youtube to so you can read the text. Posted Image
http://www.youtube.com/watch?v=DLTohG6iODM


#2993 Simple Netduino Webserver

Posted by hari on 27 September 2010 - 07:20 AM

Well, it's not really a webserver, but it listens to webrequests and do things based on the requested urls.
Thanks to OZ for hinting Socket.Listen() in his video.

http://www.youtube.com/watch?v=RfI-yCQXT8Y

The video shows a JQueryUI page, but the actual urls that do the work are: http://x.x.x.x/led/1 and http://x.x.x.x/led/0
See Test.htm and ConsumeNetduino.htm within the attached source.

public static void Main()
{
    WebServer webServer = new WebServer();

    while (true)
    {
        int requestLength = webServer.WaitForRequest(new RequestReceivedDelegate(RequestReceived));
        if (requestLength > 0)
        {
            //-- Build response --
            responseStr = "HTTP/1.1 200 OK\nContent-Type: text/html\n\n";
            responseStr += ProcessRequest(receivedStr);
            
            // IMPORTANT: SendResponse() sends response AND closes the connection, please call only once per request.
            webServer.SendResponse(responseStr); 
            receivedStr = "";
        }
        Thread.Sleep(100);
    }
}
Full source code attached. I'm sure it can be improved. I'm just too excited not to share.

Attached Files




#2599 Netduino Serial Port Code Review

Posted by hari on 22 September 2010 - 04:53 AM

I was learning how to do SerialPort communication for my next project and ended up taking some time working with buffers. I think this code could be useful to others. It uses SerialPort.DataReceived event handler so it is non-blocking (your program can go on doing other things instead of waiting for serial input).
Code is attached to this post, feel free to use it for your projects. Constructive comments welcomed. :rolleyes:

The SerialPortHelper class is very easy to use. Just instantiate it (you can overide its speed, etc, but you don't have to):
1. ReadLine() method returns a full line or a blank string coming from serial port.
2. Print() and PrintLine() prints a string to serial port.

As mentioned in the second video. I believe there is a bug, but I have never seen it happen in real life yet. If you know how to fix this, please post. Thanks!!!

http://www.youtube.com/watch?v=Os3bOCWbmHA

Demo of Netduino's SerialPort communication capability.


http://www.youtube.com/watch?v=gUB6UFyDkaA

Second video explains the wiring and reviews the actual code.


PS: Chris, If doesn't qualify as a project "Showcase", feel free to move it to more appropriate forum.


EDIT: 10/26/2010 - Attachment updated to add Locks and declare interruptPort as static.

Attached Files




home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.