Command Line Interface#

The Command Line Interface (CLI) software component simplifies creating command line user interfaces for programs. It handles tasks such as receiving keyboard input, parsing the input strings for commands and arguments, and finally calling the proper C function with decoded and validated arguments. Functions can use standard output functions such as printf to write information to the console. Many modules of the SDK have built-in commands that are provided via CLI, users can even add the custom commands if required.

The Command Line Interface (CLI) depends on I/O Stream for reading and writing bytes. You can set the I/O stream instance in the CLI instance configuration.

Modules#

sl_cli_command_arg_t

sl_cli_command_info_t

sl_cli_command_entry_t

sl_cli_command_group_t

sl_cli_t

sl_cli_instance_parameters_t

CLI Commands in NVM3

CLI Commands in RAM

CLI Delay

Enumerations#

enum
sl_cli_arg_uint8 = SL_CLI_ARG_UINT8
sl_cli_arg_uint16 = SL_CLI_ARG_UINT16
sl_cli_arg_uint32 = SL_CLI_ARG_UINT32
sl_cli_arg_int8 = SL_CLI_ARG_INT8
sl_cli_arg_int16 = SL_CLI_ARG_INT16
sl_cli_arg_int32 = SL_CLI_ARG_INT32
sl_cli_arg_string = SL_CLI_ARG_STRING
sl_cli_arg_hex = SL_CLI_ARG_HEX
sl_cli_arg_uint8opt = SL_CLI_ARG_UINT8OPT
sl_cli_arg_uint16opt = SL_CLI_ARG_UINT16OPT
sl_cli_arg_uint32opt = SL_CLI_ARG_UINT32OPT
sl_cli_arg_int8opt = SL_CLI_ARG_INT8OPT
sl_cli_arg_int16opt = SL_CLI_ARG_INT16OPT
sl_cli_arg_int32opt = SL_CLI_ARG_INT32OPT
sl_cli_arg_stringopt = SL_CLI_ARG_STRINGOPT
sl_cli_arg_hexopt = SL_CLI_ARG_HEXOPT
sl_cli_arg_additionnal = SL_CLI_ARG_ADDITIONAL
sl_cli_arg_wildcard = SL_CLI_ARG_WILDCARD
sl_cli_arg_group = SL_CLI_ARG_GROUP
sl_cli_arg_end = SL_CLI_ARG_END
}

Enum of all the argument types.

Typedefs#

typedef uint8_t

Argument type typedef.

typedef void(*
sl_cli_command_func_t)(sl_cli_command_arg_t *arguments)

Command handler data type.

typedef void(*
sl_cli_command_function_t)(char *arg_str, void *user)

Redirect command function.

typedef uint8_t

sl cli input type t

typedef sl_cli_t *

sl cli handle t

Variables#

The default CLI handle.

Functions#

uint8_t *
sl_cli_get_argument_hex(sl_cli_command_arg_t *a, size_t n, size_t *l)

Get the hex argument length and value.

void
sl_cli_clear(sl_cli_handle_t handle)

Clear (reset) a CLI.

void
sl_cli_redirect_command(sl_cli_handle_t handle, sl_cli_command_function_t command_function, const char *prompt, void *aux)

Redirect user input.

sl_status_t
sl_cli_handle_input(sl_cli_handle_t handle, char *string)

Handle input.

sl_status_t
sl_cli_instance_init(sl_cli_handle_t handle, sl_cli_instance_parameters_t *parameters)

Initialize a CLI instance.

bool
sl_cli_is_ok_to_sleep(sl_cli_handle_t handle)

Check if the CLI instance can allow sleep.

void
sl_cli_tick_instance(sl_cli_handle_t handle)

The bare metal tick function.

sl_status_t
sl_cli_tokenize(char input[], int *token_c, char *token_v[])

Split a C-string on space, ignoring sections in {} or "".

bool
sl_cli_command_add_command_group(sl_cli_handle_t handle, sl_cli_command_group_t *command_group)

Add a new command group.

bool
sl_cli_command_remove_command_group(sl_cli_handle_t handle, sl_cli_command_group_t *command_group)

Remove a command group.

sl_cli_command_find(sl_cli_handle_t handle, int *token_c, char *token_v[], int *arg_ofs, bool *single_flag, bool *help_flag)

Find a command given the command groups and input arguments.

sl_status_t
sl_cli_command_execute(sl_cli_handle_t handle, char *input)

Find and execute a command given the string input and the command table.

bool
sl_cli_input_char(sl_cli_handle_t handle, char c)

