Command specific macros. More...

Macros

#define ZOS_CMD_ADD_CMD_LIST(name, list_ptr, _list_type)
 Helper macro to initialize a zos_cmd_list_t struct.
 
#define ZOS_CMD_CREATE_CMD_LISTS(_commands, _getters, _setters)
 Helper macro to initialize a zos_cmd_lists_t struct.
 
#define ZOS_ADD_GETTER(key, name)   {key, 0, 0, &__zos_get_ ## name ## _command, 255}
 Helper macro to add a getter to a command listSee zos_var_args_command_t. More...
 
#define ZOS_ADD_SETTER(key, name)   {key, 0, 0, &__zos_set_ ## name ## _command, 255}
 Helper macro to add a setter to a command listSee zos_var_args_command_t. More...
 
#define ZOS_ADD_COMMAND(key, min, max, retval, name)   { key, NULL, & __zos_cmd_ ## name ## _command, min, max, retval, ZOS_TRUE}
 Helper macro to add a command to a command listSee zos_command_t. More...
 
#define ZOS_GETTERS_START(id)   static zos_var_args_command_t _zos_getters_list_ ## id[] = {
 Utility macro to declare a getters command list This should be used with ZOS_COMMAND_LISTS() and ZOS_CMD_REGISTER_COMMANDS()
 
#define ZOS_GETTERS_END   };
 End list of getters.
 
#define ZOS_SETTERS_START(id)   static zos_var_args_command_t _zos_setters_list_ ## id[] = {
 Utility macro to declare a setters command list This should be used with ZOS_COMMAND_LISTS() and ZOS_CMD_REGISTER_COMMANDS()
 
#define ZOS_SETTERS_END   };
 End list of setters.
 
#define ZOS_COMMANDS_START(id)   static zos_command_t _zos_command_list_ ## id[] = {
 Utility macro to declare a command list This should be used with ZOS_COMMAND_LISTS() and ZOS_CMD_REGISTER_COMMANDS()
 
#define ZOS_COMMANDS_END   };
 End list of commands.
 
#define ZOS_COMMAND_LISTS(id)   static zos_cmd_lists_t _zos_commands_ ## id = ZOS_CMD_CREATE_CMD_LISTS(_zos_command_list_ ## id, _zos_getters_list_ ## id, _zos_setters_list_ ## id);
 Utility macro to declare and initialize a zos_cmd_lists_t struct.
 
#define ZOS_CMD_REGISTER_COMMANDS(id)   zn_cmd_register_commands(&_zos_commands_ ## id)
 Utility macro to register custom commands with ZentriOS.
 
#define ZOS_CMD_UNREGISTER_COMMANDS(id)
 Utility macro to unregister custom serial commands.
 
#define ZOS_DEFINE_GETTER(name)   static zos_cmd_result_t __zos_get_ ## name ## _command(int argc, char **argv)
 Help macro to define a getter command implementationThe getter function is of the format: More...
 
#define ZOS_DEFINE_SETTER(name)   static zos_cmd_result_t __zos_set_ ## name ## _command(int argc, char **argv)
 Help macro to define a setter command implementationThe getter function is of the format: More...
 
#define ZOS_DEFINE_COMMAND(name)   static zos_cmd_result_t __zos_cmd_ ## name ## _command(int argc, char **argv)
 Help macro to define a command implementationThe command function is of the format: More...
 
#define ZOS_CMD_PARSE_INT_ARG_WITH_VAR(type, var, str, min, max)
 Utility macro to parse an integer argument and store in supplied variable. More...
 
#define ZOS_CMD_PARSE_INT_ARG(type, name, str, min, max)
 Utility macro to parse an integer argument and store in created variable. More...
 
#define ZOS_CMD_PARSE_HEX_ARG_WITH_VAR(type, var, str, min, max)
 Utility macro to parse an hexadecimal argument and store in supplied variable. More...
 
#define ZOS_CMD_PARSE_HEX_ARG(type, name, str, min, max)
 Utility macro to parse an hexadecimal argument and store in created variable. More...
 

Detailed Description

Command specific macros.

Macro Definition Documentation

#define ZOS_ADD_COMMAND (   key,
  min,
  max,
  retval,
  name 
)    { key, NULL, & __zos_cmd_ ## name ## _command, min, max, retval, ZOS_TRUE}

Helper macro to add a command to a command listSee zos_command_t.

Parameters
keyThe command name string
minThe minimum number of arguments the command accepts
maxThe maximum number of arguments the command accepts
nameThe name of the command function
retvalif ZOS_TRUE then command local prints a return value, if ZOS_FALSE then ZentriOS should print a return value
Examples:
basic/buffer_dump/buffer_dump.c, cloud/cloud_filesystem/cloud_filesystem.c, cloud/mqttdemo/commands.c, demo/pong/commands.c, and demo/uart_blaster/commands.c.
#define ZOS_ADD_GETTER (   key,
  name 
)    {key, 0, 0, &__zos_get_ ## name ## _command, 255}

Helper macro to add a getter to a command listSee zos_var_args_command_t.

Parameters
keyThe 'getter name' (i.e. variable name) string
nameThe name of the getter function
Examples:
cloud/mqttdemo/commands.c, demo/pong/commands.c, and demo/uart_blaster/commands.c.
#define ZOS_ADD_SETTER (   key,
  name 
)    {key, 0, 0, &__zos_set_ ## name ## _command, 255}

Helper macro to add a setter to a command listSee zos_var_args_command_t.

Parameters
keyThe 'setter name' (i.e. variable name) string
nameThe name of the getter function
Examples:
cloud/mqttdemo/commands.c, demo/pong/commands.c, and demo/uart_blaster/commands.c.
#define ZOS_CMD_PARSE_HEX_ARG (   type,
  name,
  str,
  min,
  max 
)
Value:
type name;\
ZOS_CMD_PARSE_HEX_ARG_WITH_VAR(type, name, str, min, max)
#define ZOS_CMD_PARSE_HEX_ARG_WITH_VAR(type, var, str, min, max)
Utility macro to parse an hexadecimal argument and store in supplied variable.
Definition: zos_cmd.h:203

