diff options
author | lonkaars <loek@pipeframe.xyz> | 2022-05-25 19:02:23 +0200 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2022-05-25 19:02:23 +0200 |
commit | 87900d6787f8e0af8d37cc313c4e0510ef0b1bf8 (patch) | |
tree | 3f5858a1d7b7291c8415d3d828321f3e20c503ad /shared/serial_parse.c | |
parent | afa10fa556585d965e3a7d46c2fd5436d29cf3c6 (diff) |
serial receive working with empty handlers
Diffstat (limited to 'shared/serial_parse.c')
-rw-r--r-- | shared/serial_parse.c | 17 |
1 files changed, 3 insertions, 14 deletions
diff --git a/shared/serial_parse.c b/shared/serial_parse.c index 0cda2d8..0ebe377 100644 --- a/shared/serial_parse.c +++ b/shared/serial_parse.c @@ -1,18 +1,7 @@ #include <stdbool.h> -#include "bin.h" #include "consts.h" #include "serial_parse.h" -#ifdef W2_SIM -#include "../robot/orangutan_shim.h" -#endif - -void w2_serial_handle(w2_s_bin *code) { -#ifdef W2_SIM - serial_send((char *)code->data, code->bytes); - // simprintf("yeah: %02x\n", code); -#endif -} void w2_serial_parse(uint8_t byte) { static uint8_t current_message[W2_SERIAL_READ_BUFFER_SIZE] = {0}; @@ -38,10 +27,10 @@ void w2_serial_parse(uint8_t byte) { if (!listening) return; current_message[current_message_index++] = byte; + complete_message_length = w2_scmd_length(current_message, current_message_index); + if (current_message_index == complete_message_length) { - w2_s_bin *copy = w2_bin_s_alloc(current_message_index, current_message); - w2_serial_handle(copy); - free(copy); + w2_scmd_handler(current_message, current_message_index); memset(¤t_message, 0, W2_SERIAL_READ_BUFFER_SIZE); current_message_index = 0; |