#include "common.h" #include "serial.h" #include "parser.h" /* * # Supported Commands * (Optional decimal point for numbers) * * - RUN * - STOP * - TEMP 20 * - DEWP 60.0 */ static int state; #define PARSE_IDLE 0 #define PARSE_CMD_RUN 1 #define PARSE_CMD_STOP 2 #define PARSE_CMD_SET_TEMP 3 #define PARSE_CMD_SET_DEWP 4 void CMD_Parse(char ch) { #if 0 switch (state) { case PARSE_IDLE: if (ch == 'R') state = PARSE_CMD_RUN; else if (ch == 'S') state = PARSE_CMD_STOP; else if (ch == 'T') state = PARSE_CMD_SET_TEMP; else if (ch == 'D') state = PARSE_CMD_SET_DEWP; } break; case PARSE_CMD_RUN: break; case PARSE_CMD_STOP: break; case PARSE_CMD_SET_TEMP: break; case PARSE_CMD_SET_DEWP: break; } #endif // Placeholder switch (state) { case 0: if (ch == 't') state = 1; break; case 1: if (ch == 'e') state = 2; else state = 0; break; case 2: if (ch == 's') state = 3; else state = 0; break; case 3: if (ch == 't') state = 4; else state = 0; break; case 4: if (ch == '\n') { // XXX: Just so the web server can show something... USART_Printf("[CORE] Parsed 'CMD_SET_TEMP' token.\r\n"); USART_Printf("[CORE] Parsed 'CMD_SET_DEWP' token.\r\n"); } state = 0; } }