summaryrefslogtreecommitdiff
path: root/robot/sim.h
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2022-05-17 22:37:09 +0200
committerlonkaars <loek@pipeframe.xyz>2022-05-17 22:37:09 +0200
commit154df68cb2a74a3b22456e8ec5af3af54352a41f (patch)
treef9d2c83b30322d81691ae1a013813add6ec6b99e /robot/sim.h
parent2b75425070662b869c15673623df44e30ce43ebe (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/sim.h')
-rw-r--r--robot/sim.h13
1 files changed, 9 insertions, 4 deletions
diff --git a/robot/sim.h b/robot/sim.h
index 15a1b4b..9c80ecf 100644
--- a/robot/sim.h
+++ b/robot/sim.h
@@ -4,6 +4,11 @@
#include <stdlib.h>
#include <unistd.h>
+// debug fine-tuning
+#define DBG_ENABLE_PRINTFUNC (0)
+#define DBG_ENABLE_SIMWARN (1)
+#define DBG_ENABLE_SIMINFO (1)
+
// debug print options
#define DBG_BYTES_PER_LINE 16
@@ -21,10 +26,10 @@
// debug stdout print macros
#define simprintf(message, ...) printf(COL_RED "[SIM] " COL_RST message, ##__VA_ARGS__)
#define simprint(message) simprintf(message "\n")
-#define simprintfunc(name, fmt, ...) simprintf(COL_BLU "[FUNC] " \
- COL_CYN name COL_RST "(" COL_YEL fmt COL_RST ")\n", ##__VA_ARGS__)
-#define simwarn(message, ...) simprintf(COL_YEL "[WARN] " COL_RST message, ##__VA_ARGS__)
-#define siminfo(message, ...) simprintf(COL_MAG "[INFO] " COL_RST message, ##__VA_ARGS__)
+#define simprintfunc(name, fmt, ...) if (DBG_ENABLE_PRINTFUNC) { simprintf(COL_BLU "[FUNC] " \
+ COL_CYN name COL_RST "(" COL_YEL fmt COL_RST ")\n", ##__VA_ARGS__); }
+#define simwarn(message, ...) if (DBG_ENABLE_SIMWARN) { simprintf(COL_YEL "[WARN] " COL_RST message, ##__VA_ARGS__); }
+#define siminfo(message, ...) if (DBG_ENABLE_SIMINFO) { simprintf(COL_MAG "[INFO] " COL_RST message, ##__VA_ARGS__); }
/**
* simulates pololu library functions for local testing