diff options
Diffstat (limited to 'robot/sim.c')
-rw-r--r-- | robot/sim.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/robot/sim.c b/robot/sim.c index 8af672e..57e0ef5 100644 --- a/robot/sim.c +++ b/robot/sim.c @@ -7,11 +7,34 @@ #include "sim.h" #include "../shared/consts.h" +#include "../shared/protocol.h" #include "sercomm.h" struct timespec reference_time; // NOLINT bool g_w2_sim_headless = false; +static const char* const W2_CMD_NAMES[] = { + "PING", + "EXPT", + "MODE", + "SPED", + "DIRC", + "CORD", + "BOMD", + "SRES", + "MCFG", + "SENS", + "INFO", + "DISP", + "PLAY", + "CLED", +}; + +static const char* const W2_CMD_DIRECTIONS[] = { + "RX", + "TX", +}; + void time_reset() { simprintfunc("time_reset", ""); clock_gettime(CLOCK_MONOTONIC, &reference_time); @@ -107,3 +130,11 @@ void w2_sim_cycle_begin() { return; } +void w2_sim_print_serial(w2_s_bin *data) { + if (g_w2_sim_headless) return; + simprintf(COL_GRN "[%s_%s]" COL_RST, W2_CMD_NAMES[data->data[0] >> 1], W2_CMD_DIRECTIONS[data->data[0] & W2_CMD_DIRECTION_MASK]); + for (int i = 0; i < data->bytes; i++) + printf(" %02x", data->data[i]); + printf("\n"); +} + |