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.

tknman0700

Member Since 03 Apr 2012
Offline Last Active Jun 25 2012 02:09 PM
-----

Posts I've Made

In Topic: Serial Port Problems

31 May 2012 - 04:09 AM

not sure I follow the .flush() reference. Would you do this before you read from the port?

In Topic: Netduino Plus 1 Firmware v4.1.0 (update 6)

31 May 2012 - 03:40 AM

are there updated drivers for running this firmware? Visual Studio crashing all the time when debug.

In Topic: VS2010 Crash on debug

31 May 2012 - 03:37 AM

Same problem here.. vb development crashing visual studio left and right anytime I try to set a break point and investigate variable.

In Topic: Serial Port Problems

31 May 2012 - 02:04 AM

Ok I am still a bit confused.. I am doing this.

Private Sub serialPort_DataReceived(ByVal sender As Object, ByVal e As SerialDataReceivedEventArgs)
        ' Check if Chars are received

        Dim ReadBuffer As Byte() = New Byte(sp.BytesToRead - 1) {}
        If e.EventType = SerialData.Chars Then
            ' Create new buffer

            sp.Read(ReadBuffer, 0, ReadBuffer.Length)

            If ReadBuffer.Length > 0 And (ReadBuffer(ReadBuffer.Length - 1) = 10 OrElse ReadBuffer(ReadBuffer.Length - 1) = 0) Then
                ' New line or terminated string.
                output.Append(GetUTF8StringFrombytes(ReadBuffer))
                Debug.Print("Recieved : " & output.ToString())
                output.Clear()
              Else
                Try
                    output.Append(GetUTF8StringFrombytes(ReadBuffer))
                Catch ecx As Exception
                    Debug.Print("Cannot parse : " & ecx.StackTrace)
                End Try
            End If
        End If

    End Sub

The problem is that when I "read" from the bus I also see what I just sent to the bus.

I have added the above as a handler....

AddHandler sp.DataReceived, New SerialDataReceivedEventHandler(AddressOf serialPort_DataReceived)

But I am not sure why I see the stuff I just sent to the serial bus in addition to the data that the device placed on the bus. Like i said I am new to hardware interfacing but not .net development. I think I am just missing a few connections here to really taking good advantage of this prototyping kit.

Any direction for handling serial data is appreciated...

This is code I have adapted from a few sources online as starters...

Thanks

In Topic: Serial Port Problems

30 May 2012 - 04:27 PM

Ok thank you for your advice... I left out that line. I have it working now but I am trying to better understand how to write and read from serial ports generally speaking. How to know when the data is done being "read" on the serial port etc. Thank you

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.