From 538956525e6ef06c2fd7561bb51dc3ce60291d55 Mon Sep 17 00:00:00 2001 From: sanujkul Date: Sat, 7 Mar 2020 18:00:56 +0530 Subject: [PATCH 01/13] Created an advance example that uses SoftwareSerial --- .../Arduino_Debug_Advance.ino | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 examples/Arduino_Debug_Advance/Arduino_Debug_Advance.ino diff --git a/examples/Arduino_Debug_Advance/Arduino_Debug_Advance.ino b/examples/Arduino_Debug_Advance/Arduino_Debug_Advance.ino new file mode 100644 index 0000000..f5b8469 --- /dev/null +++ b/examples/Arduino_Debug_Advance/Arduino_Debug_Advance.ino @@ -0,0 +1,29 @@ +/* + * Advanced Debug can be helpful in embedded applications when + * there are more that two microcontrollers connected serially + * or a wireless sensor like Xbee is connected to the serial port + * that will send data wirelessly to other Xbee node. + * + * In boards like Ardunino Nano, UNO, MEGA only one serial port is available, + * therefore additional Software Serial ports can be made usinf SoftwareSerial + */ + +#include "Arduino_DebugUtils.h" +#include + +SoftwareSerial mySerial(10, 11); // RX, TX + +void setup() { + mySerial.begin(9600); + Debug.setDebugOutputStream(&mySerial); + Debug.setDebugLevel(DBG_VERBOSE); + Debug.timestampOn(); +} + +int i = 0; + +void loop() { + Debug.print(DBG_VERBOSE, "i = %d", i); + i++; + delay(1000); +} From 390cc31f1dcae40f64b7ef905a041e2989f92226 Mon Sep 17 00:00:00 2001 From: sanujkul Date: Sat, 7 Mar 2020 18:02:14 +0530 Subject: [PATCH 02/13] Added documnetation in Readme.md --- README.md | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/README.md b/README.md index 24fb18b..9c4401b 100644 --- a/README.md +++ b/README.md @@ -27,3 +27,41 @@ If desired timestamps can be prefixed to the debug message. Timestamp output can # How-To-Use Advanced Normally all debug output is redirected to the primary serial output of each board (`Serial`). In case you want to redirect the output to another output stream you can make use of `setDebugOutputStream(&Serial2)`. + +# Documentation +### 1. Debug : +Arduino_DebugUtils Object that will be used for calling member functions. + +### 2. Debug.setDebugLevel(int const debug_level) : +Parameter debug_level in order of lowest to highest priority are : `DBG_NONE`, `DBG_ERROR`, `DBG_WARNING`, `DBG_INFO` (default), `DBG_DEBUG`, and `DBG_VERBOSE`. +Return type: void. +Example: +``` +Debug.setDebugLevel(DBG_VERBOSE); +``` + +### 2. Debug.setDebugOutputStream(Stream * stream) : +By default, Output Stream is Serial. In advanced cases other objects could be other serial ports (if available), or can be a Software Serial object. +Example: +``` +SoftwareSerial mySerial(10, 11); // RX, TX +... +Debug.setDebugOutputStream(&mySerial); +``` + +### 3. Debug.timestampOn() : +Calling this function will switches on the timestamp in `Debug.print()` function call; +By default, printing timestamp is off, unless turned on using this function call. + +### 4. Debug.timestampOff() : +Calling this function will switches off the timestamp in `Debug.print()` function call; + +### 5. Debug.print(int const debug_level, const char * fmt, ...); +This function assess the debug_level and prints the message if parameter `debug_level` in `Debug.print(debug_level, ...)` function call belongs to the range: DBG_ERROR <= debug_level <= ( that has been set using setDebugLevel() function). +Example: +``` +Debug.setDebugLevel(DBG_VERBOSE); +int i = 0; +Debug.print(DBG_VERBOSE, "DBG_VERBOSE i = %d", i); + +``` From 1f61dd895d499aafeecf4ad215dfdcc745c0c338 Mon Sep 17 00:00:00 2001 From: Sanuj Kulshrestha <32244790+sanujkul@users.noreply.github.com> Date: Sat, 7 Mar 2020 18:15:13 +0530 Subject: [PATCH 03/13] Some minor changes --- README.md | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 9c4401b..0328002 100644 --- a/README.md +++ b/README.md @@ -29,31 +29,28 @@ If desired timestamps can be prefixed to the debug message. Timestamp output can Normally all debug output is redirected to the primary serial output of each board (`Serial`). In case you want to redirect the output to another output stream you can make use of `setDebugOutputStream(&Serial2)`. # Documentation -### 1. Debug : -Arduino_DebugUtils Object that will be used for calling member functions. +### 1. Debug : +Arduino_DebugUtils Object that will be used for calling member functions. ### 2. Debug.setDebugLevel(int const debug_level) : -Parameter debug_level in order of lowest to highest priority are : `DBG_NONE`, `DBG_ERROR`, `DBG_WARNING`, `DBG_INFO` (default), `DBG_DEBUG`, and `DBG_VERBOSE`. -Return type: void. +Parameter debug_level in order of lowest to highest priority are : `DBG_NONE`, `DBG_ERROR`, `DBG_WARNING`, `DBG_INFO` (default), `DBG_DEBUG`, and `DBG_VERBOSE`. +Return type: void. Example: ``` Debug.setDebugLevel(DBG_VERBOSE); ``` - -### 2. Debug.setDebugOutputStream(Stream * stream) : +### 2. Debug.setDebugOutputStream(Stream * stream) : By default, Output Stream is Serial. In advanced cases other objects could be other serial ports (if available), or can be a Software Serial object. Example: ``` SoftwareSerial mySerial(10, 11); // RX, TX -... Debug.setDebugOutputStream(&mySerial); ``` - -### 3. Debug.timestampOn() : +### 3. Debug.timestampOn() : Calling this function will switches on the timestamp in `Debug.print()` function call; By default, printing timestamp is off, unless turned on using this function call. -### 4. Debug.timestampOff() : +### 4. Debug.timestampOff() : Calling this function will switches off the timestamp in `Debug.print()` function call; ### 5. Debug.print(int const debug_level, const char * fmt, ...); @@ -63,5 +60,4 @@ Example: Debug.setDebugLevel(DBG_VERBOSE); int i = 0; Debug.print(DBG_VERBOSE, "DBG_VERBOSE i = %d", i); - ``` From 0a3842a5b729362c12c1edc8970fdb193de8ee49 Mon Sep 17 00:00:00 2001 From: Sanuj Kulshrestha <32244790+sanujkul@users.noreply.github.com> Date: Sun, 8 Mar 2020 14:25:58 +0530 Subject: [PATCH 04/13] Update README.md Co-Authored-By: per1234 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0328002..064aee7 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ SoftwareSerial mySerial(10, 11); // RX, TX Debug.setDebugOutputStream(&mySerial); ``` ### 3. Debug.timestampOn() : -Calling this function will switches on the timestamp in `Debug.print()` function call; +Calling this function switches on the timestamp in the `Debug.print()` function call; By default, printing timestamp is off, unless turned on using this function call. ### 4. Debug.timestampOff() : From 347b84ca0b151e260c994a178f206ac5c17ad8e2 Mon Sep 17 00:00:00 2001 From: Sanuj Kulshrestha <32244790+sanujkul@users.noreply.github.com> Date: Sun, 8 Mar 2020 14:26:10 +0530 Subject: [PATCH 05/13] Update README.md Co-Authored-By: per1234 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 064aee7..21e1d87 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ Calling this function switches on the timestamp in the `Debug.print()` function By default, printing timestamp is off, unless turned on using this function call. ### 4. Debug.timestampOff() : -Calling this function will switches off the timestamp in `Debug.print()` function call; +Calling this function switches off the timestamp in the `Debug.print()` function call; ### 5. Debug.print(int const debug_level, const char * fmt, ...); This function assess the debug_level and prints the message if parameter `debug_level` in `Debug.print(debug_level, ...)` function call belongs to the range: DBG_ERROR <= debug_level <= ( that has been set using setDebugLevel() function). From b91c3f14c1409e62196a9ba50b51010ffff8d225 Mon Sep 17 00:00:00 2001 From: Sanuj Kulshrestha <32244790+sanujkul@users.noreply.github.com> Date: Sun, 8 Mar 2020 14:26:28 +0530 Subject: [PATCH 06/13] Update examples/Arduino_Debug_Advance/Arduino_Debug_Advance.ino Co-Authored-By: per1234 --- examples/Arduino_Debug_Advance/Arduino_Debug_Advance.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/Arduino_Debug_Advance/Arduino_Debug_Advance.ino b/examples/Arduino_Debug_Advance/Arduino_Debug_Advance.ino index f5b8469..98b4148 100644 --- a/examples/Arduino_Debug_Advance/Arduino_Debug_Advance.ino +++ b/examples/Arduino_Debug_Advance/Arduino_Debug_Advance.ino @@ -5,7 +5,7 @@ * that will send data wirelessly to other Xbee node. * * In boards like Ardunino Nano, UNO, MEGA only one serial port is available, - * therefore additional Software Serial ports can be made usinf SoftwareSerial + * therefore additional Software Serial ports can be made using SoftwareSerial */ #include "Arduino_DebugUtils.h" From 2749e02b8bb4a691da487b47450f2260339b6dbf Mon Sep 17 00:00:00 2001 From: Sanuj Kulshrestha <32244790+sanujkul@users.noreply.github.com> Date: Sun, 8 Mar 2020 14:27:11 +0530 Subject: [PATCH 07/13] Update README.md about Debug.print() Co-Authored-By: per1234 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 21e1d87..a213073 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,7 @@ By default, printing timestamp is off, unless turned on using this function call Calling this function switches off the timestamp in the `Debug.print()` function call; ### 5. Debug.print(int const debug_level, const char * fmt, ...); -This function assess the debug_level and prints the message if parameter `debug_level` in `Debug.print(debug_level, ...)` function call belongs to the range: DBG_ERROR <= debug_level <= ( that has been set using setDebugLevel() function). +This function prints the message if parameter `debug_level` in the `Debug.print(debug_level, ...)` function call belongs to the range: DBG_ERROR <= debug_level <= ( that has been set using `setDebugLevel()` function). Example: ``` Debug.setDebugLevel(DBG_VERBOSE); From c0ad8fba3196e00aad47da4976b13c39fe9df422 Mon Sep 17 00:00:00 2001 From: Sanuj Kulshrestha <32244790+sanujkul@users.noreply.github.com> Date: Sun, 8 Mar 2020 14:27:50 +0530 Subject: [PATCH 08/13] Update examples/Arduino_Debug_Advance/Arduino_Debug_Advance.ino Correcting spelling of Arduino in comments Co-Authored-By: per1234 --- examples/Arduino_Debug_Advance/Arduino_Debug_Advance.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/Arduino_Debug_Advance/Arduino_Debug_Advance.ino b/examples/Arduino_Debug_Advance/Arduino_Debug_Advance.ino index 98b4148..f095666 100644 --- a/examples/Arduino_Debug_Advance/Arduino_Debug_Advance.ino +++ b/examples/Arduino_Debug_Advance/Arduino_Debug_Advance.ino @@ -4,7 +4,7 @@ * or a wireless sensor like Xbee is connected to the serial port * that will send data wirelessly to other Xbee node. * - * In boards like Ardunino Nano, UNO, MEGA only one serial port is available, + * In boards like Arduino Nano, UNO, MEGA only one serial port is available, * therefore additional Software Serial ports can be made using SoftwareSerial */ From 85a9e34155e26d1400bbc9ab68bc685ca9b5366c Mon Sep 17 00:00:00 2001 From: Sanuj Kulshrestha <32244790+sanujkul@users.noreply.github.com> Date: Sun, 8 Mar 2020 14:28:30 +0530 Subject: [PATCH 09/13] Update examples/Arduino_Debug_Advance/Arduino_Debug_Advance.ino Co-Authored-By: per1234 --- examples/Arduino_Debug_Advance/Arduino_Debug_Advance.ino | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/Arduino_Debug_Advance/Arduino_Debug_Advance.ino b/examples/Arduino_Debug_Advance/Arduino_Debug_Advance.ino index f095666..e690e07 100644 --- a/examples/Arduino_Debug_Advance/Arduino_Debug_Advance.ino +++ b/examples/Arduino_Debug_Advance/Arduino_Debug_Advance.ino @@ -1,8 +1,8 @@ /* * Advanced Debug can be helpful in embedded applications when * there are more that two microcontrollers connected serially - * or a wireless sensor like Xbee is connected to the serial port - * that will send data wirelessly to other Xbee node. + * or a wireless sensor like XBee is connected to the serial port + * that will send data wirelessly to other XBee node. * * In boards like Arduino Nano, UNO, MEGA only one serial port is available, * therefore additional Software Serial ports can be made using SoftwareSerial From 68e761ce165400266315108d71aa9b5211dc44cd Mon Sep 17 00:00:00 2001 From: Sanuj Kulshrestha <32244790+sanujkul@users.noreply.github.com> Date: Sun, 8 Mar 2020 14:29:39 +0530 Subject: [PATCH 10/13] Update README.md Adding a linebreak Co-Authored-By: per1234 --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index a213073..e8273b1 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,9 @@ Arduino_DebugUtils Object that will be used for calling member functions. ### 2. Debug.setDebugLevel(int const debug_level) : Parameter debug_level in order of lowest to highest priority are : `DBG_NONE`, `DBG_ERROR`, `DBG_WARNING`, `DBG_INFO` (default), `DBG_DEBUG`, and `DBG_VERBOSE`. + Return type: void. + Example: ``` Debug.setDebugLevel(DBG_VERBOSE); From e22c60dfb16d3a91746c54aaf55910ec4dbe0b75 Mon Sep 17 00:00:00 2001 From: Sanuj Kulshrestha <32244790+sanujkul@users.noreply.github.com> Date: Sun, 8 Mar 2020 14:29:56 +0530 Subject: [PATCH 11/13] Update README.md Adding one more linebreak Co-Authored-By: per1234 --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index e8273b1..8db893e 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,7 @@ Debug.setDebugLevel(DBG_VERBOSE); ``` ### 2. Debug.setDebugOutputStream(Stream * stream) : By default, Output Stream is Serial. In advanced cases other objects could be other serial ports (if available), or can be a Software Serial object. + Example: ``` SoftwareSerial mySerial(10, 11); // RX, TX From edacd9c2bb1c6aa6db79f8726439fac5d532b87a Mon Sep 17 00:00:00 2001 From: Sanuj Kulshrestha <32244790+sanujkul@users.noreply.github.com> Date: Sun, 8 Mar 2020 14:34:08 +0530 Subject: [PATCH 12/13] removing numbers & adding return types & examples --- README.md | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 8db893e..32a5558 100644 --- a/README.md +++ b/README.md @@ -29,10 +29,10 @@ If desired timestamps can be prefixed to the debug message. Timestamp output can Normally all debug output is redirected to the primary serial output of each board (`Serial`). In case you want to redirect the output to another output stream you can make use of `setDebugOutputStream(&Serial2)`. # Documentation -### 1. Debug : +### Debug : Arduino_DebugUtils Object that will be used for calling member functions. -### 2. Debug.setDebugLevel(int const debug_level) : +### Debug.setDebugLevel(int const debug_level) : Parameter debug_level in order of lowest to highest priority are : `DBG_NONE`, `DBG_ERROR`, `DBG_WARNING`, `DBG_INFO` (default), `DBG_DEBUG`, and `DBG_VERBOSE`. Return type: void. @@ -41,23 +41,45 @@ Example: ``` Debug.setDebugLevel(DBG_VERBOSE); ``` -### 2. Debug.setDebugOutputStream(Stream * stream) : +### Debug.setDebugOutputStream(Stream * stream) : By default, Output Stream is Serial. In advanced cases other objects could be other serial ports (if available), or can be a Software Serial object. +Return type: void. + Example: ``` SoftwareSerial mySerial(10, 11); // RX, TX Debug.setDebugOutputStream(&mySerial); ``` -### 3. Debug.timestampOn() : +### Debug.timestampOn() : Calling this function switches on the timestamp in the `Debug.print()` function call; By default, printing timestamp is off, unless turned on using this function call. -### 4. Debug.timestampOff() : +Return type: void. + +Example: +``` +Debug.timestampOn(); +Debug.print(DBG_VERBOSE, "i = %d", i); //Output looks like : [ 21007 ] i = 21 +``` + +### Debug.timestampOff() : Calling this function switches off the timestamp in the `Debug.print()` function call; -### 5. Debug.print(int const debug_level, const char * fmt, ...); +Return type: void. + +Example: +``` +Debug.timestampOff(); +Debug.print(DBG_VERBOSE, "i = %d", i); //Output looks like : i = 21 +``` + + +### Debug.print(int const debug_level, const char * fmt, ...); This function prints the message if parameter `debug_level` in the `Debug.print(debug_level, ...)` function call belongs to the range: DBG_ERROR <= debug_level <= ( that has been set using `setDebugLevel()` function). + +Return type: void. + Example: ``` Debug.setDebugLevel(DBG_VERBOSE); From 09b949264f69583a1ca6efb983ec705cc5c35b2a Mon Sep 17 00:00:00 2001 From: sanujkul Date: Sun, 8 Mar 2020 14:49:25 +0530 Subject: [PATCH 13/13] Auto formatting the code --- .../Arduino_Debug_Advance.ino | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/Arduino_Debug_Advance/Arduino_Debug_Advance.ino b/examples/Arduino_Debug_Advance/Arduino_Debug_Advance.ino index e690e07..5ebbcc1 100644 --- a/examples/Arduino_Debug_Advance/Arduino_Debug_Advance.ino +++ b/examples/Arduino_Debug_Advance/Arduino_Debug_Advance.ino @@ -1,12 +1,12 @@ /* - * Advanced Debug can be helpful in embedded applications when - * there are more that two microcontrollers connected serially - * or a wireless sensor like XBee is connected to the serial port - * that will send data wirelessly to other XBee node. - * - * In boards like Arduino Nano, UNO, MEGA only one serial port is available, - * therefore additional Software Serial ports can be made using SoftwareSerial - */ + Advanced Debug can be helpful in embedded applications when + there are more that two microcontrollers connected serially + or a wireless sensor like XBee is connected to the serial port + that will send data wirelessly to other XBee node. + + In boards like Arduino Nano, UNO, MEGA only one serial port is available, + therefore additional Software Serial ports can be made using SoftwareSerial +*/ #include "Arduino_DebugUtils.h" #include