Quantcast
Channel: .NET Framework Class Libraries forum
Viewing all articles
Browse latest Browse all 8156

Openning a Serial Port Connection ?

$
0
0

Hi, could anyone please identify any errors witin this chunk of code, or share some code that opens a connection to a serial port. This code gives me an error at run time:

System.IO.IOException: The parameter is incorrect

at System.IO.Ports.Internalresources.WinIOError(Int 32 errorCode, String str)

 

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If serialPort.IsOpen Then
            serialPort.Close()
        End If
        Try
            With serialPort
                .PortName = "com1"
                .BaudRate = 96000
                .Parity = IO.Ports.Parity.None
                .DataBits = 8
                .StopBits = IO.Ports.StopBits.One
                .Handshake = IO.Ports.Handshake.RequestToSendXOnXOff
            End With
            value = serialPort.ReadTimeout
            serialPort.ReadTimeout = value

            serialPort.Open()
            lblMessage.Text = "connected"
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
    End Sub
End Class

 


Viewing all articles
Browse latest Browse all 8156

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>