Trouble reconnecting COM port after disconnecting.

DanielB33

Active member
Joined
Mar 29, 2013
Messages
40
Programming Experience
1-3
Thanks for looking at my post. I initialize my port as follows shown below. everything works great. When the user disconnects thru my disconnect button, I can reconnect to the COM just fine. But when simply unplugging my usb cable, I cannot reconnect. I know I can still send data, but I can't seen to receive any. My port even appears to be open on my form, and vb.net thinks I am connected, but my dataRecievedHandler is not firing. Any ideas what this could be??? Public mySerialPort As New SerialPort 'Define serial port object
Public Sub CommPortSetup() 'Initialize port with settings correspodning to PEM Relay Testing Board

With mySerialPort
.PortName = cboCOM.Text

.BaudRate = 115200
.DataBits = 8
.Parity = Parity.None
.StopBits = StopBits.One
.Handshake = Handshake.None
.DtrEnable = True 'This allows us to open and close the port as many times as we want.
.WriteTimeout = 200 'Do not get stuck trying to send old data if device did not recieve it (not connected?)
.ReadTimeout = 200
'Provide interrupt object
AddHandler mySerialPort.DataReceived, AddressOf DataReceivedHandler 'Enable received data interrupt
End With
Try
mySerialPort.Open()
If (mySerialPort.IsOpen) Then
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
 
Back
Top