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.

Kim Clausen

Member Since 09 Mar 2013
Offline Last Active Oct 15 2015 12:31 PM
-----

Posts I've Made

In Topic: Netduino Serial Port Code Review

27 May 2014 - 03:33 PM

Hi Chris

 

I have added watches at the copied the value when the app stops (I send the text 'hello'). It is reading the line and things seems ok to me.

		bufferLength	7	int
		bufferMax	1024	int
		bufferMax - bufferLength	1017	int
-		buffer	{byte[1024]}	byte[]
		[0]	104	byte
		[1]	101	byte
		[2]	108	byte
		[3]	108	byte
		[4]	111	byte
		[5]	13	byte
		[6]	10	byte
		[7]	0	byte
		[8]	0	byte
		[9]	0	byte
		[10]	0	byte
                .
                .
                [1023]    0    byte

For now I'm surviving by adding a try/catch around the read call:

                int bytesReceived = 0;
                try
                {
                    bytesReceived = serialPort.Read(buffer, bufferLength, bufferMax - bufferLength);
                }
                catch
                {
                    Debug.Print("SerialPort exception");
                }

In Topic: Netduino Serial Port Code Review

30 April 2014 - 09:32 AM

I'm using the Serial Port Helper with a Netduino Plus 2 and a Sparkfun Bluetooth Mate Gold. I can send data from the Netduino without problems but when reading I sometimes encounter an exeption - sometimes it is succesfull. I have not been able to identify any pattern in when it is successful and when it fails. The program stops at the read line in the below shown code:

private void serialPort_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
     lock (buffer)
     {
         int bytesReceived = serialPort.Read(buffer, bufferLength, bufferMax - bufferLength);
 
         if (bytesReceived > 0)
         {
             bufferLength += bytesReceived;
             if (bufferLength >= bufferMax)
                 throw new ApplicationException("Buffer Overflow");
         }
      }
}
 

with the following debug output

 

A first chance exception of type 'System.Exception' occurred in Microsoft.SPOT.Hardware.SerialPort.dll
An unhandled exception of type 'System.Exception' occurred in Microsoft.SPOT.Hardware.SerialPort.dll

In Topic: I2C and ADXL345 maxing sample rate

15 April 2014 - 02:04 PM

The www.loveelectronics.co.uk site seems to be down. Can anyone share the ADXL345 library at some other site


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.