Custom Commands

This contains all functionality needed to add/override commands to the ZentriOS Command API. More...

Modules

Types
Command types.
 
Macros
Command specific macros.
 

Functions

void zn_cmd_set_console_enabled (zos_bool_t enabled)
 Enable/disable the command serial console. More...
 
zos_result_t zn_cmd_register_commands (zos_cmd_lists_t *cmd_lists)
 Register commands::getters/setters serial commands. More...
 
zos_result_t zn_cmd_unregister_commands (zos_cmd_list_t *cmd_list)
 Unregister any previously registered command, getter or setter. More...
 
zos_result_t zn_cmd_start_response (zos_cmd_result_t cmd_result, size_t size)
 Begin printing a command response. More...
 
zos_result_t zn_cmd_write_response_data (const void *data, size_t data_size)
 Write the command response body. More...
 
zos_result_t zn_cmd_write_response (zos_cmd_result_t cmd_result, const void *data, size_t data_size)
 Write a complete command response. More...
 
zos_result_t zn_cmd_format_response (zos_cmd_result_t cmd_result, const char *fmt,...)
 Write formatted command response. More...
 
zos_cmd_result_t zn_cmd_set_bool (int argc, char **argv, zos_bool_t *bool_val)
 Utility to parse a boolean argument and store to given pointer.
 
zos_cmd_result_t zn_cmd_set_flag (int argc, char **argv, uint32_t *flag_ptr, uint32_t flag_val)
 Utility to parse flag argument and store to given pointer. More...
 
zos_cmd_result_t zn_cmd_set_int (int argc, char **argv, intmax_t *int_val, intmax_t min, intmax_t max)
 Utility to parse integer argument and store to given pointer. More...
 
zos_cmd_result_t zn_cmd_set_hex (int argc, char **argv, intmax_t *int_val, intmax_t min, intmax_t max)
 Utility to parse hex string and store to given pointer. More...
 
zos_cmd_result_t zn_cmd_set_encoded_str (int argc, char **argv, void *buffer, size_t max_len, size_t *saved_len)
 Utility to parse encoded string and save to given buffer.
 
zos_cmd_result_t zn_cmd_set_str (int argc, char **argv, char *buffer, size_t max_len)
 Utility to parse string and save to given buffer.
 
zos_result_t zn_cmd_read_write_data (size_t size, int read_timeout, void *user, zos_cmd_writer_t writer)
 Utility to read command bus and write data to writer argument. More...
 

Detailed Description

This contains all functionality needed to add/override commands to the ZentriOS Command API.

Function Documentation

zos_result_t zn_cmd_format_response ( zos_cmd_result_t  cmd_result,
const char *  fmt,
  ... 
)

Write formatted command response.

This will print the command header and supplied format string

Returns
zos_result_t result of api call
Examples:
cloud/mqttdemo/commands.c, demo/pong/commands.c, and demo/uart_blaster/commands.c.
zos_result_t zn_cmd_read_write_data ( size_t  size,
int  read_timeout,
void *  user,
zos_cmd_writer_t  writer 
)

Utility to read command bus and write data to writer argument.

If system.cmd.echo = 1 then characters are echoed to the command bus.

zos_result_t zn_cmd_register_commands ( zos_cmd_lists_t cmd_lists)

Register commands::getters/setters serial commands.

Note
Any duplicate command/getter/setter name overrides any previously registered name
Parameters
[in]cmd_listsLists of commands::getters/setters
Returns
zos_result_t result of api call
void zn_cmd_set_console_enabled ( zos_bool_t  enabled)

Enable/disable the command serial console.

When the command serial console is disabled, ZentriOS will not listen on the command bus for commands.

Parameters
[in]enabledEnable/disable serial command processing
Examples:
basic/ftp_upload/ftp_upload.c, basic/http_methods/main.c, and basic/uart/uart.c.
zos_cmd_result_t zn_cmd_set_flag ( int  argc,
char **  argv,
uint32_t *  flag_ptr,
uint32_t  flag_val 
)

Utility to parse flag argument and store to given pointer.

zos_cmd_result_t zn_cmd_set_hex ( int  argc,
char **  argv,
intmax_t *  int_val,
intmax_t  min,
intmax_t  max 
)

Utility to parse hex string and store to given pointer.

zos_cmd_result_t zn_cmd_set_int ( int  argc,
char **  argv,
intmax_t *  int_val,
intmax_t  min,
intmax_t  max 
)

Utility to parse integer argument and store to given pointer.

zos_result_t zn_cmd_start_response ( zos_cmd_result_t  cmd_result,
size_t  size 
)

Begin printing a command response.

This will print a serial command response header.

Parameters
[in]cmd_resultThe result of the command
[in]sizeThe size in bytes of the command response
Returns
zos_result_t result of api call
zos_result_t zn_cmd_unregister_commands ( zos_cmd_list_t cmd_list)

Unregister any previously registered command, getter or setter.

Note
The address of cmd_list must be the same as the one specified in the pointers in cmd_lists
Parameters
[in]cmd_listList of commands::getter/setters
Returns
zos_result_t result of api call
zos_result_t zn_cmd_write_response ( zos_cmd_result_t  cmd_result,
const void *  data,
size_t  data_size 
)

Write a complete command response.

This will print the command header and supplied response data

Parameters
[in]cmd_resultThe result of the command
[in]dataResponse data
[in]data_sizeThe size in bytes of the command response
Returns
zos_result_t result of api call
zos_result_t zn_cmd_write_response_data ( const void *  data,
size_t  data_size 
)

Write the command response body.

This will print the supplied response data. This should be called until the specified number of bytes from zn_cmd_start_response() have been written. e.g.:

1 zn_cmd_start_response(CMD_SUCCESS, 20);
2 zn_cmd_write_response_data(data1, 10);
3 zn_cmd_write_response_data(data2, 10);
Parameters
[in]dataResponse data
[in]data_sizeThe size of command data to be written
Returns
zos_result_t result of api call