FreeRTOS_CLI.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /*
  2. * FreeRTOS+CLI V1.0.1 (C) 2012 Real Time Engineers ltd.
  3. *
  4. * FreeRTOS+CLI is an add-on component to FreeRTOS. It is not, in itself, part
  5. * of the FreeRTOS kernel. FreeRTOS+CLI is licensed separately from FreeRTOS,
  6. * and uses a different license to FreeRTOS. FreeRTOS+CLI uses a dual license
  7. * model, information on which is provided below:
  8. *
  9. * - Open source licensing -
  10. * FreeRTOS+CLI is a free download and may be used, modified and distributed
  11. * without charge provided the user adheres to version two of the GNU General
  12. * Public license (GPL) and does not remove the copyright notice or this text.
  13. * The GPL V2 text is available on the gnu.org web site, and on the following
  14. * URL: http://www.FreeRTOS.org/gpl-2.0.txt
  15. *
  16. * - Commercial licensing -
  17. * Businesses and individuals who wish to incorporate FreeRTOS+CLI into
  18. * proprietary software for redistribution in any form must first obtain a
  19. * (very) low cost commercial license - and in-so-doing support the maintenance,
  20. * support and further development of the FreeRTOS+CLI product. Commercial
  21. * licenses can be obtained from http://shop.freertos.org and do not require any
  22. * source files to be changed.
  23. *
  24. * FreeRTOS+CLI is distributed in the hope that it will be useful. You cannot
  25. * use FreeRTOS+CLI unless you agree that you use the software 'as is'.
  26. * FreeRTOS+CLI is provided WITHOUT ANY WARRANTY; without even the implied
  27. * warranties of NON-INFRINGEMENT, MERCHANTABILITY or FITNESS FOR A PARTICULAR
  28. * PURPOSE. Real Time Engineers Ltd. disclaims all conditions and terms, be they
  29. * implied, expressed, or statutory.
  30. *
  31. * 1 tab == 4 spaces!
  32. *
  33. * http://www.FreeRTOS.org
  34. * http://www.FreeRTOS.org/FreeRTOS-Plus
  35. *
  36. */
  37. #ifndef COMMAND_INTERPRETER_H
  38. #define COMMAND_INTERPRETER_H
  39. #include "cli.h"
  40. /* The prototype to which callback functions used to process command line
  41. commands must comply. pcWriteBuffer is a buffer into which the output from
  42. executing the command can be written, xWriteBufferLen is the length, in bytes of
  43. the pcWriteBuffer buffer, and pcCommandString is the entire string as input by
  44. the user (from which parameters can be extracted).*/
  45. typedef portBASE_TYPE (*pdCOMMAND_LINE_CALLBACK)(cli_state_t *cli_state, int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t * pcCommandString );
  46. /* The structure that defines command line commands. A command line command
  47. should be defined by declaring a const structure of this type. */
  48. typedef struct xCOMMAND_LINE_INPUT
  49. {
  50. const int8_t * const pcCommand; /* The command that causes pxCommandInterpreter to be executed. For example "help". Must be all lower case. */
  51. const int8_t * 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". */
  52. const pdCOMMAND_LINE_CALLBACK pxCommandInterpreter; /* A pointer to the callback function that will return the output generated by the command. */
  53. int8_t cExpectedNumberOfParameters; /* Commands expect a fixed number of parameters, which may be zero. */
  54. } CLI_Command_Definition_t;
  55. /* For backward compatibility. */
  56. #define xCommandLineInput CLI_Command_Definition_t
  57. /*
  58. * Register the command passed in using the pxCommandToRegister parameter.
  59. * Registering a command adds the command to the list of commands that are
  60. * handled by the command interpreter. Once a command has been registered it
  61. * can be executed from the command line.
  62. */
  63. portBASE_TYPE FreeRTOS_CLIRegisterCommand( const CLI_Command_Definition_t * const pxCommandToRegister );
  64. /*
  65. * Runs the command interpreter for the command string "pcCommandInput". Any
  66. * output generated by running the command will be placed into pcWriteBuffer.
  67. * xWriteBufferLen must indicate the size, in bytes, of the buffer pointed to
  68. * by pcWriteBuffer.
  69. *
  70. * FreeRTOS_CLIProcessCommand should be called repeatedly until it returns pdFALSE.
  71. *
  72. * pcCmdIntProcessCommand is not reentrant. It must not be called from more
  73. * than one task - or at least - by more than one task at a time.
  74. */
  75. portBASE_TYPE FreeRTOS_CLIProcessCommand(cli_state_t *cli_state, const int8_t * const pcCommandInput, int8_t * pcWriteBuffer, size_t xWriteBufferLen );
  76. /*-----------------------------------------------------------*/
  77. /*
  78. * A buffer into which command outputs can be written is declared in the
  79. * main command interpreter, rather than in the command console implementation,
  80. * to allow application that provide access to the command console via multiple
  81. * interfaces to share a buffer, and therefore save RAM. Note, however, that
  82. * the command interpreter itself is not re-entrant, so only one command
  83. * console interface can be used at any one time. For that reason, no attempt
  84. * is made to provide any mutual exclusion mechanism on the output buffer.
  85. *
  86. * FreeRTOS_CLIGetOutputBuffer() returns the address of the output buffer.
  87. */
  88. int8_t *FreeRTOS_CLIGetOutputBuffer( void );
  89. /*
  90. * Return a pointer to the xParameterNumber'th word in pcCommandString.
  91. */
  92. const int8_t *FreeRTOS_CLIGetParameter( const int8_t *pcCommandString, unsigned portBASE_TYPE uxWantedParameter, unsigned portBASE_TYPE *pxParameterStringLength );
  93. /*
  94. * Return the number of parameters that follow the command name.
  95. */
  96. int8_t prvGetNumberOfParameters( const int8_t * pcCommandString );
  97. portBASE_TYPE FreeRTOS_CLICompleteCMDCommand( const int8_t * const pcCommandInput, int8_t * pcWriteBuffer);
  98. #endif /* COMMAND_INTERPRETER_H */