PixelKey
NeoPixel USB Key
Loading...
Searching...
No Matches
Command Parser Internals

Functions

static char * trim (char *str)
 Removes white-space from an input string; replaces trailing white-space with NULL character. More...
 
static void lower (char *str)
 Converts a string to lower-case. More...
 
static pixelkey_error_t parse_no_args (cmd_type_t type, char *arg_ctx, cmd_t *p_cmd)
 Parses a command that takes no arguments. More...
 
static pixelkey_error_t parse_config_get (char *arg_ctx, cmd_t *p_cmd)
 Parses config-get command arguments. More...
 
static pixelkey_error_t parse_config_set (char *arg_ctx, cmd_t *p_cmd)
 Parses config-set command arguments. More...
 
static pixelkey_error_t parse_time_set (char *arg_ctx, cmd_t *p_cmd)
 Parses time-set command arguments. More...
 
static pixelkey_error_t parse_keyframe (char *cmd_tok, cmd_t *p_cmd)
 Parses a keyframe command. More...
 
pixelkey_error_t pixelkey_command_parse (char *command_str, cmd_list_t **p_cmd_list)
 Parses a command string. More...
 
static uint8_t char_to_u8 (char c)
 Converts a character to an integer. More...
 
void pixelkey_cmd_free (cmd_t *p_cmd)
 
void pixelkey_cmd_list_free (cmd_list_t *p_cmd_list)
 

Detailed Description

Function Documentation

◆ char_to_u8()

static uint8_t char_to_u8 ( char  c)
static

Converts a character to an integer.

Parameters
cCharacter to convert.
Returns
The integer value of c.
Return values
UINT8_MAXOn non-digit character.

◆ lower()

static void lower ( char *  str)
static

Converts a string to lower-case.

Parameters
[in,out]strString to transform.

◆ parse_config_get()

static pixelkey_error_t parse_config_get ( char *  arg_ctx,
cmd_t p_cmd 
)
static

Parses config-get command arguments.

Parameters
[in]arg_ctxArgument tokenizer context.
[in,out]p_cmdPointer to the command structure to populate.
Return values
PIXELKEY_ERROR_NOT_ENOUGH_ARGUMENTSConfiguration key was not provided.
PIXELKEY_ERROR_INVALID_ARGUMENTConfiguration key is invalid or too long.
PIXELKEY_ERROR_TOO_MANY_ARGUMENTSAdditional, unexpected arguments were specified.
PIXELKEY_ERROR_OUT_OF_MEMORYFailed to malloc argument structure.
PIXELKEY_ERROR_NONEParsing was successful.

◆ parse_config_set()

static pixelkey_error_t parse_config_set ( char *  arg_ctx,
cmd_t p_cmd 
)
static

Parses config-set command arguments.

Parameters
[in]arg_ctxArgument tokenizer context.
[in,out]p_cmdPointer to the command structure to populate.
Return values
PIXELKEY_ERROR_NOT_ENOUGH_ARGUMENTSConfiguration key or value was not provided.
PIXELKEY_ERROR_INVALID_ARGUMENTConfiguration key or value is invalid or too long.
PIXELKEY_ERROR_TOO_MANY_ARGUMENTSAdditional, unexpected arguments were specified.
PIXELKEY_ERROR_OUT_OF_MEMORYFailed to malloc argument structure.
PIXELKEY_ERROR_NONEParsing was successful.

◆ parse_keyframe()

static pixelkey_error_t parse_keyframe ( char *  cmd_tok,
cmd_t p_cmd 
)
static

Parses a keyframe command.

Parameters
[in]cmd_tokCommand token representing the keyframe.
[in,out]p_cmdPointer to the command structure to populate.
Return values
PIXELKEY_ERROR_NOT_ENOUGH_ARGUMENTSRequired keyframe arguments were not provided.
PIXELKEY_ERROR_INVALID_ARGUMENTA keyframe argument was invalid or too long.
PIXELKEY_ERROR_TOO_MANY_ARGUMENTSAdditional, unexpected arguments were specified.
PIXELKEY_ERROR_OUT_OF_MEMORYFailed to malloc argument structure.
PIXELKEY_ERROR_NONEParsing was successful.

◆ parse_no_args()

static pixelkey_error_t parse_no_args ( cmd_type_t  type,
char *  arg_ctx,
cmd_t p_cmd 
)
static

Parses a command that takes no arguments.

Parameters
typeThe command type to return.
[in]arg_ctxArgument tokenizer context.
[in,out]p_cmdPointer to the command structure to populate.
Return values
PIXELKEY_ERROR_TOO_MANY_ARGUMENTSAdditional arguments were specified; expects no arguments.
PIXELKEY_ERROR_NONEParsing was successful.

◆ parse_time_set()

static pixelkey_error_t parse_time_set ( char *  arg_ctx,
cmd_t p_cmd 
)
static

Parses time-set command arguments.

Parameters
[in]arg_ctxArgument tokenizer context.
[in,out]p_cmdPointer to the command structure to populate.
Return values
PIXELKEY_ERROR_NOT_ENOUGH_ARGUMENTSTime string was not provided.
PIXELKEY_ERROR_INVALID_ARGUMENTTime string is invalid or too long.
PIXELKEY_ERROR_TOO_MANY_ARGUMENTSAdditional, unexpected arguments were specified.
PIXELKEY_ERROR_OUT_OF_MEMORYFailed to malloc argument structure.
PIXELKEY_ERROR_NONEParsing was successful.

◆ pixelkey_command_parse()

pixelkey_error_t pixelkey_command_parse ( char *  command_str,
cmd_list_t **  p_cmd_list 
)

Parses a command string.

Parameters
[in]command_strPointer to the command string to parse.
[out]p_cmd_listPointer to store the command list.

◆ trim()

static char * trim ( char *  str)
static

Removes white-space from an input string; replaces trailing white-space with NULL character.

Parameters
[in]strString to trim.
Returns
Pointer to start of the first non-white-space character in str.