summaryrefslogtreecommitdiff
path: root/robot/sercomm.c
diff options
context:
space:
mode:
Diffstat (limited to 'robot/sercomm.c')
-rw-r--r--robot/sercomm.c22
1 files changed, 5 insertions, 17 deletions
diff --git a/robot/sercomm.c b/robot/sercomm.c
index c50dd15..efad449 100644
--- a/robot/sercomm.c
+++ b/robot/sercomm.c
@@ -99,7 +99,11 @@ void w2_cmd_ping_rx(w2_s_bin *data) { w2_sercomm_append_msg(data); }
void w2_cmd_mode_rx(w2_s_bin *data) {
W2_CAST_BIN(w2_s_cmd_mode_rx, data, req);
- w2_modes_swap(req->mode);
+ if (req->mode == W2_M_SCAL) {
+ w2_modes_call(req->mode);
+ } else {
+ w2_modes_swap(req->mode);
+ }
}
void w2_cmd_sped_rx(w2_s_bin *data) { return; }
@@ -135,22 +139,6 @@ void w2_cmd_sres_rx(w2_s_bin *data) {
void w2_cmd_mcfg_rx(w2_s_bin *data) { return; }
-void w2_cmd_sens_rx(w2_s_bin *data) {
- W2_CREATE_MSG_BIN(w2_s_cmd_sens_tx, res_msg, res_bin);
- res_msg->opcode = W2_CMD_SENS | W2_CMDDIR_TX;
- memcpy((uint8_t *)&res_msg->io, (uint8_t *)&g_w2_io, sizeof(w2_s_io_all));
-
- for (int i = 0; i < 5; i++) w2_bin_repl_hton16(&res_msg->io.qtr[i].range);
- w2_bin_repl_hton16(&res_msg->io.front_distance.detection);
- w2_bin_repl_hton16(&res_msg->io.side_distance.detection);
- w2_bin_repl_hton16(&res_msg->io.battery.charge_level);
- w2_bin_repl_hton16((uint16_t *)&res_msg->io.motor_left.speed);
- w2_bin_repl_hton16((uint16_t *)&res_msg->io.motor_right.speed);
-
- w2_sercomm_append_msg(res_bin);
- free(res_bin);
-}
-
void w2_cmd_info_rx(w2_s_bin *data) {
W2_CREATE_MSG_BIN(w2_s_cmd_info_tx, res_msg, res_bin);
res_msg->opcode = W2_CMD_INFO | W2_CMDDIR_TX;