Serial port problem with VB 2008
Terrachild
Posts: 2
I've done this before years ago with VB 6, but my attempt with VB 2008 isn't working.
This should be very simple.
Here is the BS2 code:
Loop:
SEROUT 16, 396,[noparse][[/noparse]"A"]
PAUSE 3000
GOTO Loop
Here is the VB 2008 code:
Imports System
Imports System.IO.Ports
Imports Strings = Microsoft.VisualBasic
Public Class Form1
End Class
Here are the settings for the serial port:
2400, N, 8, 1
When I run both programs, my Windows Form shows a question mark in the textbox·for every byte received.
A question mark is Ansi 63, which what the SerialPort1 ParityReplace character is set to.· That is a parity error replacement byte.· Since·parity is set to none in·SerialPort1, I'm not sure why this is happening.
Any ideas?
Thanks
This should be very simple.
Here is the BS2 code:
Loop:
SEROUT 16, 396,[noparse][[/noparse]"A"]
PAUSE 3000
GOTO Loop
Here is the VB 2008 code:
Imports System
Imports System.IO.Ports
Imports Strings = Microsoft.VisualBasic
Public Class Form1
Private Sub cmdOpenPort_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdOpenPort.Click
End Sub
Private Sub cmdClosePort_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdClosePort.Click
End Sub
Private Sub cmdReadPort_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdReadPort.Click
End Sub
SerialPort1.Open()
End Sub
Private Sub cmdClosePort_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdClosePort.Click
SerialPort1.Close()
End Sub
Private Sub cmdReadPort_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdReadPort.Click
Dim strTemp As String
strTemp = SerialPort1.ReadExisting()
TextBox1.Text = strTemp
TextBox1.Text = strTemp
End Sub
End Class
Here are the settings for the serial port:
2400, N, 8, 1
When I run both programs, my Windows Form shows a question mark in the textbox·for every byte received.
A question mark is Ansi 63, which what the SerialPort1 ParityReplace character is set to.· That is a parity error replacement byte.· Since·parity is set to none in·SerialPort1, I'm not sure why this is happening.
Any ideas?
Thanks
Comments
I substituted $3fd for the baudrate, and now it works fine.