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.
Photo

Graphing Data from Netduino over the network


  • Please log in to reply
8 replies to this topic

#1 bill.french

bill.french

    Advanced Member

  • Members
  • PipPipPip
  • 260 posts
  • LocationPrinceton, NJ

Posted 08 November 2010 - 05:03 AM

I've got my netduino plus talking to a windows forms application over the network, so that this code:
        public static void Main()
        {
            NetLog log1 = new NetLog();

            log1.Host = "192.168.1.12";
            log1.Port = 8000;

            log1.Print("100");
            Thread.Sleep(500);
            log1.Print("400");
            Thread.Sleep(500);
            log1.Print("200");
            Thread.Sleep(500);
            log1.Print("500");
            Thread.Sleep(500);
            log1.Print("300");
        }
...using the Microsoft Charting stuff, produces this graph:
Posted Image

Which makes me happy!

What is weird though is that sometimes, and only from initial boot or by pressing play is VS, the netduino never makes it past sending the first "100" and throws an exception for each of the subsequent sends:

#### Exception System.Net.Sockets.SocketException - CLR_E_FAIL (1) ####
    #### Message: 
    #### Microsoft.SPOT.Net.SocketNative::connect [IP: 0000] ####
    #### System.Net.Sockets.Socket::Connect [IP: 001d] ####
    #### NetLogger.NetLog::Print [IP: 0042] ####
    #### NDP_SocketSender1.Program::Main [IP: 002d] ####
    #### SocketException ErrorCode = 10053
    #### SocketException ErrorCode = 10053
A first chance exception of type 'System.Net.Sockets.SocketException' occurred in Microsoft.SPOT.Net.dll
    #### SocketException ErrorCode = 10053
    #### SocketException ErrorCode = 10053

When the netduino is unable to connect to the forms app, I am able still able to connect to my forms application using telnet, so I know it's still responding. I am on the latest posted firmware.

I'm sure my code is a train wreck, so any advice would be very much appreciated. I don't doubt I'm doing something fundamentally wrong. My next step is to have the act of sending the data spun off into it's own thread. Here are my solution files:


I've been working up the nerve to take a stab at this for a while, eventually to start graphing data from the analog inputs. I was motivated to action after seeing Corey's 2d motion tracker w/ excel graphs using data cut/pasted from the debugger output... I was hoping I'd end up with something slightly useful for his Avatar motion project!

Thanks! --Bill

#2 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 08 November 2010 - 07:06 AM

Are you connected directly to your computer (via a wired hub)? Is there any pattern to the occassions when it fails to connect and throws an exception? Chris

#3 bill.french

bill.french

    Advanced Member

  • Members
  • PipPipPip
  • 260 posts
  • LocationPrinceton, NJ

Posted 08 November 2010 - 02:58 PM

Hello! Both the computer and the ND+ are plugged into switchports on my FiOS actiontel router. The netduino is also plugged in and powered via usb. It mostly works, but when it fails, it's almost always under these scenarios, after opening my forms application: 1. Pressing "play" in VS, which reboots and deploys 2. Unplugging the ND+ and plugging it in My forms app receives the 100, and then the netduino throws exceptions for each of the subsequent transmissions (which I catch and send to output), after the timeout for each one. I know my forms app is still responding, as I can telnet into it and send data while the ND is waiting to time out. But, sometimes it works in #1 and #2. And, it always works when I hit the reset button.

#4 Jim Davies

Jim Davies

    Advanced Member

  • Members
  • PipPipPip
  • 48 posts
  • LocationBrighton & Hove, UK

Posted 11 January 2011 - 05:19 PM

Hi Bill, I'm getting something almost identical to this. Did you manage to resolve it please? Jim

#5 bill.french

bill.french

    Advanced Member

  • Members
  • PipPipPip
  • 260 posts
  • LocationPrinceton, NJ

Posted 11 January 2011 - 05:42 PM

You know, I have not had the problem, since, so I have not turned my attention back to it. I really, really, want to get my head around sockets and threads in .net. I used to have a handle of it under Java, but that was too long ago. Are you having the issue with my code, or your own?

#6 Jim Davies

Jim Davies

    Advanced Member

  • Members
  • PipPipPip
  • 48 posts
  • LocationBrighton & Hove, UK

Posted 12 January 2011 - 08:36 AM

Thanks Bill. It's my code, but very simple. I think it's probably nearly out of memory. I think I may be relying too much on Debug.GC(true), rather than 'using' and 'Dispose'! Best, Jim

#7 Philip

Philip

    Member

  • Members
  • PipPip
  • 26 posts
  • LocationPreston, England

Posted 13 January 2011 - 06:45 PM

Just a quick 'Thank You' to Bill French. Your code set me going transmitting data over the network. Phil

#8 Francisco

Francisco

    New Member

  • Members
  • Pip
  • 8 posts

Posted 29 March 2012 - 08:56 PM

You know, I have not had the problem, since, so I have not turned my attention back to it.

I really, really, want to get my head around sockets and threads in .net. I used to have a handle of it under Java, but that was too long ago.

Are you having the issue with my code, or your own?


Hello bill.french,

Thank you for your code.

I had some problems with sockets, using Netduino as a Client.

Using your code was not working deploying the application to my N+, then I decided to use the emulator and everything worked fine.

I supposed it was a memory related problem, so I decided to remove some using sentences from your code, and this made the magic for my N+.

So after all I guess it was a memory issue.

Regards

#9 ljbeng

ljbeng

    New Member

  • Members
  • Pip
  • 8 posts

Posted 08 February 2013 - 08:09 PM

How are you getting NetLog to compile?  I don't see it's resource in the Neduino Plus reference path.

 

Thanks.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

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.