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

Unable to get CLI to work on SDK 14

Hello,

I'm in the process of updating our codebase to SDK 14 and am facing some problems getting the CLI to work. My goal is to get CLI and logging to output on the same UART channel.

Here's a snipped of the code I have:

// UART instance used by CLI

NRF_CLI_UART_DEF( mConsoleUARTInstance, APP_UART_DRIVER_INSTANCE, NRF_CLI_UART_TX_BUF_SIZE, NRF_CLI_UART_RX_BUF_SIZE );

// CLI instance

NRF_CLI_DEF( mConsoleInstance, "> ", &mConsoleUARTInstance.transport, '\n', NRF_CLI_LOG_QUEUE_SIZE );


ret_code_t errCode;

errCode = NRF_LOG_INIT( NULL );

APP_ERROR_CHECK( errCode );

nrf_drv_uart_config_t uartConfig = NRF_DRV_UART_DEFAULT_CONFIG;

uartConfig.pseltxd = 6;

uartConfig.pselrxd = 8;

// Initialize CLI over UART

errCode = nrf_cli_init( &mConsoleInstance, &uartConfig, false, true, NRF_LOG_DEFAULT_LEVEL );

APP_ERROR_CHECK( errCode );

// Start CLI service

errCode = nrf_cli_start( &mConsoleInstance );

APP_ERROR_CHECK( errCode );

In my app_config.h, I have the following defines:

#define UART_ENABLED                            ( 1 )                   // Enable UART which is used by CLI and Logging

#define NRF_CLI_ENABLED                        ( 1 )

#define NRF_CLI_LOG_BACKEND                    ( 1 )

#define NRF_CLI_UART_ENABLED                    ( 1 )

#define NRF_CLI_UART_RX_BUF_SIZE                ( 64 )

#define NRF_CLI_UART_TX_BUF_SIZE                ( 64 )

#define APP_UART_ENABLED                        ( 1 )

#define APP_UART_DRIVER_INSTANCE                0                       // Do not put between parenthesis as it is used in macro concatenation later

#define UART0_ENABLED                          ( 1 )

#define UART0_CONFIG_USE_EASY_DMA              ( 1 )

#define NRF_CLI_LOG_QUEUE_SIZE                  ( 8 )

#define NRF_LOG_BACKEND_UART_ENABLED            ( 1 )                   // Enable UART as backend for logging

#define NRF_LOG_BACKEND_UART_TX_PIN            ( 6 )

#define NRF_LOG_BACKEND_UART_RX_PIN            ( 8 )

#define NRF_LOG_BACKEND_UART_BAUDRATE          ( 30801920 )            // Baud rate used by nRF log backend (maps to 115200 - set to 61865984 for 230400)

If the order of inits is LOG followed by CLI, only logging would work. If I init CLI before logging, only CLI would "kind of" work.

Do you see anything that I'm obviously missing?

Also, I loaded the cli example from SDK 14 (examples/peripheral/cli) and I do get a CLI on UART but I don't get any logging. There's 2 log messages in main before the while loop that are not coming out:

NRF_LOG_RAW_INFO("Command Line Interface example.\r\n");

NRF_LOG_RAW_INFO("Please press <Tab> to see all available commands.\r\n");

I confirmed that NRF_LOG_BACKEND_UART_ENABLED is defined as 1 in sdk_config.h.

The cli example has the following calls:

APP_ERROR_CHECK(NRF_LOG_INIT(app_timer_cnt_get));

nrf_drv_uart_config_t uart_config = NRF_DRV_UART_DEFAULT_CONFIG;

uart_config.pseltxd = TX_PIN_NUMBER;

uart_config.pselrxd = RX_PIN_NUMBER;

uart_config.hwfc    = NRF_UART_HWFC_DISABLED;

ret = nrf_cli_init(&m_cli_uart, &uart_config, true, true, NRF_LOG_SEVERITY_INFO);

APP_ERROR_CHECK(ret);

cli_start();

NRF_LOG_RAW_INFO("Command Line Interface example.\r\n");

NRF_LOG_RAW_INFO("Please press <Tab> to see all available commands.\r\n");

while (true)

{

    (void)NRF_LOG_PROCESS();

    nrf_cli_process(&m_cli_uart);

My expectation is that in this example logging would come out on the same UART as CLI. Am I wrong in my expectation?

Related