diff options
author | lonkaars <loek@pipeframe.xyz> | 2022-05-17 22:37:09 +0200 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2022-05-17 22:37:09 +0200 |
commit | 154df68cb2a74a3b22456e8ec5af3af54352a41f (patch) | |
tree | f9d2c83b30322d81691ae1a013813add6ec6b99e /robot/sercomm.h | |
parent | 2b75425070662b869c15673623df44e30ce43ebe (diff) |
fix buffer overflow in error handling module
- fixed ring buffer overflow in errcatch module
- fixed naming of commands in sercomm module
- added comments to macro's in consts.h
- properly handle `W2_E_WARN_UNCAUGHT_ERROR` and
`W2_E_WARN_ERR_BUFFER_FULL` (these used to cause infinite loops)
- added buffer full warning code
- added options to hide some simulation messages
- more boilerplate sercomm module code
Diffstat (limited to 'robot/sercomm.h')
-rw-r--r-- | robot/sercomm.h | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/robot/sercomm.h b/robot/sercomm.h index 1533a4c..d960d0d 100644 --- a/robot/sercomm.h +++ b/robot/sercomm.h @@ -1,27 +1,35 @@ #pragma once #include "bin.h" +#include "consts.h" -#define W2_CMD_RX (0) -#define W2_CMD_TX (1) +#define W2_CMDDIR_RX (0) +#define W2_CMDDIR_TX (1) enum w2_e_serial_commands { - W2_E_CMD_PING = 0x00, - W2_E_CMD_EXPT = 0x02, - W2_E_CMD_MODE = 0x04, - W2_E_CMD_SPED = 0x06, - W2_E_CMD_DIRC = 0x08, - W2_E_CMD_CORD = 0x0a, - W2_E_CMD_BOMD = 0x0c, - W2_E_CMD_SRES = 0x0e, - W2_E_CMD_MCFG = 0x10, - W2_E_CMD_SENS = 0x12, - W2_E_CMD_INFO = 0x14, - W2_E_CMD_DISP = 0x16, - W2_E_CMD_PLAY = 0x18, - W2_E_CMD_CLED = 0x1a, + W2_CMD_PING = 0x00, + W2_CMD_EXPT = 0x02, + W2_CMD_MODE = 0x04, + W2_CMD_SPED = 0x06, + W2_CMD_DIRC = 0x08, + W2_CMD_CORD = 0x0a, + W2_CMD_BOMD = 0x0c, + W2_CMD_SRES = 0x0e, + W2_CMD_MCFG = 0x10, + W2_CMD_SENS = 0x12, + W2_CMD_INFO = 0x14, + W2_CMD_DISP = 0x16, + W2_CMD_PLAY = 0x18, + W2_CMD_CLED = 0x1a, }; +/** sercomm ring buffer */ +extern w2_s_bin *g_w2_sercomm_buffer[W2_SERCOMM_BUFFER_SIZE]; +/** stores head of ring buffer */ +extern uint8_t g_w2_error_index; +/** stores start of ring buffer */ +extern uint8_t g_w2_error_offset; + /** * serial pc-robot communication module * |