summaryrefslogtreecommitdiffstats
path: root/boiler-monster/stm32/app/cmd.c
diff options
context:
space:
mode:
Diffstat (limited to 'boiler-monster/stm32/app/cmd.c')
-rw-r--r--boiler-monster/stm32/app/cmd.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/boiler-monster/stm32/app/cmd.c b/boiler-monster/stm32/app/cmd.c
new file mode 100644
index 0000000..7e1975a
--- /dev/null
+++ b/boiler-monster/stm32/app/cmd.c
@@ -0,0 +1,55 @@
+#include "project.h"
+
+
+static void cmd_dispatch (char *cmd)
+{
+
+ printf ("Q received cmd %s\r\n", cmd);
+
+ if (!strncmp (cmd, "CH=", 3)) {
+ ot_override_ch = atoi (cmd + 3);
+ printf ("Q CH override set to %d\r\n", ot_override_ch);
+ }
+
+
+ if (!strncmp (cmd, "DHW=", 4)) {
+ ot_override_dhw = atoi (cmd + 4);
+ printf ("Q DHW override set to %d\r\n", ot_override_dhw);
+ }
+
+ if (!strcmp (cmd, "PIC")) {
+ ot_override_dhw = atoi (cmd + 4);
+ printf ("Q Entering PIC mode, reset to leave\r\n");
+ pic_passthru();
+ }
+
+}
+
+
+void cmd_usart_dispatch (void)
+{
+ static char cmd[16];
+ static unsigned cmd_ptr;
+
+ uint8_t c;
+
+ if (ring_read_byte (&rx1_ring, &c))
+ return;
+
+
+ if ((c == '\n') || (c == '\r')) {
+ if (cmd_ptr)
+ cmd_dispatch (cmd);
+
+ cmd_ptr = 0;
+ return;
+ }
+
+
+ if (cmd_ptr < (sizeof (cmd) - 1)) {
+ cmd[cmd_ptr++] = c;
+ cmd[cmd_ptr] = 0;
+ }
+}
+
+