Handle new input char from the terminal, both in terms of writing back to terminal and writing to the input buffer.

void
sl_cli_input_clear(sl_cli_handle_t handle)

Empty the input buffer.

sl_status_t

Initialize module.

sl_status_t
sl_cli_simple_password_logout(sl_cli_handle_t handle)

Logout connected user from an instance.

sl_status_t
sl_cli_set_simple_password(char *new_password)

Set a new password.

sl_status_t

Destroy password key and force to configure a new password.

sl_status_t

Reset security warning flag.

Macros#

#define

Enable the CLI tick.

#define

Obtain the number of command arguments.

#define

Obtain the type of argument.

#define

Obtain int8 arguments.

#define

Obtain int16 arguments.

#define

Obtain int32 arguments.

#define

Obtain uint8 arguments.

#define

Obtain uint16 arguments.

#define

Obtain uint32 arguments.

#define

Obtain string arguments.

#define

Obtain the number of command strings.

#define

Obtain the command string(s).

#define
SL_CLI_COMMAND (function, help_text, arg_help, ...)

A macro, which is used to create commands.

#define
SL_CLI_COMMAND_GROUP (group_table, help_text)

A macro, which is used to create command groups.

#define

MACROS ************************************.

#define

Define the DOWN-direction.

#define

UINT8 argument type.

#define

UINT16 argument type.

#define

UINT32 argument type.

#define

INT8 argument type.

#define

INT16 argument type.

#define

INT32 argument type.

#define

STRING argument type.

#define

HEX argument type.

#define

Optional (zero or more) UINT8 argument type.

#define

Optional (zero or more) UINT16 argument type.

#define

Optional (zero or more) UINT32 argument type.

#define

Optional (zero or more) INT8 argument type.

#define

Optional (zero or more) INT16 argument type.

#define

Optional (zero or more) INT32 argument type.

#define

Optional (zero or more) STRING argument type.

#define

Optional (zero or more) HEX argument type.

#define

ADDITIONAL argument type.

#define

WILDCARD argument type.

#define

GROUP argument type.

#define

END argument type.

#define

sl cli nvm3 key count

#define

sl cli nvm3 key begin

#define
SL_CLI_NVM3_KEY_END (SL_CLI_NVM3_KEY_BEGIN + SL_CLI_NVM3_KEY_COUNT)

sl cli nvm3 key end

#define

Ordinary text or non-special characters.

#define

RETURN character.

#define

escape character (0xb)

#define

Must follow escape character. (0x5b)

Enumeration Documentation#

sl_cli_arg_t#

sl_cli_arg_t

Enum of all the argument types.

Enumerator
sl_cli_arg_uint8

UINT8 argument type.

sl_cli_arg_uint16

UINT16 argument type.

sl_cli_arg_uint32

UINT32 argument type.

sl_cli_arg_int8

INT8 argument type.

sl_cli_arg_int16

INT16 argument type.

sl_cli_arg_int32

INT32 argument type.

sl_cli_arg_string

STRING argument type.

sl_cli_arg_hex

HEX argument type.

sl_cli_arg_uint8opt

Optional (zero or more) UINT8 argument type.

sl_cli_arg_uint16opt

Optional (zero or more) UINT16 argument type.

sl_cli_arg_uint32opt

Optional (zero or more) UINT32 argument type.

sl_cli_arg_int8opt

Optional (zero or more) INT8 argument type.

sl_cli_arg_int16opt

Optional (zero or more) INT16 argument type.

sl_cli_arg_int32opt

Optional (zero or more) INT32 argument type.

sl_cli_arg_stringopt

Optional (zero or more) STRING argument type.

sl_cli_arg_hexopt

Optional (zero or more) HEX argument type.

sl_cli_arg_additionnal

ADDITIONAL argument type.

sl_cli_arg_wildcard

WILDCARD argument type.

sl_cli_arg_group

GROUP argument type.

sl_cli_arg_end

END argument type.


Definition at line 90 of file platform/service/cli/inc/sl_cli_arguments.h

Typedef Documentation#

sl_cli_argument_type_t#

typedef uint8_t sl_cli_argument_type_t

Argument type typedef.


Definition at line 90 of file platform/service/cli/inc/sl_cli_types.h

sl_cli_command_func_t#

typedef void(* sl_cli_command_func_t) (sl_cli_command_arg_t *arguments) )(sl_cli_command_arg_t *arguments)

Command handler data type.


Definition at line 102 of file platform/service/cli/inc/sl_cli_types.h

sl_cli_command_function_t#

typedef void(* sl_cli_command_function_t) (char *arg_str, void *user) )(char *arg_str, void *user)

