BaseType_t FreeRTOS_CLIRegisterCommand( CLI_Command_Definition_t *pxCommandToRegister )
FreeRTOS+CLI is an extensible framework that allows the application writer
to define and register their own command line input commands. Functions that implement the
behaviour of a user defined command have to use a particular interface, which is described
on a separate page.
This page describes FreeRTOS_CLIRegisterCommand(), which is the API function used to register commands with FreeRTOS+CLI. A command is registered by associating the function that implements the command behaviour with a text string, and telling FreeRTOS+CLI about the association. FreeRTOS+CLI will then automatically run the function each time the command text string is entered. This will become clear after reading this page.
Note: The FreeRTOS_CLIRegisterCommand() prototype that appears in the code take a const pointer to a const structure of type CLI_Command_Definition_t. The const qualifiers have been removed here to make the prototype easier to read.
|pxCommandToRegister||The command being registered, which is defined by a structure of type CLI_Command_Definition_t. The structure is described below this table.|
pdPASS is returned if the command was successfully registered.
pdFAIL is returned if the command could not be registered because there was insufficient FreeRTOS heap available for a new list item to be created.
CLI_Command_Definition_tCommands are defined by a structure of type CLI_Command_Definition_t. The structure is shown below. The comments in the code describe the structure members.
ExamplesOne of the FreeRTOS+CLI featured demos implements a file system “del” command. The command definition is given below.
Once this command is registered:
- prvDelCommand() is executed each time the user types “del”.
- “del <filename>: Deletes <filename> from the diskrn” is output to describe the del command when the user types “help”.
- The del command expects one parameter (the name of the file being deleted). FreeRTOS+CLI will output an error string instead of executing prvDelCommand() if the number of input parameters is not exactly 1.
The del command is then registered with FreeRTOS+CLI using the following function call: