I am using the SerialConnection classes in a console helper application to access a Serial-to-USB device on Windows and macOS.
Basically connection looks like this:
Var seriald As serialdevice = SerialDevice.WithName(Me.PortName) If seriald <> Nil Then serial.Baud = Me.Baud serial.Bits = Me.Bits serial.CTS = Me.cts serial.DTR = Me.dtr serial.Parity = CType(Me.Parity, SerialConnection.Parities) serial.StopBit = CType(Me.StopBits, SerialConnection.StopBits) serial.XON = Me.xon serial.Device = seriald serial.Connect Return True End If
With an exception handler following, returning False.
Serial is an already created instance property of type SerialConnection, with its three events linked to class methods via Addhandler.
This works nicely on Windows, and I can read data in the DataAvailable Handler.
On macOS, the SerialConnection.Error handler fires twice before the connect method returns true (sic!).
Errorcode both times is 2, which most possibly means kBluetoothSDPErrorCodeInvalidServiceRecordHandle – at least this would correspond to the SerialConnection’s handle which is Nil (or rather -1) while its Device property is set correctly.
Any hints what I might be doing wrongly? Or a Xojo 2019r3 bug?
EDIT: An old project using the old serial class works.