How to add the CLI (Command Line interface) on FreeRTOS instead of Task Manager

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: clearclicolorsechohistory and resize.
  • Viewing recently executed commands using the Up/Down keys.
  • Text edition using Left/Right/End/Home/Insert keys.
  • Support for ANSI escape codes: VT100 and 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.

https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.2.0/lib_cli.html

Here are two blogs at the Nordic Development Zone to describe about the CLI.

New Command Line Interface – part 1

https://devzone.nordicsemi.com/nordic/nordic-blog/b/blog/posts/new-command-line-interface-part-1

New Command Line Interface and enhanced Logger – part 2

https://devzone.nordicsemi.com/nordic/nordic-blog/b/blog/posts/new-command-line-interface-and-enhanced-logger-par

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.

https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.2.0/ble_sdk_app_cli.html

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.

Example code is placed at https://github.com/jimmywong2003/nRF5-freeRTOS-BLE-Central-or-Peripheral-Example/tree/master/ble_app_multiple_nus_c_freeRTOS_cli_flash

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).

Terminal settings

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.

RTT settings

Apply these settings when using RTT as the transport layer for the CLI module.

Warning

  • 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.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.