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.

Patrick's Content

There have been 20 items by Patrick (Search limited from 29-March 23)


By content type

See this member's

Sort by                Order  

#47474 Looking for a few ninja code contributors...

Posted by Patrick on 22 March 2013 - 02:10 PM in General Discussion

I'm a little late to the party but I have access to a Beagle 480 USB sniffer and all flavors of Netduino.  If any debugging assistance is required, I'd be happy to help out.




#39624 Holding a hacknight with Netduino's and Windows Azure

Posted by Patrick on 19 November 2012 - 02:28 PM in Project Showcase

Sounds like an awesome time



#38759 Introducing Netduino Plus 2

Posted by Patrick on 08 November 2012 - 04:50 PM in Netduino Plus 2 (and Netduino Plus 1)

Your timing is perfect. Can't wait for mine to arrive! Thanks guys!



#37255 Running out of memory

Posted by Patrick on 15 October 2012 - 11:42 PM in Netduino Plus 2 (and Netduino Plus 1)

Thanks Chris! I have WireShark installed but I don't have access to the shared host's OS nor do I know how to monitor the traffic from the N+ using it. I moved my test loop into the SocketExample you recommended (much smaller deployment) and it locks up at 561 iterations with no output. I'm going to try to access some local web services to eliminate the possibility of a server side issue.



#37252 Running out of memory

Posted by Patrick on 15 October 2012 - 10:28 PM in Netduino Plus 2 (and Netduino Plus 1)

Same exact failure with using sockets and a POST. 563 inserts, then locked.