Redirect command function.


Definition at line 105 of file platform/service/cli/inc/sl_cli_types.h

sl_cli_input_type_t#

typedef uint8_t sl_cli_input_type_t

sl cli input type t


Definition at line 138 of file platform/service/cli/inc/sl_cli_types.h

sl_cli_handle_t#

typedef sl_cli_t* sl_cli_handle_t

sl cli handle t


Definition at line 174 of file platform/service/cli/inc/sl_cli_types.h

Variable Documentation#

sl_cli_default_handle#

sl_cli_handle_t sl_cli_default_handle

The default CLI handle.


Definition at line 411 of file platform/service/cli/inc/sl_cli.h

sl_cli_default_command_group#

sl_cli_command_group_t* sl_cli_default_command_group

The default CLI command group.


Definition at line 416 of file platform/service/cli/inc/sl_cli.h

Function Documentation#

sl_cli_get_argument_hex#

uint8_t * sl_cli_get_argument_hex (sl_cli_command_arg_t * a, size_t n, size_t * l)

Get the hex argument length and value.

Parameters
[in]a

A pointer to the command arguments.

[in]n

The argument number. The first argument is number 0, the next 1, etc.

[in]l

A pointer to the variable that receives the argument value length. Note: The length is stored in a 2 byte variable. Valid lengths are in the range 0 .. 65535.

Returns

  • A pointer to the value buffer.


Definition at line 436 of file platform/service/cli/inc/sl_cli.h

sl_cli_clear#

void sl_cli_clear (sl_cli_handle_t handle)

Clear (reset) a CLI.

Parameters
[in]handle

A handle to the CLI that will be cleared.


Definition at line 445 of file platform/service/cli/inc/sl_cli.h

sl_cli_redirect_command#

void sl_cli_redirect_command (sl_cli_handle_t handle, sl_cli_command_function_t command_function, const char * prompt, void * aux)

Redirect user input.

Parameters
[in]handle

A handle to the CLI.

[in]command_function

A pointer to the function that will receive user input when the re-direct is active. NULL to stop the redirect.

[in]prompt

A pointer to a string that will be used as command prompt in the redirect function. NULL to stop the redirect.

[in]aux

A pointer that will be added to the redirect function arguments. NULL to stop the redirect.

Normally, an input string is passed to the CLI command handler for execution, but with the redirect function the input string will be passed to the alternative function. If the alternative input function should not to be used, this function can be called with NULL in the command_function, prompt and aux.


Definition at line 471 of file platform/service/cli/inc/sl_cli.h

sl_cli_handle_input#

sl_status_t sl_cli_handle_input (sl_cli_handle_t handle, char * string)

Handle input.

Parameters
[in]handle

A handle to the CLI.

[in]string

A pointer to the string containing the command line that shall be executed.

Execute a complete command line with command and arguments.

Returns

  • Execution status. Note: If the command is redirected, the function will always return SL_STATUS_OK.


Definition at line 488 of file platform/service/cli/inc/sl_cli.h

sl_cli_instance_init#

sl_status_t sl_cli_instance_init (sl_cli_handle_t handle, sl_cli_instance_parameters_t * parameters)

Initialize a CLI instance.

Parameters
[in]handle

A handle to the CLI.

[in]parameters

A pointer to the structure containing instance parameters.

Returns

  • Initialization status.


Definition at line 503 of file platform/service/cli/inc/sl_cli.h

sl_cli_is_ok_to_sleep#

bool sl_cli_is_ok_to_sleep (sl_cli_handle_t handle)

Check if the CLI instance can allow sleep.

Parameters
[in]handle

A handle to the CLI instance.

This function is available in a bare metal configuration only.

Returns

  • A boolean that is true if the CLI allows sleep, else false.


Definition at line 518 of file platform/service/cli/inc/sl_cli.h

sl_cli_tick_instance#

void sl_cli_tick_instance (sl_cli_handle_t handle)

The bare metal tick function.

Parameters
[in]handle

A handle to the CLI instance.


Definition at line 527 of file platform/service/cli/inc/sl_cli.h

sl_cli_tokenize#

sl_status_t sl_cli_tokenize (char input, int * token_c, char * token_v)

Split a C-string on space, ignoring sections in {} or "".

Parameters
[inout]input

The C-string to be split. Must be '\0'-terminated. Will be modified, even if an error occurs.

[out]token_c

The number of tokens put in the token_v array.

[out]token_v

An array containing the tokens obtained from splitting.

