summaryrefslogtreecommitdiffstats
path: root/boiler-monster/stm32/app/cmd.c
diff options
context:
space:
mode:
authorfishsoupisgood <github@madingley.org>2020-09-09 11:53:37 +0100
committerfishsoupisgood <github@madingley.org>2020-09-09 11:53:37 +0100
commit9d87c925a9eaa4fc256be3173c14a20d1469472d (patch)
tree50d63f87a47a0eac3f5b8058850184bcd4e6ee95 /boiler-monster/stm32/app/cmd.c
parentdafd8cf2fdcdd637cc06f760d318cf8391b1a294 (diff)
downloadheating-9d87c925a9eaa4fc256be3173c14a20d1469472d.tar.gz
heating-9d87c925a9eaa4fc256be3173c14a20d1469472d.tar.bz2
heating-9d87c925a9eaa4fc256be3173c14a20d1469472d.zip
everything, mostly, working
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;
+ }
+}
+
+