Using Visual Basic for reading serial port... not going well :( GONE WELL NOW :)

I'm using VB 2010 .NET to read the serial port so I can make something more useful than simply writing out the data but initially that is all I am trying to do.

I have taken some code I found called MAXIcom at Serial Communication with Visual Basic .NET and modified it to read simple output of "Hello" plus an incrementing number. The code works at 9600 baud but not at 115200. The supplied code uses event handler for the reading (and hence in a separate thread). I also rewrote it to do everything in the same thread (read and update the text box) using a timer which I eventually set ticking at 1 ms. It worked'ish but the GUI became unresponsive.

In all cases the speed is not as fast as the Arduino serial output... The program locks up... various woes.

At this time I'm not asking if someone could check my code I would just like to get my hands on some alternative to try. Does anyone have some source or links to something that may be useful.

Cheers

Here is the VB source cut down to its minimum. The form has a single text box on it for displaying the output. This version writes just one character to the text box and clears it away.

The display changes characters pretty fast for about 2 seconds then each charactercomes up at about every .25 seconds... !!!

Imports System
Imports System.IO.Ports
Imports System.Threading
Imports System.Threading.Thread

Public Class Form1

    Dim WithEvents COMport As New SerialPort
    Dim RXbyte As Byte


    Public Sub New()

        ' This call is required by the designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.

        COMport.PortName = "COM8"
        COMport.BaudRate = 9600
        COMport.Open()


    End Sub

    Private Sub Receiver(ByVal sender As Object, ByVal e As SerialDataReceivedEventArgs) Handles COMport.DataReceived
        RXbyte = COMport.ReadByte
        Me.Invoke(New MethodInvoker(AddressOf Display))

    End Sub

    Private Sub Display()
        txtReceived.Clear()
        txtReceived.Text = (ChrW(RXbyte))
    End Sub

End Class

and here is the Arduino code (util.h manages the printf support) and it speeds along on the Arduino serial output

#include <SPI.h>
#include <_util.h>

void setup() {
    Serial.begin(9600);

    printf_begin();

}
int i;
void loop() {
  printf("Hello %d\n", i);
  i++;
  //delay(200);

}

Changing the read buffer like this

        COMport.PortName = "COM8"
        COMport.BaudRate = 9600
        COMport.ReadBufferSize = 16384
        COMport.Open()

just delays the onset of slow motion

and

        COMport.DtrEnable = True
        COMport.RtsEnable = True

seems to make no differnce

void loop() {
printf("Hello %d\n", i);
i++;
//delay(200);

}

Jamming data out the serial port as fast as possible hardly seems like a good idea. What does "Hello " add to the information being sent?

The Arduino output is generating test data.

The objective is to have a better tool than a simple print of values (eg a plotter or a visual representation)

To get there I have to make it work! Then I have to check its performance capabilities and envelop. I am obviously concerned about the performance/stability and my approach being wrong. Arduino manages the 'jamming' as does http://home.comcast.net/~hardandsoftware/enhanced_serial_port_object_for.htm so I'd like to get my version working too.

PaulS, what did you think the "Hello" was for? More useful than the number counter!

PaulS, what did you think the "Hello" was for? More useful than the number counter!

I don't agree. I hardly see the benefit of a PC application receiving HelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHello

Your mileage may vary.

PaulS:

PaulS, what did you think the "Hello" was for? More useful than the number counter!

I don't agree. I hardly see the benefit of a PC application receiving HelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHello

Your mileage may vary.

Ha ha ha.... You cannot be serious

Looking good now, please visit Enhanced Serial Monitor - Version 3.1.3 UPDATE - Interfacing w/ Software on the Computer - Arduino Forum for a little serial monitor tool