How to detect that console have just connected to HAL UART?
I need my code called when something connects to the HAL UART.
I have a simple mini-debug that just prints something to the UART and I see it on a console connected to the STM debug COM port. I noticed that the HAL_UART_Transmit() always returns HAL_OK, no matter if there is anything listening on COM port or not.
Is there a way to detect connect / disconnect event?
Well, if there is no obvious way, maybe I could receive on that port? But then again - when there is a pending RX operation - can I transmit in that time?
My goal is that the Nucleo board should notify about events on the console, but when the console is just connected and nothing is being sent at the moment, I need to be able to query the board about its status by for example pressing a key on console, or just configure the session to send anything on starting the connection. So - the board should do its things, wait either for environment change (like temperature changed) and at the same time wait for user input, like key pressed. I'm just not sure what would happen if the board would have pending receive and I try to transmit. Would it wait? Would it fail? Would it succeed, while the receive operation would still be waiting for the input?
Do I need to transmit in interrupt mode? Or can I just receive in interrupt mode? When polling mode is used, are the interrupts still triggered and my registered callbacks would be called?
