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.

MLA44

Member Since 06 Nov 2014
Offline Last Active Dec 02 2016 12:56 PM
-----

Topics I've Started

N+2 stability issue, stops working after some hours

10 December 2014 - 10:40 AM

Hi,

 

I'm experiencing stability issues with the n+2. I'm using VS2013pro and NETMF 4.3 and firmware 4.3.1.0.

 

My program does the following:

- all the usual initial stuff (prepare file for log on sd-card, update local time from time server etc.)

 

- starts a method that is executed on interrupt from external events to measure the time between events (by using an InterruptPort and NativeEventHandler). Runs approx. every 10 ms and contains only some simple math.

 

while(true)

- sleep(900) // the interrupt method is running x times

- disable the interruptPort above

- POST data using HttpWebRequest (only on local network)

- enable the interruptPort above

end

 

I also have some methods for handling remove/insert sd-card as well as posting error logs online as well as to sd-card.

I have lock() on all things, so that nothing is interrupted by other things and the only shared variable is also written/read in a lock(). I also have a lock() on the InterruptPort so that I don't disable it while it is running (even though it should not matter).

 

 

Especially, NOT having the interruptPort enabled while doing HttpWebRequest has eliminated the netduino hanging up with the (read in MFDeploy) message: Failed allocation for 5 blocks, 60 bytes

 

I have added a pin toggle to measure on a oscilloscope, just to see if there is some activity.

 

After running for somewhere between 30 minutes and a full day the Netduino "dies".

Sometimes there are no activity at all and some times my pin toggle still runs (in the later case its not dead).

However, my online POST just stops... no logs of any kind, no exceptions made (at least not in my code).

 

Does anyone have any ideas? I'm considering going back to VS2010 with NETMF 4.2 and frimware.

 

Martin


Netduino Plus 2 - encryption

05 December 2014 - 02:05 PM

Hi,

 

I need to make an encrypted connection from the n+2 to my server and initially thought I could use SSL.

I was surprised to learn, that is not possible (out of the box, anyway).

 

I have been looking a bit on http://www.bouncycastle.org/csharp/

but I'm not sure on how to proceed.

I can't seem to find any examples with the n+2 that are explaining things.

Can anyone here give me some pointers in the right direction.

There are many different types of encryption in the API from bouncy castle. What should I use. and how.

 

Further on, I need to do the same thing (encryption) with an GSM module (using SIM900), so it would be nice to use something that will work on this as well.

 

Regards,

Martin


DateTime in NativeEventHandler()

18 November 2014 - 05:09 PM

Hi all,

 

I have been trying to use the timestamp in the NativeEventHandler to detect the time elapsed between two external events.

On an Arduino I would just set-up a timer with input capture, read the input capture register and subtract the previous value to get the elapsed time. That would give me a count in ticks relative to the 16 MHz clock frequency.

 

The NativeEventHandler is specified to have a timestamp of the time at the occurrence of the event. But Is that a timestamp in ms only? I have seen mentioned that DateTime is only measured in ms and therefore the ticks count is not accurate.

However, I have tried to use the "ticks" from DateTime, which is specified on MSDN to be 10.000 ticks/ms, but I'm not sure if I get an accurate time (oldDateTime.ticks - newDateTime.ticks = elapsedTime).

 

Also when I do read the number of ticks elapsed, the last digit is always zero. Indicating a resolution of ticks as 1.000 ticks/ms and not 10.000.

 

Can someone enlighten me as to what the accuracy of the timestamp in NativeEventHandler is.

I need an accuracy between events, much better than 1 ms (on the Arduino Leonardo I can detect better than 0.001 ms. Just for illustration).

Maybe I should be doing this differently. All suggestions are welcome.

 

/Martin


SerialPort.DataReceived

06 November 2014 - 02:37 PM

Hi all,

 

Can anyone guide me to some documentation or explain to me how I can figure out what is going on inside SerialPort.DataRecieved?

 

I use it as follows:

serial.DataReceived += new SerialDataReceivedEventHandler(SerialRecieveHandler);

I have an Arduino (Leonardo) sending data on serial interface to the Netduino+2 periodically (once pr sec).

 

Inside SerialRecieveHandler() I do like this:

if (serial.BytesToRead > 0)
{
    while (serial.BytesToRead > 0)
    {
        // read data
    }
    // process data
}
else
//write log to SD

My problem is that it seams like the event handler is triggered twice since:

- I get the data

- and I get the log in "else"

- every second.

I did see something on the forum about SerialHelper class for buffering data. Is my problem that the event handler is triggered on the first byte and again set in queue "later"? In this case I'm just lucky that my data is not cut in half! I don't like the uncertainty.

My full string that I receive every second is 9 bytes and it does get read right and converted to an int. I'm just wondering why the event handler is triggered twice.

 

So, how does it work and should I be using it differently?

 

PS, I use VS2010, NETMF 4.2 and firmware 4.2.2


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.