In this blog, I would like to describe how to add the cli module on the FreeRTOS instead of using the TASK Manager (Nordic Proprietary TASK manager). Also, I would show how to use the PUTTY with Segger Embedded Studio.
The CLI has supported on the Nordic NRF5 SDK since SDK 13.0 or later.
This module allows to create and handle a command line interface (CLI) with a user-defined command set. You can use it in examples where more than button/LED user interaction is required. This module can be considered a Unix-like command line interface with these features:
- Support for multiple instances.
- Advanced cooperation with the Logger module.
- Support for static and dynamic commands.
- Smart command completion with the Tab key.
- Built-in commands:
- Viewing recently executed commands using the Up/Down keys.
- Text edition using Left/Right/End/Home/Insert keys.
- Support for ANSI escape codes:
ESC[n~for cursor control and color printing.
- Support for multiline commands.
- Built-in handler to display help for the commands.
- Support for wildcards.
- Support for meta keys.
Here are two blogs at the Nordic Development Zone to describe about the CLI.
New Command Line Interface – part 1
New Command Line Interface and enhanced Logger – part 2
Experimental: Console over Bluetooth Application
The Command Line Interface over BLE (CLI BLE) Application is an example that showcases how BLE NUS (Nordic UART service) can be used as a transport for a console.
The example folder contains a Python script that uses the PC BLE driver and an additional board to connect to the example and forward any BLE NUS traffic to a network port. A standard terminal, such as PuTTY, can be used to connect to a network port and run the console.
By using the NRF_CLI_ENABLED = 1, it must need to enable the TASK_MANAGER_ENABLED = 1 in default SDK.
By using the FreeRTOS example, there is not any official example to run with CLI module.
I do the example to support the CLI on FreeRTOS.
By using the Segger Embedded Studio, it needs to use the PUTTY.
You can refer to the URL (https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.3.0/lib_cli.html).
A strongly recommended terminal to use with the CLI module is PuTTY. It can be easily configured to send escape codes interpreted by the console. If other terminal is used, configure it according to the following PuTTY settings. See the below figures.
Apply these settings when using RTT as the transport layer for the CLI module.
- Do not use J-Link Viewer to start an RTT session because PuTTY will not display characters correctly.
- When debugging under Segger Embedded Studio with RTT configured as CLI transport, some characters might be directed to Segger Debug Window, instead of to PuTTY. To solve this problem, you need to deactivate RTT in SES:
Project settings->Debug->Debugger->RTT Enable-> Set to No.
- Do not use the SES debug window to operate the console, because it significantly limits CLI capability. Use PuTTY or a similar terminal instead.