flash based config testing

Dependencies:   mbed

Committer:
bwang
Date:
Tue Mar 07 08:06:39 2017 +0000
Revision:
3:82c00c8e2cb4
lot's more commands

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bwang 3:82c00c8e2cb4 1 #include "mbed.h"
bwang 3:82c00c8e2cb4 2 #include "CommandProcessor.h"
bwang 3:82c00c8e2cb4 3 #include "PreferenceWriter.h"
bwang 3:82c00c8e2cb4 4 #include "globals.h"
bwang 3:82c00c8e2cb4 5
bwang 3:82c00c8e2cb4 6 #include "config.h"
bwang 3:82c00c8e2cb4 7 #include "config_driving.h"
bwang 3:82c00c8e2cb4 8 #include "config_inverter.h"
bwang 3:82c00c8e2cb4 9 #include "config_logging.h"
bwang 3:82c00c8e2cb4 10 #include "config_loop.h"
bwang 3:82c00c8e2cb4 11 #include "config_motor.h"
bwang 3:82c00c8e2cb4 12 #include "config_pins.h"
bwang 3:82c00c8e2cb4 13 #include "config_table.h"
bwang 3:82c00c8e2cb4 14
bwang 3:82c00c8e2cb4 15 void cmd_setp(Serial *pc, char *buf) {
bwang 3:82c00c8e2cb4 16 if (BREMS_src == CMD_SRC_TERMINAL) user_cmd = atof(buf);
bwang 3:82c00c8e2cb4 17 }
bwang 3:82c00c8e2cb4 18
bwang 3:82c00c8e2cb4 19 void cmd_mode(Serial *pc, char *buf) {
bwang 3:82c00c8e2cb4 20 int n = str_to_mode(buf);
bwang 3:82c00c8e2cb4 21 if (n < 0) {
bwang 3:82c00c8e2cb4 22 pc->printf("%s\n", "Invalid Mode");
bwang 3:82c00c8e2cb4 23 return;
bwang 3:82c00c8e2cb4 24 }
bwang 3:82c00c8e2cb4 25 BREMS_mode = n;
bwang 3:82c00c8e2cb4 26 pc->printf("Set mode to %s\n", mode_to_str(n));
bwang 3:82c00c8e2cb4 27 }
bwang 3:82c00c8e2cb4 28
bwang 3:82c00c8e2cb4 29 void cmd_src(Serial *pc, char *buf) {
bwang 3:82c00c8e2cb4 30 int n = str_to_src(buf);
bwang 3:82c00c8e2cb4 31 if (n < 0) {
bwang 3:82c00c8e2cb4 32 pc->printf("%s\n", "Invalid Source");
bwang 3:82c00c8e2cb4 33 return;
bwang 3:82c00c8e2cb4 34 }
bwang 3:82c00c8e2cb4 35 BREMS_src = n;
bwang 3:82c00c8e2cb4 36 pc->printf("Set source to %s\n", src_to_str(n));
bwang 3:82c00c8e2cb4 37 }
bwang 3:82c00c8e2cb4 38
bwang 3:82c00c8e2cb4 39 void cmd_op(Serial *pc, char *buf) {
bwang 3:82c00c8e2cb4 40 int n = str_to_op(buf);
bwang 3:82c00c8e2cb4 41 if (n < 0) {
bwang 3:82c00c8e2cb4 42 pc->printf("%s\n", "Invalid Source");
bwang 3:82c00c8e2cb4 43 return;
bwang 3:82c00c8e2cb4 44 }
bwang 3:82c00c8e2cb4 45 BREMS_op = n;
bwang 3:82c00c8e2cb4 46 pc->printf("Set operation to %s\n", op_to_str(n));
bwang 3:82c00c8e2cb4 47 }
bwang 3:82c00c8e2cb4 48
bwang 3:82c00c8e2cb4 49 void cmd_exit(Serial *pc) {
bwang 3:82c00c8e2cb4 50 BREMS_mode = MODE_RUN;
bwang 3:82c00c8e2cb4 51 pc->printf("%s\n", "Run mode ON");
bwang 3:82c00c8e2cb4 52 }