Add RUN/STOP parser state

This commit is contained in:
2024-08-27 22:11:53 +02:00
parent 0836f709c3
commit 8e45de2b82

View File

@@ -49,9 +49,17 @@ void CMD_Parse(char ch)
// Placeholder
switch (state) {
case 0:
if (ch == 'T')
if (ch == 'T') // TEMP
state = 1;
if (ch == 'D') // DEWP
state = 5;
if (ch == 'R') // RUN
state = 9;
if (ch == 'S') // STOP
state = 12;
break;
// Parse 'TEMP'
case 1:
if (ch == 'E')
state = 2;
@@ -74,8 +82,85 @@ void CMD_Parse(char ch)
if (ch == ' ') {
// XXX: Just so the web server can show something...
USART_Printf("[CORE] Parsed 'CMD_SET_TEMP' token.\r\n");
}
// TODO: Parse float value
state = 0;
break;
// Parse 'DEWP'
case 5:
if (ch == 'E')
state = 6;
else
state = 0;
break;
case 6:
if (ch == 'W')
state = 7;
else
state = 0;
break;
case 7:
if (ch == 'P')
state = 8;
else
state = 0;
break;
case 8:
if (ch == ' ') {
// XXX: Just so the web server can show something...
USART_Printf("[CORE] Parsed 'CMD_SET_DEWP' token.\r\n");
}
// TODO: Parse float value
state = 0;
break;
// Parse 'RUN'
case 9:
if (ch == 'U')
state = 10;
else
state = 0;
break;
case 10:
if (ch == 'N')
state = 11;
else
state = 0;
break;
case 11:
if (ch == '\n') {
// XXX: Just so the web server can show something...
USART_Printf("[CORE] Parsed 'CMD_RUN' token.\r\n");
}
state = 0;
break;
// Parse 'STOP'
case 12:
if (ch == 'T')
state = 13;
else
state = 0;
break;
case 13:
if (ch == 'O')
state = 14;
else
state = 0;
break;
case 14:
if (ch == 'P')
state = 15;
else
state = 0;
break;
case 15:
if (ch == '\n') {
// XXX: Just so the web server can show something...
USART_Printf("[CORE] Parsed 'CMD_STOP' token.\r\n");
}
state = 0;
break;
}
}