Hi, I'm using Serial2 to connect via USB, sometimes I lost the connection (for example unplugging USB cable), but B4PPC "thinks" that the port is still open, so I get strange behaviour, communication is broken but no Error-Event is fired.
PortOpen returns the value from the serial driver.
One possible solution is to send a "ping" every second and make the device reply with a ping. If you get no reply after 10 seconds you should break the connection.
I recommend using my SerialEx library instead of Serial2 which has several issues as documented in the Overview topic of the SerialEx help.
Have you checked what happens to CTS and DSR when you unplug the USB adaptor? Note that SerialEx can raise events when the pin states change so you might be able to detect when the connection goes down this way.
I tried SerialEx library, no event is raised when USB is unplugged, I set serial.EnableOnError = True and serial.EnableOnPinChanged = True
and msgbox in Serial_OnError and Serial_OnPinChanged, and in debug mode, CTS and DSR are "false" and OnErrorReason and OnPinChangedReason are "0".