How to disable Mbed Tracing during run-time?

I wonder if it is possible to disable the UART attached to mbed-trace once it is enabled in mbed_app.json. I couldn’t find a way to do it in run-time.

To what I understand:

  • The target implements the HAL functionality of the serial object (using the external variable stdio_uart_inited it reports if the UART was initialized correctly)
  • Based on mbed_app.json we either use BufferedSerial or DirectSerial class which use the target-implementation initialization in the constructor.
  • In mbed_retarget.cpp we create the console object from either BufferedSerial or DirectSerial (both of them inherits SerialBase class the one it really uses the HAL functions).

I can’t see further how we can deinitialize.

What makes me more confidence that serial_free from targets implementation is called only with the private method _deinit in SerialBase. _deinit is called with enable_input(false).

I found how to do so, from a comment inside the mbed_retarget.cpp

mbed_file_handle(STDIN_FILENO)->enable_input(false);
mbed_file_handle(STDOUT_FILENO)->enable_output(false);