Note

  • This function modifies the content of the input string, and points the pointers in tokens to addresses in the input string. In quote strings ("") or curly braces ({}), the string will not be split, The quotes will be removed, but curly braces are kept for validation. To avoid '"' being interpreted as start/end of quote string, it may be escaped using '\"', both within and outside of "...". '{' may be escaped using * '\{'. There is no need for escaping '}', since only hex digits are allowed within {...}. Backslash also needs be be escaped, as '\'.

Returns

  • Status of the operation.


Definition at line 76 of file platform/service/cli/inc/sl_cli_tokenize.h

sl_cli_command_add_command_group#

bool sl_cli_command_add_command_group (sl_cli_handle_t handle, sl_cli_command_group_t * command_group)

Add a new command group.

Parameters
[inout]handle

A handle to a CLI instance.

[in]command_group

A pointer to a command group structure. Note that the structure must initially have NULL in all elements except the command_table.

Returns

  • Returns true if the command_group could be added, false otherwise.


Definition at line 112 of file platform/service/cli/inc/sl_cli_command.h

sl_cli_command_remove_command_group#

bool sl_cli_command_remove_command_group (sl_cli_handle_t handle, sl_cli_command_group_t * command_group)

Remove a command group.

Parameters
[inout]handle

A handle to a CLI instance.

[in]command_group

A pointer to a command group structure.

Returns

  • Returns true if the command_group could be removed, false otherwise.


Definition at line 127 of file platform/service/cli/inc/sl_cli_command.h

sl_cli_command_find#

const sl_cli_command_entry_t * sl_cli_command_find (sl_cli_handle_t handle, int * token_c, char * token_v, int * arg_ofs, bool * single_flag, bool * help_flag)

Find a command given the command groups and input arguments.

Parameters
[inout]handle

A handle to a CLI instance.

[in]token_c

A number of arguments given.

[in]token_v

An array containing the token_v obtained from tokenization.

[out]arg_ofs

An integer that will get the index to the first command argument. Whether the command is in a group or not will affect the arg_ofs value.

[out]single_flag

Boolean that is set to true if a specific command is detected. For help, the function may return a pointer to a command entry table or NULL, and in these cases the single_flag is set to false.

[out]help_flag

Boolean that is set to true if "help" is detected, else set to false.

Returns

  • A pointer to a command entry for the given command. If the command is not found, the returned value can be NULL. If a help command is issued, the returned value may point to a command entry table.


Definition at line 160 of file platform/service/cli/inc/sl_cli_command.h

sl_cli_command_execute#

sl_status_t sl_cli_command_execute (sl_cli_handle_t handle, char * input)

Find and execute a command given the string input and the command table.

Parameters
[inout]handle

A handle to a CLI instance.

[inout]input

C-string containing the user input. Must be '\0'-terminated.

Note

  • The input string will be modified in-place.

Returns

  • Status of the execution.


Definition at line 183 of file platform/service/cli/inc/sl_cli_command.h

sl_cli_input_char#

bool sl_cli_input_char (sl_cli_handle_t handle, char c)

Handle new input char from the terminal, both in terms of writing back to terminal and writing to the input buffer.

Parameters
[inout]handle

A handle to a CLI instance.

[in]c

Input char to be processed by the function.

This function should be called every time new input is detected. The behavior of the function is highly configurable through settings in cli_config.h.

Returns

  • Returns true if newline or return is detected, false otherwise.


Definition at line 79 of file platform/service/cli/inc/sl_cli_input.h

sl_cli_input_clear#

void sl_cli_input_clear (sl_cli_handle_t handle)

Empty the input buffer.

Parameters
[inout]handle

A handle to a CLI instance.

This function should be called after newline has been detected and the information in the buffer has been processed.


Definition at line 93 of file platform/service/cli/inc/sl_cli_input.h

sl_cli_simple_password_init#

sl_status_t sl_cli_simple_password_init (void )

Initialize module.

Parameters
N/A

Returns

  • Initialization status .


Definition at line 51 of file platform/service/cli/inc/sl_cli_simple_password.h

sl_cli_simple_password_logout#

sl_status_t sl_cli_simple_password_logout (sl_cli_handle_t handle)

Logout connected user from an instance.

Parameters
[in]handle

A handle to the CLI.

Returns

  • Initialization status.


Definition at line 60 of file platform/service/cli/inc/sl_cli_simple_password.h

sl_cli_set_simple_password#

sl_status_t sl_cli_set_simple_password (char * new_password)

Set a new password.

Parameters
[in]new_password

Password string

Returns

  • Operation status.


