AnsweredAssumed Answered

bug: STM32 Virtual com port driver incorrect state after fast hardware reconnect

Question asked by kuznetsov.dmitriy on Oct 20, 2015
Virtual com port driver 1.4.0 | Win7

When STM32 MCU with USB virtual com port is disconnected-connected during overlapped IO session, the device entry(virtual com port) remains available in the list provided by Setup API, but becomes inaccessible. Attempt to CreateFile(...) on it fails with error code 2(ERROR_FILE_NOT_FOUND). At the moment of cancelling overlapped IO session com port disappears from the registry HKEY_LOCAL_MACHINE\hardware\devicemap\serialcomm and doesn't appear again (until the hardware is reconnected second time).
Even if user program(on computer) cancells IO(CancelIoEx or PurgeComm) and clears error state(ClearCommBreak + ClearCommError), com port remains inaccessible.
After second reconnection everything continues to work properly.

From other side, there is a Prolific PL2303 virtual com port driver. It executes the complete disconnect-connect sequence after overlapped IO session is ended(cancelled by user program). It does not require resetting virtual com port driver in user code(on PC) or manual reconnecting second time.

So, the ST VCP driver should at least behave in some way like Prolific one - do full disconnect-connect sequence after overlapped IO session end(disconnect even if hardware is available, since was quickly connected back). Or alternatively and better, disconnect-connect imediately on corresponding hardware event and report failure to user code waiting for overlapped IO events.