This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

NRF_LOG...() function on VirtualCom (like printf).

I'm using the "ble_app_uart" example from "nRF5_SDK_15.2.0_9412b96".
I would like to enable the sending of logs to the serial port (Virtual com), like "printf ()".

The code is this (for example):

static void idle_state_handle (void)
{
     if (NRF_LOG_PROCESS () == false)
     {
         nrf_pwr_mgmt_run ();
     }
}

main ()
{
     // Start execution.
     printf (UART started);
     NRF_LOG_INFO ("Debug logging for UART over RTT started.");
 
     // Enter main loop.
     for (;;)
     {
         idle_state_handle ();
         mdb_handler ();
    }
}

Note:

1) The message "UART started" from printf () is displayed on the virtual com port, but not the message "Debug logging for UART over RTT started."
2) #ifndef NRF_LOG_ENABLED
     #define NRF_LOG_ENABLED 1
     #endif
3) All library files are like "ble_app_uart" example from "nRF5_SDK_15.2.0_9412b96".

Question:

Is it possible to send logs from NRF_LOG ... to the VCP (like printf) ?
What should I change to do this ?
Where can I find an example ?

Thank you.

BR
Demetrio Magrin

Parents
  • If you open the sdk_config.h file you will see that NRF_LOG_BACKEND_RTT_ENABLED is set to 1, while NRF_LOG_BACKEND_UART_ENABLED is not defined. This will make RTT as a backend when calling NRF_LOG_INFO(..), and if you download and use J-Link RTT Viewer you will be able to see the NRF_LOG_.. messages.

    Read this and this thread for more information about logging backends, uart and why you can't use both NRF_LOG_.. (with UART as backend) and printf() at the same time.

    Best regards,

    Simon

Reply
  • If you open the sdk_config.h file you will see that NRF_LOG_BACKEND_RTT_ENABLED is set to 1, while NRF_LOG_BACKEND_UART_ENABLED is not defined. This will make RTT as a backend when calling NRF_LOG_INFO(..), and if you download and use J-Link RTT Viewer you will be able to see the NRF_LOG_.. messages.

    Read this and this thread for more information about logging backends, uart and why you can't use both NRF_LOG_.. (with UART as backend) and printf() at the same time.

    Best regards,

    Simon

Children
Related