aboutsummaryrefslogtreecommitdiff
path: root/client/serial.c
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2022-05-29 22:34:19 +0200
committerlonkaars <loek@pipeframe.xyz>2022-05-29 22:34:19 +0200
commit87d8b0ceb349e101b693cf43336a98647f4b92dc (patch)
tree6089767f348807710d59c326e6e062b904e85668 /client/serial.c
parent2c591a5e97ad9f354844d3d2b04a4190f9c6fc1f (diff)
garbage ui functions + janky status bar
Diffstat (limited to 'client/serial.c')
-rw-r--r--client/serial.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/client/serial.c b/client/serial.c
index 0d0bca7..9efb966 100644
--- a/client/serial.c
+++ b/client/serial.c
@@ -1,3 +1,5 @@
+#include <memory.h>
+
#include "serial.h"
#include "../shared/protocol.h"
#include "../shared/serial_parse.h"
@@ -10,16 +12,25 @@ void w2_serial_main() {
}
void w2_cmd_ping_tx(w2_s_bin *data) {
- // TODO: check ping id
+ W2_CAST_BIN(w2_s_cmd_ping_tx, data, cast);
+
+ if (g_w2_state.ping_received) return;
+ if (g_w2_state.ping_id != cast->id) return;
g_w2_state.ping = w2_timer_end(W2_TIMER_PING);
+ g_w2_state.ping_received = true;
+
printf("ping measured, %ims\n", g_w2_state.ping);
}
+
void w2_cmd_expt_tx(w2_s_bin *data) { printf("w2_cmd_expt_tx()\n"); }
void w2_cmd_mode_tx(w2_s_bin *data) { printf("w2_cmd_mode_tx()\n"); }
void w2_cmd_cord_tx(w2_s_bin *data) { printf("w2_cmd_cord_tx()\n"); }
void w2_cmd_bomd_tx(w2_s_bin *data) { printf("w2_cmd_bomd_tx()\n"); }
void w2_cmd_sens_tx(w2_s_bin *data) { printf("w2_cmd_sens_tx()\n"); }
-void w2_cmd_info_tx(w2_s_bin *data) { printf("w2_cmd_info_tx()\n"); }
+
+void w2_cmd_info_tx(w2_s_bin *data) {
+ memcpy(&g_w2_state.info, data->data, sizeof(w2_s_cmd_info_tx));
+}
void w2_cmd_ping_rx(w2_s_bin *data) { return; }
void w2_cmd_mode_rx(w2_s_bin *data) { return; }