Bayley Wang
/
flash_configuration
flash based config testing
Diff: CommandProcessor/CommandProcessor.cpp
- Revision:
- 2:cfc39b0843ae
- Parent:
- 1:df6bbacb7bb9
- Child:
- 3:82c00c8e2cb4
diff -r df6bbacb7bb9 -r cfc39b0843ae CommandProcessor/CommandProcessor.cpp --- a/CommandProcessor/CommandProcessor.cpp Thu Mar 02 07:04:47 2017 +0000 +++ b/CommandProcessor/CommandProcessor.cpp Thu Mar 02 07:36:56 2017 +0000 @@ -1,6 +1,7 @@ #include "mbed.h" #include "CommandProcessor.h" #include "PreferenceWriter.h" +#include "globals.h" #include "config.h" #include "config_driving.h" @@ -123,10 +124,28 @@ pref->flush(); } +void cmd_cfg(Serial *pc) { + mode = MODE_CFG; + pc->printf("%s\n", "Config mode ON"); +} + +void cmd_exit(Serial *pc) { + mode = MODE_RUN; + pc->printf("%s\n", "Run mode ON"); +} + void processCmd(Serial *pc, PreferenceWriter *pref, char *buf) { char *tokens[10]; int len = tokenize(buf, tokens, 10); + if (mode == MODE_RUN) { + if (len == 1 && strcmp(tokens[0], "cfg") == 0) { + cmd_cfg(pc); + } else { + return; + } + } + switch (len) { case 1: if (strcmp(tokens[0], "ls") == 0) cmd_ls(pc); @@ -134,6 +153,7 @@ if (strcmp(tokens[0], "reload") == 0) cmd_reload(pc, pref); if (strcmp(tokens[0], "load") == 0) cmd_reload(pc, pref); if (strcmp(tokens[0], "flush") == 0) cmd_flush(pc, pref); + if (strcmp(tokens[0], "exit") == 0) cmd_exit(pc); break; case 2: if (strcmp(tokens[0], "ls") == 0) cmd_ls2(pc, tokens[1]);