Definition at line 69 of file platform/service/cli/inc/sl_cli_simple_password.h

sl_cli_simple_password_destroy_key#

sl_status_t sl_cli_simple_password_destroy_key (void )

Destroy password key and force to configure a new password.

Parameters
N/A

Returns

  • Operation status.


Definition at line 76 of file platform/service/cli/inc/sl_cli_simple_password.h

sl_cli_reset_security_warning_flag#

sl_status_t sl_cli_reset_security_warning_flag (void )

Reset security warning flag.

Parameters
N/A

Returns

  • Operation status.


Definition at line 83 of file platform/service/cli/inc/sl_cli_simple_password.h

Macro Definition Documentation#

SL_CLI_TICK_ENABLE#

#define SL_CLI_TICK_ENABLE
Value:
1

Enable the CLI tick.

Trigger the creation of a tick task or the implentation of the tick handling function.


Definition at line 60 of file platform/service/cli/inc/sl_cli.h

sl_cli_get_argument_count#

#define sl_cli_get_argument_count
Value:
(a)

Obtain the number of command arguments.

Users obtain the number of command arguments with this macro.

Returns

  • The number of command arguments.

An example could be the CLI input of example_sub_menu example_command hello 255 -100 {AA BB CC} with corresponding C code of:

void example_command(sl_cli_command_arg_t *args)
{
  // Get the number of arguments (after the command strings).
  int arg_count = sl_cli_get_argument_count(args); // arg_count = 4
}

Definition at line 88 of file platform/service/cli/inc/sl_cli.h

sl_cli_get_argument_type#

#define sl_cli_get_argument_type
Value:
(a, n)

Obtain the type of argument.

Users obtain the type of the argument with this macro.

Returns

  • enum of the argument type.

For auto-generated commands, it could be useful in the handler to know the type of the argument.


Definition at line 111 of file platform/service/cli/inc/sl_cli.h

sl_cli_get_argument_int8#

#define sl_cli_get_argument_int8
Value:
(a, n)

Obtain int8 arguments.

Returns

  • The argument value.

An example could be the CLI input of example_sub_menu example_command hello 255 -100 {AA BB CC} with corresponding C code of:

void example_command(sl_cli_command_arg_t *args)
{
  // Get the arguments (after the command strings).
  char *text_ptr = sl_cli_get_argument_string(args, 0);  // char ptr to
  // "hello"
  uint8_t num1_u8 = sl_cli_get_argument_uint8(args, 1);  // num1_u8 = 255
  int16_t num2_i16 = sl_cli_get_argument_int16(args, 2); // num2_i16 = -100
  size_t hex_array_size;
  uint8_t *hex_array_ptr = sl_cli_get_argument_hex(args, 3, &hex_array_size);
  // uint8_t ptr to {0xAA, 0xBB, 0xCC}, hex_array_size = 3
}

Definition at line 144 of file platform/service/cli/inc/sl_cli.h

sl_cli_get_argument_int16#

#define sl_cli_get_argument_int16
Value:
(a, n)

Obtain int16 arguments.

Returns

  • The argument value.

An example could be the CLI input of example_sub_menu example_command hello 255 -100 {AA BB CC} with corresponding C code of:

void example_command(sl_cli_command_arg_t *args)
{
  // Get the arguments (after the command strings).
  char *text_ptr = sl_cli_get_argument_string(args, 0);  // char ptr to
  // "hello"
  uint8_t num1_u8 = sl_cli_get_argument_uint8(args, 1);  // num1_u8 = 255
  int16_t num2_i16 = sl_cli_get_argument_int16(args, 2); // num2_i16 = -100
  size_t hex_array_size;
  uint8_t *hex_array_ptr = sl_cli_get_argument_hex(args, 3, &hex_array_size);
  // uint8_t ptr to {0xAA, 0xBB, 0xCC}, hex_array_size = 3
}

Definition at line 177 of file platform/service/cli/inc/sl_cli.h

sl_cli_get_argument_int32#

#define sl_cli_get_argument_int32
Value:
(a, n)

Obtain int32 arguments.

Returns

  • The argument value.

An example could be the CLI input of example_sub_menu example_command hello 255 -100 {AA BB CC} with corresponding C code of:

void example_command(sl_cli_command_arg_t *args)
{
  // Get the arguments (after the command strings).
  char *text_ptr = sl_cli_get_argument_string(args, 0);  // char ptr to
  // "hello"
  uint8_t num1_u8 = sl_cli_get_argument_uint8(args, 1);  // num1_u8 = 255
  int16_t num2_i16 = sl_cli_get_argument_int16(args, 2); // num2_i16 = -100
  size_t hex_array_size;
  uint8_t *hex_array_ptr = sl_cli_get_argument_hex(args, 3, &hex_array_size);
  // uint8_t ptr to {0xAA, 0xBB, 0xCC}, hex_array_size = 3
}