Utility macro to parse an hexadecimal argument and store in created variable.

Note
If parsing fails then then function returns with the value CMD_BAD_ARGS
Parameters
typeThe datatype of varaible to create(e.g. uint32_t)
nameThe name of the variable to create
strHex string to parse
minMinumum value of the integer
maxMaximum value of the integer
#define ZOS_CMD_PARSE_HEX_ARG_WITH_VAR (   type,
  var,
  str,
  min,
  max 
)
Value:
do {\
intmax_t value;\
if(str_parse_hex(str, &value, min, max) != ZOS_SUCCESS) return CMD_BAD_ARGS;\
var = (type)value;\
} while (0)
Complete successfully.
Definition: zos_types.h:20
Invalid command arguments.
Definition: zos_cmd.h:244
zos_result_t str_parse_hex(const char *s, intmax_t *result, intmax_t min, intmax_t max)
Parse hexadecimal integer and check if it's in bounds [min, max].

Utility macro to parse an hexadecimal argument and store in supplied variable.

Note
If parsing fails then then function returns with the value CMD_BAD_ARGS
Parameters
typeThe argument datatype (e.g. uint32_t)
varThe name of existing variable
strHex string to parse
minMinumum value of the integer
maxMaximum value of the integer
#define ZOS_CMD_PARSE_INT_ARG (   type,
  name,
  str,
  min,
  max 
)
Value:
type name;\
ZOS_CMD_PARSE_INT_ARG_WITH_VAR(type, name, str, min, max)
#define ZOS_CMD_PARSE_INT_ARG_WITH_VAR(type, var, str, min, max)
Utility macro to parse an integer argument and store in supplied variable.
Definition: zos_cmd.h:168

Utility macro to parse an integer argument and store in created variable.

Note
If parsing fails then then function returns with the value CMD_BAD_ARGS
Parameters
typeThe datatype of varaible to create(e.g. uint32_t)
nameThe name of the variable to create
strInteger string to parse
minMinumum value of the integer
maxMaximum value of the integer
Examples:
basic/buffer_dump/buffer_dump.c.
#define ZOS_CMD_PARSE_INT_ARG_WITH_VAR (   type,
  var,
  str,
  min,
  max 
)
Value:
do {\
intmax_t value;\
if(str_parse_int(str, &value, min, max) != ZOS_SUCCESS) return CMD_BAD_ARGS;\
var = (type)value;\
} while (0)
Complete successfully.
Definition: zos_types.h:20
Invalid command arguments.
Definition: zos_cmd.h:244
zos_result_t str_parse_int(const char *s, intmax_t *result, intmax_t min, intmax_t max)
Parse decimal integer and check if it's in bounds [min, max].

Utility macro to parse an integer argument and store in supplied variable.

Note
If parsing fails then then function returns with the value CMD_BAD_ARGS
Parameters
typeThe argument datatype (e.g. uint32_t)
varThe name of existing variable
strInteger string to parse
minMinumum value of the integer
maxMaximum value of the integer
Examples:
basic/buffer_dump/buffer_dump.c, cloud/mqttdemo/commands.c, demo/pong/commands.c, and demo/uart_blaster/commands.c.
#define ZOS_DEFINE_COMMAND (   name)    static zos_cmd_result_t __zos_cmd_ ## name ## _command(int argc, char **argv)

Help macro to define a command implementationThe command function is of the format:

1 static zos_cmd_result_t set_mycommand_command(int argc, char **arg)
Parameters
nameThe name of the 'command' function
Examples:
basic/buffer_dump/buffer_dump.c, cloud/cloud_filesystem/cloud_filesystem.c, cloud/mqttdemo/commands.c, demo/pong/commands.c, and demo/uart_blaster/commands.c.
#define ZOS_DEFINE_GETTER (   name)    static zos_cmd_result_t __zos_get_ ## name ## _command(int argc, char **argv)

Help macro to define a getter command implementationThe getter function is of the format:

1 static zos_cmd_result_t get_mysetting_command(int argc, char **arg)
Parameters
nameThe name of the 'getter' function
Examples:
cloud/mqttdemo/commands.c, demo/pong/commands.c, and demo/uart_blaster/commands.c.
#define ZOS_DEFINE_SETTER (   name)    static zos_cmd_result_t __zos_set_ ## name ## _command(int argc, char **argv)

Help macro to define a setter command implementationThe getter function is of the format:

1 static zos_cmd_result_t set_mysetting_command(int argc, char **arg)
Parameters
nameThe name of the 'setter' function
Examples:
cloud/mqttdemo/commands.c, demo/pong/commands.c, and demo/uart_blaster/commands.c.