diff options
-rw-r--r-- | robot/sercomm.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/robot/sercomm.c b/robot/sercomm.c index 44bf5f9..9e40b0e 100644 --- a/robot/sercomm.c +++ b/robot/sercomm.c @@ -19,6 +19,12 @@ void w2_sercomm_main() { #ifdef W2_SIM simprintfunc("w2_sercomm_main", ""); #endif + // read and parse data + while (serial_get_received_bytes() != g_w2_serial_buffer_index) { + w2_serial_parse(g_w2_serial_buffer[g_w2_serial_buffer_index]); + g_w2_serial_buffer_index = (g_w2_serial_buffer_index + 1) % W2_SERIAL_READ_BUFFER_SIZE; + } + // send data while (g_w2_sercomm_offset != g_w2_sercomm_index) { w2_s_bin *data = g_w2_sercomm_buffer[g_w2_sercomm_offset]; @@ -27,12 +33,6 @@ void w2_sercomm_main() { serial_send(data_cast, data->bytes); g_w2_sercomm_offset = (g_w2_sercomm_offset + 1) % W2_SERCOMM_BUFFER_SIZE; } - - // read and parse data - while (serial_get_received_bytes() != g_w2_serial_buffer_index) { - w2_serial_parse(g_w2_serial_buffer[g_w2_serial_buffer_index]); - 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) { |