Definition at line 210 of file platform/service/cli/inc/sl_cli.h

sl_cli_get_argument_uint8#

#define sl_cli_get_argument_uint8
Value:
(a, n)

Obtain uint8 arguments.

Returns

  • The argument value.

An example could be the CLI input of example_sub_menu example_command hello 255 -100 {AA BB CC} with corresponding C code of:

void example_command(sl_cli_command_arg_t *args)
{
  // Get the arguments (after the command strings).
  char *text_ptr = sl_cli_get_argument_string(args, 0);  // char ptr to
  // "hello"
  uint8_t num1_u8 = sl_cli_get_argument_uint8(args, 1);  // num1_u8 = 255
  int16_t num2_i16 = sl_cli_get_argument_int16(args, 2); // num2_i16 = -100
  size_t hex_array_size;
  uint8_t *hex_array_ptr = sl_cli_get_argument_hex(args, 3, &hex_array_size);
  // uint8_t ptr to {0xAA, 0xBB, 0xCC}, hex_array_size = 3
}

Definition at line 243 of file platform/service/cli/inc/sl_cli.h

sl_cli_get_argument_uint16#

#define sl_cli_get_argument_uint16
Value:
(a, n)

Obtain uint16 arguments.

Returns

  • The argument value.

An example could be the CLI input of example_sub_menu example_command hello 255 -100 {AA BB CC} with corresponding C code of:

void example_command(sl_cli_command_arg_t *args)
{
  // Get the arguments (after the command strings).
  char *text_ptr = sl_cli_get_argument_string(args, 0);  // char ptr to
  // "hello"
  uint8_t num1_u8 = sl_cli_get_argument_uint8(args, 1);  // num1_u8 = 255
  int16_t num2_i16 = sl_cli_get_argument_int16(args, 2); // num2_i16 = -100
  size_t hex_array_size;
  uint8_t *hex_array_ptr = sl_cli_get_argument_hex(args, 3, &hex_array_size);
  // uint8_t ptr to {0xAA, 0xBB, 0xCC}, hex_array_size = 3
}

Definition at line 276 of file platform/service/cli/inc/sl_cli.h

sl_cli_get_argument_uint32#

#define sl_cli_get_argument_uint32
Value:
(a, n)

Obtain uint32 arguments.

Returns

  • The argument value.

An example could be the CLI input of example_sub_menu example_command hello 255 -100 {AA BB CC} with corresponding C code of:

void example_command(sl_cli_command_arg_t *args)
{
  // Get the arguments (after the command strings).
  char *text_ptr = sl_cli_get_argument_string(args, 0);  // char ptr to
  // "hello"
  uint8_t num1_u8 = sl_cli_get_argument_uint8(args, 1);  // num1_u8 = 255
  int16_t num2_i16 = sl_cli_get_argument_int16(args, 2); // num2_i16 = -100
  size_t hex_array_size;
  uint8_t *hex_array_ptr = sl_cli_get_argument_hex(args, 3, &hex_array_size);
  // uint8_t ptr to {0xAA, 0xBB, 0xCC}, hex_array_size = 3
}

Definition at line 309 of file platform/service/cli/inc/sl_cli.h

sl_cli_get_argument_string#

#define sl_cli_get_argument_string
Value:
(a, n)

Obtain string arguments.

Returns

  • The argument value. For hex arguments, the return value is a pointer to a buffer containing decoded values. For string arguments, the return value is a pointer to the string.

An example could be the CLI input of example_sub_menu example_command hello 255 -100 {AA BB CC} with corresponding C code of:

void example_command(sl_cli_command_arg_t *args)
{
  // Get the arguments (after the command strings).
  char *text_ptr = sl_cli_get_argument_string(args, 0);  // char ptr to
  // "hello"
  uint8_t num1_u8 = sl_cli_get_argument_uint8(args, 1);  // num1_u8 = 255
  int16_t num2_i16 = sl_cli_get_argument_int16(args, 2); // num2_i16 = -100
  size_t hex_array_size;
  uint8_t *hex_array_ptr = sl_cli_get_argument_hex(args, 3, &hex_array_size);
  // uint8_t ptr to {0xAA, 0xBB, 0xCC}, hex_array_size = 3
}

Definition at line 345 of file platform/service/cli/inc/sl_cli.h