private static void TestSockettPost()
        {
            int numTests = 1000;

            while (numTests > 0)
            {
                //write test data and show LED
                led.Write(true);
                Thread.Sleep(250);

                try
                {
                    IPHostEntry host = Dns.GetHostEntry("www.SERVER.com");
                    IPEndPoint endPoint = new IPEndPoint(host.AddressList[0], 80);

                    using (Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
                    {
                        socket.Connect(endPoint);

                        using (NetworkStream ns = new NetworkStream(socket))
                        {
                            //POST /somepage.php HTTP/1.1
                            //Host: example.com
                            //Content-Type: application/x-www-form-urlencoded
                            //Content-Length: 19

                            byte[] bytes = System.Text.Encoding.UTF8.GetBytes(
                                "POST /PATH/FILE.php HTTP/1.1\r\n" +                
                                "Host: www.SERVER.com\r\n" +
                                "Connection: keep-alive\r\n" +
                                "Content-Length: 21\r\n" +
                                "Cache-Control: max-age=0\r\n" +
                                "Origin: null\r\n" +
                                "User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.4 (KHTML, like Gecko) Chrome/22.0.1229.94 Safari/537.4\r\n" +
                                "Content-Type: application/x-www-form-urlencoded\r\n" +
                                "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n" +
                                "Accept-Encoding: gzip,deflate,sdch\r\n" +
                                "Accept-Language: en-US,en;q=0.8\r\n" +
                                "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3\r\n" +
                                "\r\n" +
                                "TestID=&TestDesc=TEST");

                            ns.Write(bytes, 0, bytes.Length);

                            Debug.Print("POST done");
                        }
                    }
                }
                catch (Exception ex)
                {
                    Debug.Print(ex.Message.ToString());
                }

                //hide LED
                led.Write(false);
                Thread.Sleep(250);

                numTests--;
            }

            Debug.Print("Test complete");
        }

This just seems crazy to me. Anybody have any idea what could be going on or any input on how to troubleshoot?



#37195 Running out of memory

Posted by Patrick on 14 October 2012 - 11:41 PM in Netduino Plus 2 (and Netduino Plus 1)

I'm running 4.2. Getting some help in chat atm and will check out the SocketClient example regardless; thanks!



#37192 Running out of memory

Posted by Patrick on 14 October 2012 - 10:43 PM in Netduino Plus 2 (and Netduino Plus 1)

Thanks for the help Chuck; I appreciate it! According to my research, Close() calls Dispose(true) internally and I did it in that order just in case what I found was inaccurate... Well that and I tried it both ways. :D You're in Crystal River? Cool! I'm in Tampa.



#37187 Running out of memory

Posted by Patrick on 14 October 2012 - 09:59 PM in Netduino Plus 2 (and Netduino Plus 1)

According to the Debug.GC method, it doesn't seem like the device is running out of memory. It shows the following then stays at 40812 right up until iteration 556, then it just stops.

Debug.Print("Memory Used: " + Debug.GC(true).ToString());
Memory Used: 35160
Memory Used: 36900
Memory Used: 36900
Memory Used: 38364
Memory Used: 40812
...

Same thing if I pass the Debug.GC method false as well but it goes to iteration 563.

Once the program halts, If I hit pause in VS, the compiler highlights this line:
stOut = new StreamWriter(req.GetRequestStream());



#37184 Running out of memory

Posted by Patrick on 14 October 2012 - 08:49 PM in Netduino Plus 2 (and Netduino Plus 1)

This code seems to cause my N+ to run out of memory. There are no errors but I figure that it's running out of memory because it will insert 536 records every time and if I add a couple references to the project and increase the size of the payload, it will insert a few less records. Scientific huh? :P

Any ideas? Is it possible to do a POST using sockets instead?

int numTests = 1000;

            while (numTests > 0)
            {
                //write test data and show LED
                led.Write(true);
                Thread.Sleep(250);

                try
                {
                    string strNewValue;
                    //string strResponse;
                    req = (HttpWebRequest)WebRequest.Create("http://SERVERNAME.com/PATH/TestInsert.php?");
                    req.Method = "POST";
                    req.ContentType = "application/x-www-form-urlencoded";
                    req.KeepAlive = false;

                    // Set values for the request back                
                    strNewValue = "TestID=''&TestDesc=AWholeBunchOfTestDataDoesItMatterHowMuchWePass";
                    req.ContentLength = strNewValue.Length;

                    // Write the request
                    stOut = new StreamWriter(req.GetRequestStream());
                    stOut.Write(strNewValue);
                    stOut.Dispose();
                    stOut.Close();

                    req.Dispose();
                }
                catch (Exception ex)
                {
                    Debug.Print(ex.Message.ToString());
                }

                //hide LED
                led.Write(false);
                Thread.Sleep(250);

                numTests--;
            }

            Debug.Print("Test complete");



#35730 Ethernet Broken?

Posted by Patrick on 21 September 2012 - 09:39 PM in Netduino Plus 2 (and Netduino Plus 1)

You wouldn't know how to call a .Net web service would you?



#35726 Ethernet Broken?

Posted by Patrick on 21 September 2012 - 09:27 PM in Netduino Plus 2 (and Netduino Plus 1)

It works perfectly well with your web server, so it must be my server side code or my host. Thanks for taking the time to work on it with me Stefan. :D



#35714 Ethernet Broken?

Posted by Patrick on 21 September 2012 - 04:23 PM in Netduino Plus 2 (and Netduino Plus 1)

It's looking more like that is the issue but I sure will test later on; thanks Stefan.



#35641 Ethernet Broken?

Posted by Patrick on 20 September 2012 - 08:28 PM in Netduino Plus 2 (and Netduino Plus 1)

We can conclude that Ethernet is not broken and I'm very happy that is the case. When execute the following code, it runs through once and does a proper insert, the second time it fails just after executing this line:
StreamWriter stOut = new StreamWriter(req.GetRequestStream());
The N+ just sits there with the onboard led solid and the Ethernet activity light flashing.

Any idea?

using System;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.NetduinoPlus;
using Microsoft.SPOT.Net.NetworkInformation;
using System.Text;
using System.IO;
using System.Net;

namespace BC
{
    public class Program
    {
        public static void Main()
        {
            OutputPort led = new OutputPort(Pins.ONBOARD_LED, false);

            int numTests = 720;

            while (numTests > 0)
            {
                //write test data and show LED
                led.Write(true);
                Thread.Sleep(250);

                try
                {
                    string strNewValue;
                    string strResponse;
                    HttpWebRequest req = (HttpWebRequest)WebRequest.Create("http://SERVERNAME/PATH/InsertFile.php");
                    req.Method = "POST";
                    req.ContentType = "application/x-www-form-urlencoded";
                    req.KeepAlive = false;

                    // Set values for the request back                
                    strNewValue = "TestID=''&TestDesc=TestData";
                    req.ContentLength = strNewValue.Length;

                    // Write the request
                    StreamWriter stOut = new StreamWriter(req.GetRequestStream());
                    stOut.Write(strNewValue);
                    stOut.Close();

                    // Do the request to get the response
                    StreamReader stIn = new StreamReader(req.GetResponse().GetResponseStream());
                    strResponse = stIn.ReadToEnd();
                    stIn.Close();
                }
                catch (Exception ex)
                {
                    Debug.Print(ex.Message.ToString());
                }

                //hide LED
                led.Write(false);
                Thread.Sleep(250);

                numTests--;
            }
        }
    }
}



#35560 Ethernet Broken?

Posted by Patrick on 20 September 2012 - 12:53 AM in Netduino Plus 2 (and Netduino Plus 1)

Thanks Stefan, Surprisingly to me, if I run that code, I don't seem to have any issues even if I execute it in a loop at 1.5 second intervals (that includes the 1 second sleep you had in there) for 720 iterations.



#35504 Ethernet Broken?

Posted by Patrick on 18 September 2012 - 10:35 PM in Netduino Plus 2 (and Netduino Plus 1)

Here you go Stefan, thanks! Network interface 0: +-- Type: Ethernet +-- DHCP enabled: no +-- Dynamic DNS servers: no +-- IP Address: 192.168.1.10 +-- Subnet mask: 255.255.255.0 +-- Gateway: 192.168.1.1 +-- DNS Server: 8.8.8.8 +-- DNS Server: 8.8.4.4 '-- MAC address: 5C:86:4A:00:01:71



#35480 Ethernet Broken?

Posted by Patrick on 18 September 2012 - 02:19 PM in Netduino Plus 2 (and Netduino Plus 1)

Thanks Stefan (sorry about the mispelling)! Will have it for you later this evening.



#35477 Ethernet Broken?

Posted by Patrick on 18 September 2012 - 01:47 PM in Netduino Plus 2 (and Netduino Plus 1)

I've spent quite a bit of time trying to get my Netduino Plus to reliably post data to a web server and I think its time to poll the brains in the community as I've tried on 4.1 and 4.2 and am seemingly out of options. Some background: http://forums.netdui...dpost__p__34958 Initially, I wrote the most basic of examples using the HTTPRequest class, then thought that I was missing something silly, so I move to Stephan's toolbox and used his Web_Client but the results are the same. So I'm thinking the bug is in the firmware or maybe its a hardware issue. "Regardless of how long I sleep for (tested between 250 ms and 10000 ms) the application on the N+ becomes unresponsive (led stops blinking) but no exception is thrown and the debugger never disconnects. I also tried this without being attached to the debugger and got that same result." What is going on?



#35315 Trigger a function based on time of day

Posted by Patrick on 15 September 2012 - 02:24 PM in Netduino Plus 2 (and Netduino Plus 1)

I don't believe DateTime.Now() actually returns the current time as it does on the non-micro version of the .Net framework. The Netduino simply doesn't remember the system time when powered off (no battery) so you get a default value. You need to somehow set the system time when powered up - maybe from a time server - then that code should work. I've thought about this a bit but have never worked through a solution but it seems likely that someone would have. Sorry I can't be more help.



#34958 Watchdog redeux: Available in 4.2?

Posted by Patrick on 10 September 2012 - 02:01 PM in General Discussion

I wanted to chime in here as I'm seeing the same thing with my board (N+, Rev A, 4.2) and I have something that is quite reproducible.

For the test project, we're using the web client example from the netmftoolbox project but updated for 4.2. We then changed the GET to a POST to test inserted data in the a database via php. This works well.

We then wrapped the code in a while to test longevity as this needs to be running for at least a few weeks at a time.
public static void Main()
        {
            OutputPort led = new OutputPort(Pins.ONBOARD_LED, false);

            // Creates a new web session
            HTTP_Client WebSession = new HTTP_Client(new IntegratedSocket("www.SERVERNAME.com", 80));

            int numTests = 720;

            while (numTests > 0)
            {                

                // Requests the latest source
                HTTP_Client.HTTP_Response Response = WebSession.Post("/InsertTest/InsertTest.php", "ID='',data=TestData");

                // Did we get the expected response? (a "200 OK")
                if (Response.ResponseCode != 200)
                    throw new ApplicationException("Unexpected HTTP response code: " + Response.ResponseCode.ToString());

                led.Write(true);
                Thread.Sleep(2500);
                led.Write(false);
                Thread.Sleep(2500);

                numTests--;
            }
        }

Regardless of how long I sleep for (tested between 250 ms and 10000 ms) the application on the N+ becomes unresponsive (led stops blinking) but no exception is thrown and the debugger never disconnects. I also tried this without being attached to the debugger and got that same result.

I know I should aggregate the data and upload in batches instead but this should still work and leads me to believe there is some sort of memory leak in the firmware.



#26582 Introducing Netduino Go

Posted by Patrick on 05 April 2012 - 08:45 PM in Netduino Go

Well crap, on 00101011 I bought 4 netduinos for a project... :) looks awesome, I'll pick on up ASAP.




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.