13 #ifndef COMMANDHANDLER_H_ 14 #define COMMANDHANDLER_H_ 18 #include "escapesequence.h" 19 #include "communication.h" 44 #define MONITOR_MAX_COMMAND_LENGTH (255U) 45 #define MONITOR_COMMAND_ARG_MAX_COUNT (3) 46 #define MONITOR_COMMAND_ARG_MAX_NUM_BITS (0x07) // 0b111 <-- warning: "binary constants are a GCC extension 48 #define MONITOR_HISTORY_MAX_COUNT (5) 51 #define MONITOR_DUMMY_STRING "____________________________________________\r\n" 54 #define MONITOR_SEND_WELCOME() \ 55 MONITOR_SendMessage( \ 57 "Welcome in Monitor program!\r\n" \ 58 "Version: " VERSION_DEFINE "\r\n" \ 59 "Date: " DATE_VERSION "\r\n" \ 60 "Time: "TIME_VERSION "\r\n" \ 61 "Used panel: " BOARD_NAME "\r\n" \ 62 "(c) Copyright, Vizi Gabor\r\n" \ 64 "Try \"help\" command for help!\r\n") 67 #define MONITOR_SEND_PROMT_NEW_LINE() \ 68 MONITOR_SendMessage("\r\n# ") 70 #define MONITOR_SEND_PROMT() \ 71 MONITOR_SendMessage("# ") 74 #define USART_SEND_DUMMYSTRING() MONITOR_SendMessage(MONITOR_DUMMY_STRING) 77 #define MONITOR_SEND_NEW_LINE() \ 78 MONITOR_SendMessage("\r\n") 83 CONFIG_USE_TERMINAL_ZOC
84 #if defined(CONFIG_USE_TERMINAL_ZOC) || defined(CONFIG_USE_TERMINAL_PUTTY) 85 #define USART_KEY_DELETE (0x08) 86 #define USART_KEY_BACKSPACE (0x7F) 88 #define USART_KEY_DELETE (0x7F) 89 #define USART_KEY_BACKSPACE (0x08) 93 #define USART_KEY_ENTER ('\r') 94 #define USART_KEY_SPACE (' ') 95 #define USART_KEY_ESCAPE ('\x1B') 96 #define USART_KEY_BELL ('\a') 100 #define USART_ESCAPESEQUENCE_1 ('\x1B') 101 #define USART_ESCAPESEQUENCE_2 ('[') 108 #define USART_SEND_KEY_BACKSPACE() \ 112 #define USART_SEND_KEY_DEL() \ 113 MONITOR_SendChar(127) 125 CommandResult_Unknown = 0,
127 CommandResult_Ok_SendSuccessful,
128 CommandResult_Error_WrongArgument1,
129 CommandResult_Error_WrongArgument2,
130 CommandResult_Error_TooFewArgument,
131 CommandResult_Error_WrongArgumentNum,
132 CommandResult_Error_TooManyArgument,
133 CommandResult_Error_CommandArgNumIsWrong,
134 CommandResult_Error_CommandNotFound,
135 CommandResult_Error_Unknown
140 typedef CommandResult_t ( *FunctionPointer )( uint32_t argc,
char** COMMAND_Arguments );
144 typedef uint8_t CommandID_t;
150 CommandArgument_0 = (1 << 0),
151 CommandArgument_1 = (1 << 1),
152 CommandArgument_2 = (1 << 2)
172 extern volatile char MONITOR_CommandActual[MONITOR_MAX_COMMAND_LENGTH];
173 extern volatile CommProtocol_t MONITOR_CommandSource;
175 extern const bool MONITOR_CommandReceiveEnable;
178 #ifdef CONFIG_USE_FREERTOS 179 extern xSemaphoreHandle DEBUG_USART_Rx_Semaphore;
180 extern xSemaphoreHandle DEBUG_USART_Tx_Semaphore;
189 void MONITOR_Init(
void);
190 void MONITOR_SendWelcome(
void);
192 void MONITOR_CheckCommand(
void);
194 void MONITOR_WriteCommandHelp(CommandID_t commandID);
195 void MONITOR_SendCls(
void);
197 void MONITOR_SendMessage(
const char *message);
198 void MONITOR_SendLine(
const char *message);
199 void MONITOR_SendChar(
char c);
200 void MONITOR_Printf(
const char *format, ...);
202 void MONITOR_PrintAllCommands(
void);
203 void MONITOR_SearchCommandAndPrintHelp(
const char *command);
const FunctionPointer * commandFunctionPointer
Function pointer (which called)
Definition: CommandHandler.h:160
const char * syntax
Command syntax.
Definition: CommandHandler.h:162
const CommandArgNum_t commandArgNum
Required command argument num.
Definition: CommandHandler.h:163
const char * description
Command description (for help)
Definition: CommandHandler.h:161
Command structure.
Definition: CommandHandler.h:157
const char * name
Name of command (which need type) [string].
Definition: CommandHandler.h:159