sl_cli_get_command_count#

#define sl_cli_get_command_count
Value:
(a)

Obtain the number of command strings.

Users obtain the number of command strings with this macro.

Returns

  • The number of command strings.

An example could be the CLI input of example_sub_menu example_command hello 255 -100 {AA BB CC} with corresponding C code of:

void example_command(sl_cli_command_arg_t *args)
{
  // Get the number of command strings (before the arguments).
  int cmd_count = sl_cli_get_command_count(args); // cmd_count = 2
  // (first string being "example_sub_menu" and second "example_command")
}

Definition at line 373 of file platform/service/cli/inc/sl_cli.h

sl_cli_get_command_string#

#define sl_cli_get_command_string
Value:
(a, n)

Obtain the command string(s).

Users get the command string with this macro. If the command is used in a group, both the group string(s) and command string can be obtained. The total number of command strings is available in the command argument arg_ofs variable.

An example could be the CLI input of example_sub_menu example_command hello 255 -100 {AA BB CC} with corresponding C code of:

void example_command(sl_cli_command_arg_t *args)
{
  // Get the command strings (before the arguments).
  char *cmd1_ptr = sl_cli_get_command_string(args, 0); // char ptr to
  // "example_sub_menu"
  char *cmd2_ptr = sl_cli_get_command_string(args, 1); // char ptr to
  // "example_command"
}

Definition at line 406 of file platform/service/cli/inc/sl_cli.h

SL_CLI_COMMAND#

#define SL_CLI_COMMAND
Value:
{ \
(function), /* Pointer to command function */ \
__VA_ARGS__ /* Argument list*/ \
}

A macro, which is used to create commands.


Definition at line 81 of file platform/service/cli/inc/sl_cli_command.h

SL_CLI_COMMAND_GROUP#

#define SL_CLI_COMMAND_GROUP
Value:
{ \
((sl_cli_command_func_t)(group_table)), /* Group pointer */ \
{ SL_CLI_ARG_GROUP, } /* Group indicator */ \
}

A macro, which is used to create command groups.


Definition at line 90 of file platform/service/cli/inc/sl_cli_command.h

SL_CLI_INPUT_DIRECTION_UP#

#define SL_CLI_INPUT_DIRECTION_UP
Value:
(1)

MACROS ************************************.

Define the UP-direction.


Definition at line 56 of file platform/service/cli/inc/sl_cli_input.h

SL_CLI_INPUT_DIRECTION_DOWN#

#define SL_CLI_INPUT_DIRECTION_DOWN
Value:
(-1)

Define the DOWN-direction.


Definition at line 58 of file platform/service/cli/inc/sl_cli_input.h

SL_CLI_ARG_UINT8#

#define SL_CLI_ARG_UINT8
Value:
(0x00U)

UINT8 argument type.


Definition at line 49 of file platform/service/cli/inc/sl_cli_arguments.h

SL_CLI_ARG_UINT16#

#define SL_CLI_ARG_UINT16
Value:
(0x01U)

UINT16 argument type.


Definition at line 51 of file platform/service/cli/inc/sl_cli_arguments.h

SL_CLI_ARG_UINT32#

#define SL_CLI_ARG_UINT32
Value:
(0x02U)

UINT32 argument type.


Definition at line 53 of file platform/service/cli/inc/sl_cli_arguments.h

SL_CLI_ARG_INT8#

#define SL_CLI_ARG_INT8
Value:
(0x03U)

INT8 argument type.


Definition at line 55 of file platform/service/cli/inc/sl_cli_arguments.h

SL_CLI_ARG_INT16#

#define SL_CLI_ARG_INT16
Value:
(0x04U)

INT16 argument type.


Definition at line 57 of file platform/service/cli/inc/sl_cli_arguments.h

SL_CLI_ARG_INT32#

#define SL_CLI_ARG_INT32
Value:
(0x05U)

INT32 argument type.


Definition at line 59 of file platform/service/cli/inc/sl_cli_arguments.h

SL_CLI_ARG_STRING#

#define SL_CLI_ARG_STRING
Value:
(0x06U)

STRING argument type.


Definition at line 61 of file platform/service/cli/inc/sl_cli_arguments.h

SL_CLI_ARG_HEX#

#define SL_CLI_ARG_HEX
Value:
(0x07U)

HEX argument type.


Definition at line 63 of file platform/service/cli/inc/sl_cli_arguments.h

SL_CLI_ARG_UINT8OPT#

#define SL_CLI_ARG_UINT8OPT
Value:
(0x10U)

