This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Using CLI alongside NRF_LOG_INFO()

Hello,

I'm trying to set up an app that enables the command line interface (CLI) over UART as well as the logging.

This is the what the main looks like:

int main(void)
{
    ret_code_t err_code;

    // Initialize nRF clock driver
    err_code = nrf_drv_clock_init();
    APP_ERROR_CHECK( err_code );

    // Initialize nRF power driver
    err_code = nrf_drv_power_init(NULL);
    APP_ERROR_CHECK( err_code );

    // Initialize CLI over UART
    err_code = nrf_cli_init( &m_cli_uart );
    APP_ERROR_CHECK( err_code );

    // Start CLI service
    err_code = nrf_cli_start( &m_cli_uart );
    APP_ERROR_CHECK( err_code );

    // Setup logging
    err_code = NRF_LOG_INIT(NULL);
    APP_ERROR_CHECK(err_code);

    NRF_LOG_INFO("Example logging\n");
    NRF_LOG_INFO("One more time\n");

    NRF_LOG_FLUSH();

    while (true)
    {
        nrf_cli_process( &m_cli_uart );
    }
}

The problem I see is that the 2 lines of logging get output but the app hangs after and I cannot interact with the CLI anymore:

>ˇ:INFO:Example logging
:INFO:One more time

Any ideas about how to get the logging working with the CLI?

  • New CLI is already available with SDK14. You can download and test it. Very simple example showing how CLI can be configured as Logger backend is presented in CLI example.

    Once you will execute command:

    counter start
    

    you shall see how "logs" are printed on the screen and in parallel you can still edit new command.

Related