Command interpreter code updated to pass the command string into command hander functions.

This commit is contained in:
Richard Barry 2011-12-08 10:46:16 +00:00
parent 255dd683d2
commit e7a1222c5f
2 changed files with 130 additions and 15 deletions

View file

@ -1,6 +1,6 @@
/*
FreeRTOS V7.0.2 - Copyright (C) 2011 Real Time Engineers Ltd.
***************************************************************************
* *
@ -55,11 +55,11 @@
#define COMMAND_INTERPRETER_H
/* The prototype to which callback functions used to process command line
commands must comply. This type will change when commands with parameters
are included. pcWriteBuffer is a buffer into which the output from executing
the command can be written, xWriteBufferLen is the length, in bytes, of the
pcWriteBuffer buffer. */
typedef portBASE_TYPE (*pdCOMMAND_LINE_CALLBACK)( signed char *pcWriteBuffer, size_t xWriteBufferLen );
commands must comply. pcWriteBuffer is a buffer into which the output from
executing the command can be written, xWriteBufferLen is the length, in bytes of
the pcWriteBuffer buffer, and pcCommandString is the entire string as input by
the user (from which parameters can be extracted.*/
typedef portBASE_TYPE (*pdCOMMAND_LINE_CALLBACK)( signed char *pcWriteBuffer, size_t xWriteBufferLen, const signed char * pcCommandString );
/* The structure that defines command line commands. A command line command
should be defined by declaring a const structure of this type. */
@ -68,6 +68,7 @@ typedef struct xCOMMAND_LINE_INPUT
const signed char * const pcCommand; /* The command that causes pxCommandInterpreter to be executed. For example "help". Must be all lower case. */
const signed char * const pcHelpString; /* String that describes how to use the command. Should start with the command itself, and end with "\r\n". For example "help: Returns a list of all the commands\r\n". */
const pdCOMMAND_LINE_CALLBACK pxCommandInterpreter; /* A pointer to the callback function that will return the output generated by the command. */
signed char cExpectedNumberOfParameters; /* Commands expect a fixed number of parameters, which may be zero. */
} xCommandLineInput;
/*
@ -110,6 +111,11 @@ portBASE_TYPE xCmdIntProcessCommand( const signed char * const pcCommandInput, s
signed char *pcCmdIntGetOutputBuffer( void );
unsigned portBASE_TYPE uxCmdIntGetOutputBufferSizeBytes( void );
/*
* Return a pointer to the xParameterNumber'th word in pcCommandString.
*/
const signed char *pcCmdIntGetParameter( const signed char *pcCommandString, unsigned portBASE_TYPE uxWantedParameter, portBASE_TYPE *pxParameterStringLength );
#endif /* COMMAND_INTERPRETER_H */