Optional (zero or more) UINT8 argument type.


Definition at line 65 of file platform/service/cli/inc/sl_cli_arguments.h

SL_CLI_ARG_UINT16OPT#

#define SL_CLI_ARG_UINT16OPT
Value:
(0x11U)

Optional (zero or more) UINT16 argument type.


Definition at line 67 of file platform/service/cli/inc/sl_cli_arguments.h

SL_CLI_ARG_UINT32OPT#

#define SL_CLI_ARG_UINT32OPT
Value:
(0x12U)

Optional (zero or more) UINT32 argument type.


Definition at line 69 of file platform/service/cli/inc/sl_cli_arguments.h

SL_CLI_ARG_INT8OPT#

#define SL_CLI_ARG_INT8OPT
Value:
(0x13U)

Optional (zero or more) INT8 argument type.


Definition at line 71 of file platform/service/cli/inc/sl_cli_arguments.h

SL_CLI_ARG_INT16OPT#

#define SL_CLI_ARG_INT16OPT
Value:
(0x14U)

Optional (zero or more) INT16 argument type.


Definition at line 73 of file platform/service/cli/inc/sl_cli_arguments.h

SL_CLI_ARG_INT32OPT#

#define SL_CLI_ARG_INT32OPT
Value:
(0x15U)

Optional (zero or more) INT32 argument type.


Definition at line 75 of file platform/service/cli/inc/sl_cli_arguments.h

SL_CLI_ARG_STRINGOPT#

#define SL_CLI_ARG_STRINGOPT
Value:
(0x16U)

Optional (zero or more) STRING argument type.


Definition at line 77 of file platform/service/cli/inc/sl_cli_arguments.h

SL_CLI_ARG_HEXOPT#

#define SL_CLI_ARG_HEXOPT
Value:
(0x17U)

Optional (zero or more) HEX argument type.


Definition at line 79 of file platform/service/cli/inc/sl_cli_arguments.h

SL_CLI_ARG_ADDITIONAL#

#define SL_CLI_ARG_ADDITIONAL
Value:
(0x20U)

ADDITIONAL argument type.


Definition at line 81 of file platform/service/cli/inc/sl_cli_arguments.h

SL_CLI_ARG_WILDCARD#

#define SL_CLI_ARG_WILDCARD
Value:
(0x21U)

WILDCARD argument type.


Definition at line 83 of file platform/service/cli/inc/sl_cli_arguments.h

SL_CLI_ARG_GROUP#

#define SL_CLI_ARG_GROUP
Value:
(0xFEU)

GROUP argument type.


Definition at line 85 of file platform/service/cli/inc/sl_cli_arguments.h

SL_CLI_ARG_END#

#define SL_CLI_ARG_END
Value:
(0xFFU)

END argument type.


Definition at line 87 of file platform/service/cli/inc/sl_cli_arguments.h

SL_CLI_NVM3_KEY_COUNT#

#define SL_CLI_NVM3_KEY_COUNT
Value:
(0x100)

sl cli nvm3 key count


Definition at line 71 of file platform/service/cli/inc/sl_cli_types.h

SL_CLI_NVM3_KEY_BEGIN#

#define SL_CLI_NVM3_KEY_BEGIN
Value:
(0x3000)

sl cli nvm3 key begin


Definition at line 72 of file platform/service/cli/inc/sl_cli_types.h

SL_CLI_NVM3_KEY_END#

#define SL_CLI_NVM3_KEY_END
Value:
(SL_CLI_NVM3_KEY_BEGIN + SL_CLI_NVM3_KEY_COUNT)

sl cli nvm3 key end


Definition at line 73 of file platform/service/cli/inc/sl_cli_types.h

SL_CLI_INPUT_ORDINARY#

#define SL_CLI_INPUT_ORDINARY
Value:
(0U)

Ordinary text or non-special characters.


Definition at line 76 of file platform/service/cli/inc/sl_cli_types.h

SL_CLI_INPUT_RETURN#

#define SL_CLI_INPUT_RETURN
Value:
(1U)

RETURN character.


Definition at line 77 of file platform/service/cli/inc/sl_cli_types.h

SL_CLI_INPUT_ESCAPE#

#define SL_CLI_INPUT_ESCAPE
Value:
(2U)

escape character (0xb)


Definition at line 78 of file platform/service/cli/inc/sl_cli_types.h

SL_CLI_INPUT_ARROW#

#define SL_CLI_INPUT_ARROW
Value:
(3U)

Must follow escape character. (0x5b)


Definition at line 79 of file platform/service/cli/inc/sl_cli_types.h