#include "common.h" #include "serial.h" #include "parser.h" bool running; int main(void) { char ch; unsigned long i = 1; USART_Init(); Enable(); for (;;) { // Process rx ring buffer while ((ch = USART_GetChar())) { CMD_Parse(ch); } Sleep(3000); if (running) { // TODO: Main program if (i >= 99999) i = 1; Info("Fetching sensors #%05lu...", i++); } } return 0; } void Enable(void) { Info("Parsed 'CMD_RUN' token."); if (running == true) { Error("Already running."); return; } running = true; SetStateFlag(running); Info("Program started."); } void Disable(void) { Info("Parsed 'CMD_STOP' token."); if (running == false) { Error("Already stopped."); return; } running = false; SetStateFlag(running); Info("Program stopped."); } void SetTemp(long val) { Info("Parsed 'CMD_SET_TEMP', VAL='%ld'.", val); if (val < 10) { Error("Given temperature is too low."); return; } else if (val > 40) { Error("Given temperature is too high."); return; } } void SetDewp(long val) { Info("Parsed 'CMD_SET_DEWP', VAL='%ld'.", val); if (val < 10) { Error("Given dew point is too low."); return; } else if (val > 80) { Error("Given dew point is too high."); return; } }