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 SC2(a1, a2, b)   ZOS_CMD_SHORTCUT_HASH2(a1, a2, b)
 Helper function for creating a two item short, e.g. More...
 
#define SC3(a1, a2, b, c)   ZOS_CMD_SHORTCUT_HASH3(a1, a2, b, c)
 Helper function for creating a three item short, e.g. More...
 
#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_GETTER_SC(key, shortcut, name)   {key, shortcut, &__zos_get_ ## name ## _command, 255}
 Helper macro to add a getter with a shortcut to a command list. 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_SETTER_SC(key, shortcut, name)   {key, shortcut, &__zos_set_ ## name ## _command, 255}
 Helper macro to add a setter with a shortcut to a command list. 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_ADD_COMMAND_SC(key, shortcut, min, max, retval, name)   { key, shortcut, & __zos_cmd_ ## name ## _command, min, max, retval, ZOS_TRUE}
 Helper macro to add a command with a shortcut to a command list. 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 SC2 (   a1,
  a2,
 
)    ZOS_CMD_SHORTCUT_HASH2(a1, a2, b)

Helper function for creating a two item short, e.g.

1 get wlan.ssid -> get wl s -> CS1('w', 'l', 's')
#define SC3 (   a1,
  a2,
  b,
 
)    ZOS_CMD_SHORTCUT_HASH3(a1, a2, b, c)

Helper function for creating a three item short, e.g.

1 get wlan.powersave.mode -> get wl p m -> CS1('w', 'l', 'p','m')
#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
retvalif ZOS_TRUE then command local prints a return value, if ZOS_FALSE then ZentriOS should print a return value
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_ADD_COMMAND_SC (   key,
  shortcut,
  min,
  max,
  retval,
  name 
)    { key, shortcut, & __zos_cmd_ ## name ## _command, min, max, retval, ZOS_TRUE}

Helper macro to add a command with a shortcut to a command list.

This has the same functionality as ZOS_ADD_COMMAND but also supports creating a shortcut for the command The shortcut may be any string value, e.g.

1 wlan_scan -> scan
Parameters
keyThe command name string
shortcutThe command shortcut string
minThe minimum number of arguments the command accepts
maxThe maximum number of arguments the command accepts
retvalif ZOS_TRUE then command local prints a return value, if ZOS_FALSE then ZentriOS should print a return value
nameThe name of the command function
#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.

Note
This does not create a shortcut. See ZOS_ADD_GETTER_SC
Parameters
keyThe 'getter name' (i.e. variable name) string
nameThe name of the getter function
Examples:
cloud/mqttdemo/commands.c, cloud/s2cdemo/commands.c, demo/pong/commands.c, and demo/uart_blaster/commands.c.
#define ZOS_ADD_GETTER_SC (   key,
  shortcut,
  name 
)    {key, shortcut, &__zos_get_ ## name ## _command, 255}

Helper macro to add a getter with a shortcut to a command list.

This has the same functionality as ZOS_ADD_GETTER but also supports creating a shortcut for the getter. See SC2 and SC3 for creating a shortcut

Parameters
keyThe 'setter name' (i.e. variable name) string
shortcutGetter shortcut, see SC2 or SC3
nameThe name of the getter function
#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, cloud/s2cdemo/commands.c, demo/pong/commands.c, and demo/uart_blaster/commands.c.
#define ZOS_ADD_SETTER_SC (   key,
  shortcut,
  name 
)    {key, shortcut, &__zos_set_ ## name ## _command, 255}

Helper macro to add a setter with a shortcut to a command list.

This has the same functionality as ZOS_ADD_SETTER but also supports creating a shortcut for the setter. See SC2 and SC3 for creating a shortcut

Parameters
keyThe 'setter name' (i.e. variable name) string
shortcutSetter shortcut, see SC2 or SC3
nameThe name of the getter function
#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:273

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:314
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:237

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
If the supplied string starts with 0x it will be parsed as HEX.
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:314
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
If the supplied string starts with 0x it will be parsed as HEX.
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, cloud/s2cdemo/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, cloud/s2cdemo/commands.c, demo/pong/commands.c, and demo/uart_blaster/commands.c.