Hi I just installed Xojo 2019r21 and now I can’t figure out how to connect to a comport with the new SerialConnection.
I want to connect to COM1 but I am not sure where to set it.
I have tried this. But I just get an error that says “You must use the value returned by this function”
Try
SerialConnection1.Connect
MessageBox(“The serial connection is open.”)
Catch error As IOException
MessageBox(“The serial connection could not be opened.”)
End Catch
IF SerialConnection1.Connect Then
’ Code here
dt = Chr(&h7A) + Chr(&h31) + Chr(&h00) + Chr(&h55)
SerialConnection1.XmitWait
SerialConnection1.Write(dt)
Window1.ParkAnt.BackColor = white
Else
MsgBox(“The selected serial port could not be opened.”)
End If[/code]
This code seems to support that because it doesn’t work, I get the “This method doesn’t return a value” error on line "IF SerialConnection.Connect . . . .
So, how do you determine if the port is connected?
Finn,
you can open a specific port with the first line above:
SerialConnection1.Device = SerialDevice.WithName(“COM7”)
rather than having to use the System scan list. Sometimes you just need to open a specific port.
Try
SerialConnection1.Connect
MessageBox("The serial connection is open.")
Catch error As IOException
MessageBox("The serial connection could not be opened.")
End Try