cli stopping and uninitializing error NRF_ERROR_BUSY

sdk 16.0 52833 SD s140 standard setup

NRF_CLI_UART_ENABLED 1
NRF_LOG_CLI_CMDS 1
TASK_MANAGER_CLI_CMDS 0
NRF_CLI_ENABLED 1
NRF_CLI_LOG_BACKEND 1


In the code set the stop nrf_cli_process works as the variable internal.flag.processing  shows a value of zero

The problem
The nrf_cli.c variable internal.flag.processing is always set to 1 when the rf_cli_uninit(p_cli); call is run
I do not see where or how it can get set or why

what is the proper way to stop and uninit the CLI

Already noted

https://devzone.nordicsemi.com/f/nordic-q-a/56861/how-to-stop-disable-uninit-cli-instance-and-usb-cdc-acm-instance-gracefully/231361#231361

https://devzone.nordicsemi.com/f/nordic-q-a/69210/exit-cli-and-start-logging

https://devzone.nordicsemi.com/nordic/nordic-blog/b/blog/posts/new-command-line-interface-part-1
seems like the code is stuck in

cli_state_collect

and will not complete the

nrf_cli_process

call

Code set

    // stop nrf_cli_process
    cli_uart_set_state (false);
    nrf_delay_ms(500);

   
    ret_code_t err_code = nrf_cli_stop(p_cli);
    APP_ERROR_CHECK(err_code);
    
    // This is to allow cli_processing to complete before stopping cli
    // this doesn't work before or after the nrf_cli_stop 
    //nrf_delay_ms(500);
    //cli_uart_set_state (false);

    err_code = nrf_cli_uninit(p_cli);
    NRF_LOG_WARNING("c ec %d", err_code);
    APP_ERROR_CHECK(err_code);
    // This is to delay for the main.c cli_processing to complete before stopping cli

  • Hi,

    What happens when you call cli_uart_set_state(false)? I cannot find that function in the SDK.

    nrf_cli_stop() simply means that later calls to nrf_cli_process() will empty the buffer from the transport without handling the incoming data. It sill relies on the transport not being teared down yet. It also means cli_state_collect() will not be called from nrf_cli_process, which means if that's where it hangs, it hangs from a call to nrf_cli_process() that was initialized before the call to nrf_cli_stop(). What interrupt contexts are these API calls running in?

    I suspect that it is possible to hang in cli_state_collect() if the transport (in this case UART) has been fully or partially uninitialized, before the cli was uninitialized.

    Regards,
    Terje

Related