summaryrefslogtreecommitdiff
path: root/robot/sercomm.c
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2022-05-23 13:40:17 +0200
committerlonkaars <loek@pipeframe.xyz>2022-05-23 13:40:17 +0200
commit92c394b44cc846ba044c2862b4f08eadc2160805 (patch)
treed065e8c58c7da82ec00ec5fe6ecbd091a3516442 /robot/sercomm.c
parent33540c7855d52343eb943d3a5144d6b736c234da (diff)
WIP serial receive
Diffstat (limited to 'robot/sercomm.c')
-rw-r--r--robot/sercomm.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/robot/sercomm.c b/robot/sercomm.c
index 723a231..d7dc7f1 100644
--- a/robot/sercomm.c
+++ b/robot/sercomm.c
@@ -5,11 +5,14 @@
#include "orangutan_shim.h"
#include "sercomm.h"
-w2_s_bin *g_w2_sercomm_buffer[W2_SERCOMM_BUFFER_SIZE] = {};
+w2_s_bin *g_w2_sercomm_buffer[W2_SERCOMM_BUFFER_SIZE] = {0};
uint8_t g_w2_sercomm_index = 0;
uint8_t g_w2_sercomm_offset = 0;
uint8_t g_w2_sercomm_buffer_full = 0;
+char g_w2_serial_buffer[W2_SERIAL_READ_BUFFER_SIZE] = {0};
+uint8_t g_w2_serial_buffer_index = 0;
+
void w2_sercomm_main() {
#ifdef W2_SIM
simprintfunc("w2_sercomm_main", "");
@@ -22,6 +25,14 @@ void w2_sercomm_main() {
serial_send(data_cast, data->bytes);
g_w2_sercomm_offset = (g_w2_sercomm_offset + 1) % W2_SERCOMM_BUFFER_SIZE;
}
+
+ while(serial_get_received_bytes() != g_w2_serial_buffer_index) {
+ uint8_t byte = g_w2_serial_buffer[g_w2_serial_buffer_index];
+#ifdef W2_SIM
+ simprintf("serial byte: %02x\n", byte);
+#endif
+ g_w2_serial_buffer_index = (g_w2_serial_buffer_index + 1) % W2_SERIAL_READ_BUFFER_SIZE;
+ }
}
void w2_sercomm_append_msg(w2_s_bin *data) {