Projektarbeit Line Following Robot bei Prof. Chowanetz im WS22/23
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

vcos_cmd.h 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*
  2. Copyright (c) 2012, Broadcom Europe Ltd
  3. All rights reserved.
  4. Redistribution and use in source and binary forms, with or without
  5. modification, are permitted provided that the following conditions are met:
  6. * Redistributions of source code must retain the above copyright
  7. notice, this list of conditions and the following disclaimer.
  8. * Redistributions in binary form must reproduce the above copyright
  9. notice, this list of conditions and the following disclaimer in the
  10. documentation and/or other materials provided with the distribution.
  11. * Neither the name of the copyright holder nor the
  12. names of its contributors may be used to endorse or promote products
  13. derived from this software without specific prior written permission.
  14. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  15. ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  16. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  17. DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
  18. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  19. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  20. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  21. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  22. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  23. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24. */
  25. #if !defined( VCOS_CMD_H )
  26. #define VCOS_CMD_H
  27. /* ---- Include Files ----------------------------------------------------- */
  28. #ifndef VCOS_H
  29. #include "vcos.h"
  30. #endif
  31. #include "vcos_stdint.h"
  32. /* ---- Constants and Types ---------------------------------------------- */
  33. struct VCOS_CMD_S;
  34. typedef struct VCOS_CMD_S VCOS_CMD_T;
  35. typedef struct
  36. {
  37. int argc; /* Number of arguments (includes the command/sub-command) */
  38. char **argv; /* Array of arguments */
  39. char **argv_orig; /* Original array of arguments */
  40. VCOS_CMD_T *cmd_entry;
  41. VCOS_CMD_T *cmd_parent_entry;
  42. int use_log; /* Output being logged? */
  43. size_t result_size; /* Size of result buffer. */
  44. char *result_ptr; /* Next place to put output. */
  45. char *result_buf; /* Start of the buffer. */
  46. } VCOS_CMD_PARAM_T;
  47. typedef VCOS_STATUS_T (*VCOS_CMD_FUNC_T)( VCOS_CMD_PARAM_T *param );
  48. struct VCOS_CMD_S
  49. {
  50. const char *name;
  51. const char *args;
  52. VCOS_CMD_FUNC_T cmd_fn;
  53. VCOS_CMD_T *sub_cmd_entry;
  54. const char *descr;
  55. };
  56. /* ---- Variable Externs ------------------------------------------------- */
  57. /* ---- Function Prototypes ---------------------------------------------- */
  58. /*
  59. * Common printing routine for generating command output.
  60. */
  61. VCOSPRE_ void VCOSPOST_ vcos_cmd_error( VCOS_CMD_PARAM_T *param, const char *fmt, ... ) VCOS_FORMAT_ATTR_(printf, 2, 3);
  62. VCOSPRE_ void VCOSPOST_ vcos_cmd_printf( VCOS_CMD_PARAM_T *param, const char *fmt, ... ) VCOS_FORMAT_ATTR_(printf, 2, 3);
  63. VCOSPRE_ void VCOSPOST_ vcos_cmd_vprintf( VCOS_CMD_PARAM_T *param, const char *fmt, va_list args ) VCOS_FORMAT_ATTR_(printf, 2, 0);
  64. /*
  65. * Cause vcos_cmd_error, printf and vprintf to always log to the provided
  66. * category. When this call is made, the results buffer passed into
  67. * vcos_cmd_execute is used as a line buffer and does not need to be
  68. * output by the caller.
  69. */
  70. VCOSPRE_ void VCOSPOST_ vcos_cmd_always_log_output( VCOS_LOG_CAT_T *log_category );
  71. /*
  72. * Prints command usage for the current command.
  73. */
  74. VCOSPRE_ void VCOSPOST_ vcos_cmd_usage( VCOS_CMD_PARAM_T *param );
  75. /*
  76. * Register commands to be processed
  77. */
  78. VCOSPRE_ VCOS_STATUS_T VCOSPOST_ vcos_cmd_register( VCOS_CMD_T *cmd_entry );
  79. /*
  80. * Registers multiple commands to be processed. The array should
  81. * be terminated by an entry with all zeros.
  82. */
  83. VCOSPRE_ VCOS_STATUS_T VCOSPOST_ vcos_cmd_register_multiple( VCOS_CMD_T *cmd_entry );
  84. /*
  85. * Executes a command based on a command line.
  86. */
  87. VCOSPRE_ VCOS_STATUS_T VCOSPOST_ vcos_cmd_execute( int argc, char **argv, size_t result_size, char *result_buf );
  88. /*
  89. * Shut down the command system and free all allocated data.
  90. * Do not call any other command functions after this.
  91. */
  92. VCOSPRE_ void VCOSPOST_ vcos_cmd_shutdown( void );
  93. #endif /* VCOS_CMD_H */