Bayley Wang
/
flash_configuration
flash based config testing
Diff: CommandProcessor/cmd_mode.cpp
- Revision:
- 3:82c00c8e2cb4
diff -r cfc39b0843ae -r 82c00c8e2cb4 CommandProcessor/cmd_mode.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/CommandProcessor/cmd_mode.cpp Tue Mar 07 08:06:39 2017 +0000 @@ -0,0 +1,52 @@ +#include "mbed.h" +#include "CommandProcessor.h" +#include "PreferenceWriter.h" +#include "globals.h" + +#include "config.h" +#include "config_driving.h" +#include "config_inverter.h" +#include "config_logging.h" +#include "config_loop.h" +#include "config_motor.h" +#include "config_pins.h" +#include "config_table.h" + +void cmd_setp(Serial *pc, char *buf) { + if (BREMS_src == CMD_SRC_TERMINAL) user_cmd = atof(buf); +} + +void cmd_mode(Serial *pc, char *buf) { + int n = str_to_mode(buf); + if (n < 0) { + pc->printf("%s\n", "Invalid Mode"); + return; + } + BREMS_mode = n; + pc->printf("Set mode to %s\n", mode_to_str(n)); +} + +void cmd_src(Serial *pc, char *buf) { + int n = str_to_src(buf); + if (n < 0) { + pc->printf("%s\n", "Invalid Source"); + return; + } + BREMS_src = n; + pc->printf("Set source to %s\n", src_to_str(n)); +} + +void cmd_op(Serial *pc, char *buf) { + int n = str_to_op(buf); + if (n < 0) { + pc->printf("%s\n", "Invalid Source"); + return; + } + BREMS_op = n; + pc->printf("Set operation to %s\n", op_to_str(n)); +} + +void cmd_exit(Serial *pc) { + BREMS_mode = MODE_RUN; + pc->printf("%s\n", "Run mode ON"); +} \ No newline at end of file