STM32 mbedOS serial port interrupt

Hi,
I have been using platformIO for some time now. I really love it.
I’ve come across a problem lately.
I considered myself a quite experienced programmer.
I have developed a board based on NUCLEO_STM32F303 but the problem is more general.

I am using mbedOS, platform is ststm32 [5.7.0] (mbed framework 5.14).
(I have also tried different versions does not make any difference)

In order to access threads RTOS functionalities, I added, as usual, in the platformio.ini
build_flags = -D PIO_FRAMEWORK_MBED_RTOS_PRESENT

I have to use a serial port through RX interrupt.
In order to red the received character i use a simple pc.getc().

while the code is perfectly ok if compiled with mbed online compiler with the same mbedOS 5.14.

My code compiles fine but when executes my ISR it gets stuck because the locking mechanism used by the getc standard implementation fails to lock the OS and gets stuck reporting an error locking.
I am aware of all the caveats of mbed RTOS and ISR locking code, bust still I do not understand why the code works fine if compiled online

Really do not know how to get around it.

Any help really appreciated

Franz

Modify the code for the mbed online compiler to check if you are really running on the RTOS, too. No mutex, no locking error while calling pc.getc() during an ISR. Simply print something like

#if MBED_CONF_RTOS_API_PRESENT
pc.printf("We have an RTOS\n");
#else 
pc.printf("No RTOS enabled\n");
#endif

All-in-all, you should use RawSerial instead of Serial if you want a lock-free serial object. Then pc.getc() is no problem.

Thanks a lot maxgerhardt, your answer was spot on!
Using rawserial solved the problem!
Thank you