From c88ebb74cfeae41a0d5552a90c380e7473c18415 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Millet?= Date: Thu, 10 Jun 2021 08:05:25 +0200 Subject: [PATCH] Removes assert from RF433any.h - RF433any uses its own assert mechanism. I had made it available in RF433any.h so that test.ino could use it, but it is not logical (an RF433any user could face a conflict if using RF433any and their own, or the default, assert). Now assert is defined only in RF433any.cpp. This of course requested test.ino to define its own assert, that was done, too. --- RF433any.cpp | 10 +++++++++- RF433any.h | 9 --------- extras/testplan/test/test.ino | 18 ++++++++++++++++++ 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/RF433any.cpp b/RF433any.cpp index 3fb1c65..e267366 100644 --- a/RF433any.cpp +++ b/RF433any.cpp @@ -122,7 +122,15 @@ track -> r_low -> b_short = manage short duration on LOW signal #include "RF433any.h" #include -void assert_failed(int line) { +#define ASSERT_OUTPUT_TO_SERIAL + +#define assert(cond) { \ + if (!(cond)) { \ + rf433any_assert_failed(__LINE__); \ + } \ +} + +static void rf433any_assert_failed(int line) { #ifdef ASSERT_OUTPUT_TO_SERIAL Serial.print("\nRF433any.cpp:"); Serial.print(line); diff --git a/RF433any.h b/RF433any.h index 0893485..61b1128 100644 --- a/RF433any.h +++ b/RF433any.h @@ -102,15 +102,6 @@ #define RF433ANY_MAX_SECTIONS 8 #endif -#define ASSERT_OUTPUT_TO_SERIAL - -#define assert(cond) { \ - if (!(cond)) { \ - assert_failed(__LINE__); \ - } \ -} -void assert_failed(int line); - // * **** ********************************************************************* // * Band ********************************************************************* diff --git a/extras/testplan/test/test.ino b/extras/testplan/test/test.ino index 6aade38..479b121 100644 --- a/extras/testplan/test/test.ino +++ b/extras/testplan/test/test.ino @@ -41,6 +41,24 @@ extern unsigned int sim_int_count_svg; bool filter_mask_set; uint16_t filter_mask; +#define ASSERT_OUTPUT_TO_SERIAL + +#define assert(cond) { \ + if (!(cond)) { \ + assert_failed(__LINE__); \ + } \ +} + +static void assert_failed(int line) { +#ifdef ASSERT_OUTPUT_TO_SERIAL + Serial.print("\nRF433any.cpp:"); + Serial.print(line); + Serial.println(": assertion failed, aborted."); +#endif + while (1) + ; +} + void setup() { pinMode(PIN_RFINPUT, INPUT); Serial.begin(115200);