STM32F4 SPL USB library example CDC/VPC: how to determine if PC serial port is open?
I managed to get an old version of the USB CDC/VCP SPl library working
https://www.st.com/en/embedded-software/stsw-stm32046.html and modified the VCP example to send/receive data to a PC via USB serial port. I edited syscalls.c so that the printf() function sends data to the USB.
It all works well if the PC is connected to my board and I have a USB serial session open in, say, PuTTY. If there's no connection, though, the USB buffer fills immediately and the code stops executing, until a new USB Serial session is opened. Which is usually desirable, since it will prevent missing characters if too much data is sent at once and the USB serial port is still catching up. But if I want to use the USB serial port as a debug print, it must work if connected or not
How can I determine programmatically if the USB serial port is opened ? I know how to determine if the USB is connected to the PC or not, but that's not enough, since the board is also powered by USB, and always connected to a PC, even if the serial port is not open
I could not find a status function nor a register to read, and I got lost in the nested interrupts handling trying to figure out where to set a global flag. Thanks in advance for any suggestion
