I'm current working with this C++ library - https://github.com/wjwwood/serialv- to read a COM port device on Windows.
The application appears to work well, but I've encountered a strange edge case.
When I plug in the device, before starting the application, the application will work as expected, but when there's no device available, I poll the COM ports for new connections. If a new connection is found, the application appears to pick up the hotplugged device, but the stream appears to be corrrupted in someway.
If, however, I "serial::close()" the device (see here - http://wjwwood.io/serial/doc/1.1.0/classserial_1_1_serial.html#afbe59407e718bc3d22ea4a67b304db6c) and reopen it, the device works as intended.
To workaround this, I currently capture 12 seconds of the COM port stream, and if it's corrupted, I close and reopen the hotplugged device.
This feels like quite a nasty hack, but I also suspect that I'm not the only one to have encountered this problem.
Are there more efficient solutions out there? Or is this just an RTFM moment?