Hi everybody,
I have a problem detecting the com port for my board.
It’s allways fond on COM2, but there isn’t anything connected to this.
Here is a snippet of my code.
[code]
’ Get available COM ports and populate a ComboBOx (RelayBox)
myport = IO.Ports.SerialPort.GetPortNames()
Application.DoEvents()
If myport.Length = 0 Then 'If no COM-Port available
MessageBox.Show("Oops! No COM-PORT found on this computer. Cannot go ahead.")
EndPgm()
End If
For Each Port In myport
Try
If SerialPort1.IsOpen = True Then
SerialPort1.Close()
End If
With SerialPort1
.PortName = Port
.ReadTimeout = 500
.Open()
End With
Catch es As Exception
Finally
If SerialPort1.IsOpen = True Then
RelayBox.Items.Add(Port) 'RelayBox is a combobox
SerialPort1.Close()
End If
End Try
Next Port
'Then, once the ComboBox is populated with available ports (currently COM2 and COM12), I’m looking for my VM8090 board as this:
For Each ConnectedPort In RelayBox.Items()
Try
K8090.Port = ConnectedPort
MyInfoTextBox.Text = “Looking on " & K8090.Port & " for VM8090 Relays board.”
If K8090.Connect() = True Then
found = True
chaine = ConnectedPort
RelaysOK = True
RelError = 0
ComError = 0
MyInfoTextBox.Text = " "
Label33.Text = “USB Relays”
RelayBox.SelectedIndex = RelayBox.FindStringExact(ConnectedPort)
MyInfoTextBox.Text = "Ready. "
Exit For
End If
Catch ex As Exception
RelaysOK = False
found = False
RelError = 1
ComError = 1
End Try
Next[/code]
Using Debug mode, it allways finds on COM2. It should by found on COM12.
Does the function K8090.Connect() return something more than True or False I can test?
Can someone help me?
Thank you all in advance.
Regards,
Yvan.