Just downloaded, so will look at it. Thank you
You said youâre getting error 103. Error 103 is âHardware detected a break condition."
Iâm a little late to the game here, but perhaps I have some insight might be useful.
Resetting microcontrollers can be a little tricky since, in most cases, the serial port associated with then actually disappear briefly. When that happens, there will be no event that one could use to detect such a situation. What that means, on Windows for example, is that your COM port ceases to exist for a little while, and your SerialDevice is no longer valid (but not nil), and trying to do anything with the port will result in an error. I donât remember if simply closing and connecting the port works. I have a feeling that it doesnât, otherwise I would probably do that in CoolTerm (itâs been a while since Iâve had to deal with that ). To get around this reliably, you should re-acquire your serial connection (with SerialConnection1.Device = ⊠) and then connect. Thatâs what CoolTerm does. Note that SerialDeviceAt() might not work since any new port usually appears at the end of the list. I.e. the port index of the port you previously selected may no longer be the same after it reappears. SerialDevice.WithName() should be more reliable since the port name usually doesnât change when a device disappears and then comes back.
Now, there are things you can do to detect if a port disappears or re-appears. In CoolTerm, Iâm using a 200ms timer that monitors SerialDevice.Count, and if that changes, acts accordingly:
- when a port disappears, it checks if the port is used by any open terminal windows, and if the port is currently connected, it closes the connection.
- when a port appears, it checks if that port was previously in use by any of the open windows, and if so, it reconnects if it was previously connected before the port disappeared.
Adding this simple mechanism solved a lot of headaches for CoolTerm users with microcontrollers, such as Arduino, ESP32âs etc. Resetting an attached microcontroller causes CoolTerm to temporarily close the connection until the controller reboots and the serial port appears again. This also works, when someone unplugs their USB/serial adapter and then plugs it back in.
Coding defensively and anticipating a disconnect is so important. In my ERP software, you could literally reboot the database server and the users would most likely not even notice.
Thanks for the input, this is a side project so it may take some time to get back into but definitely will give a try.