Change command interpreter semantics.

This commit is contained in:
Richard Barry 2011-08-03 09:35:21 +00:00
parent 59fbe1da22
commit 49f726cf25
2 changed files with 45 additions and 43 deletions

View file

@ -56,15 +56,17 @@
/* The prototype to which callback functions used to process command line
commands must comply. This type will change when commands with parameters
are included. */
typedef const signed char * (*pdCOMMAND_LINE_CALLBACK)( void );
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 );
/* The structure that defines command line commands. A command line command
should be defined by declaring a const structure of this type. */
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 exxample "help: Returns a list of all the commands\r\n". */
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. */
} xCommandLineInput;
@ -77,18 +79,17 @@ typedef struct xCOMMAND_LINE_INPUT
portBASE_TYPE xCmdIntRegisterCommand( const xCommandLineInput * const pxCommandToRegister );
/*
* Runns the command interpreter for the command string "pcCommandInput". If
* pcCommandInput is valid (the command has been registered) a string will be
* returned, and pcCmdIntProcessCommand must then be called repeatedly until
* NULL is returned. If pcCommand pcCommandInput is not valid (the command is
* not recognised as a registered command) then an error message will be
* returned - and again pcCmdIntProcessCommand() must be called repeatedly
* until NULL is returned.
* Runs the command interpreter for the command string "pcCommandInput". Any
* output generated by running the command will be placed into pcWriteBuffer.
* xWriteBufferLen must indicate the size, in bytes, of the buffer pointed to
* by pcWriteBuffer.
*
* xCmdIntProcessCommand should be called repeatedly until it returns pdFALSE.
*
* pcCmdIntProcessCommand is not reentrant. It must not be called from more
* than one task - or at least - by more than one task at a time.
*/
const signed char *pcCmdIntProcessCommand( const signed char * const pcCommandInput );
portBASE_TYPE xCmdIntProcessCommand( const signed char * const pcCommandInput, signed char * pcWriteBuffer, size_t xWriteBufferLen );
#endif /* COMMAND_INTERPRETER_H */