SingingCat 0
application
|
code to encode/decode commands to a serialized or in-ram format More...
#include "main-header.h"
#include "coms/coms.h"
#include "platform-header.h"
Go to the source code of this file.
Macros | |
#define | CNWDEBUGCOM(a, ...) noop() |
#define | command_names_size 60 |
Functions | |
int | _command_add_encoded_arg (struct command *com, byte *buf) |
int | ascii_commandstring_to_num (const byte *buf, int size, int *const newpos) |
match a string to a command num. More... | |
void | command_add_arg (struct command *com, const char *format,...) |
adds an arg to a partially initialised command structure More... | |
int | command_add_binary_arg (struct command *com, const int len, const byte *srcbuf) |
adds a binary parameter to command returns 0 if ok otherwise errorcode More... | |
void | command_add_varg (struct command *com, const char *format, va_list args) |
adds a varg list of parameters to a command More... | |
byte | command_calc_checksum (struct command *com) |
int | command_decode_ascii (struct command *com, const byte *buf, int size, int version) |
int | command_decode_binary (struct command *com, const byte *buf, int size) |
int | command_encode_ascii (struct command *com, int bufsize, char *buf) |
encode a command to an ascii blob properly surrounded by '{' and '}' and escaped returns length if ok or <0 if error More... | |
const char * | command_get_name (int num) |
given a command number returns its name More... | |
char * | command_get_source_name (byte sourcedev) |
returns a human readable text identifying a source device More... | |
void | command_init (struct command *com) |
initialize a command structure with default values More... | |
struct command * | command_parse (const byte *buf, int size) |
void | command_print (struct command *com) |
prints a command in human readable format to serial console More... | |
void | command_start () |
initialization for command parser More... | |
void | error_com (void *com) |
void | flagstostr (char *buf, int flags) |
given a pointer to a buffer and command flags, it will fill the buffer with a human readable text describing the flags More... | |
const char * | get_arg (const struct command *com, int index) |
given an argument by index[0..n], will return a pointer to the bytearray (excluding the fieldtype) this is compatibility only, use get_arg_new() instead the argument may contain NUL bytes - use get_arg_size() to determine its length More... | |
int | get_arg_int_array (const struct command *com, const int index, int *result, const int arraysize) |
given a command and argument index, will attempt to parse the arg as array and return it array syntax is currently semi-comma delimited hex values returns the number of values parsed deprecated - use field arrays instead More... | |
const byte * | get_arg_new (const struct command *com, int index) |
given an argument by index[0..n], will returns a pointer to it. This will include the fieldnumber and fieldtype the argument may contain NUL bytes - use get_arg_size() to determine its length More... | |
int | get_arg_size (const struct command *com, int index) |
given an argument by index [0..n], will returns the size of the value in bytes. for a string/array it is the size of the array. for a uint8_t it is 1 and for uint16_t it is 2... More... | |
int | get_arg_size_inmem (const struct command *com, int index) |
given an argument by index [0..n], will returns the number in bytes this argument takes up in memory. for a string/array it is the fieldnum(1 byte) + fieldtype(1 byte) + arraylen(1 byte) + size of the array + nul-terminator(1byte) for a uint8_t it is 3 (fieldnum+fieldtype+1bytevalue) for a uint16_t it is 4 (fieldnum+fieldtype+2bytevalue) More... | |
int | is_command_valid (struct command *com) |
const char * | namedarg (struct command *com, const char *name) |
get a named arg (key-value pair) or NULL More... | |
int | namedarg_uint16 (struct command *com, const char *name, uint16_t *value) |
get a named arg (key-value pair), parsed as integer. result in "value". if return value == 0 , it was parsed, otherwise error code More... | |
int | namedarg_uint32 (struct command *com, const char *name, uint32_t *value) |
get a named arg (key-value pair), parsed as integer. result in "value". if return value == 0 , it was parsed, otherwise error code More... | |
Variables | |
const char *const | command_names [] |
char | rbuf [10] |
char | sbuf [10] |
char | tbuf [10] |
code to encode/decode commands to a serialized or in-ram format
encoding == a | b version == 1 sender = 8-bytes in hex recipient = 8-bytes in hex target = 8-bytes in hex index(sequence) == user chooses (will be resent in reply) 8-bit checksum flags == COMFLAGS_... command == one of command_names[] args == strings
Definition in file command-parser.c.