From 02b015fb96408930af8edfcd753cc1b61b6159cc Mon Sep 17 00:00:00 2001 From: ubi Date: Mon, 22 Jul 2019 12:56:14 +0200 Subject: [PATCH 01/60] fix version number in library.properties --- library.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library.properties b/library.properties index a3c53e5..fd1a3c6 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Arduino_DebugUtils -version=1.0.0 +version=0.1.2 author=Arduino maintainer=Arduino sentence=Debugging module with different debug levels, timestamps and printf-style output. From eb3238b7d44d31334b08dbbd0423d3c1e058cb2e Mon Sep 17 00:00:00 2001 From: per1234 Date: Wed, 7 Aug 2019 01:15:57 -0700 Subject: [PATCH 02/60] Update arduino-cli binary filename MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The arduino-cli binary filename was recently changed, which broke CI builds: mv: cannot stat ‘arduino-cli-*-linux64’: No such file or directory --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c1073db..17a2d81 100644 --- a/.travis.yml +++ b/.travis.yml @@ -45,7 +45,7 @@ before_install: - wget http://downloads.arduino.cc/arduino-cli/arduino-cli-$CLI_VERSION-linux64.tar.bz2 - tar xf arduino-cli-$CLI_VERSION-linux64.tar.bz2 - mkdir -p "$HOME/bin" - - mv arduino-cli-*-linux64 $HOME/bin/arduino-cli + - mv arduino-cli $HOME/bin - export PATH="$PATH:$HOME/bin" - arduino-cli core update-index - if [[ "$BOARD" =~ "arduino:samd:" ]]; then From 538956525e6ef06c2fd7561bb51dc3ce60291d55 Mon Sep 17 00:00:00 2001 From: sanujkul Date: Sat, 7 Mar 2020 18:00:56 +0530 Subject: [PATCH 03/60] 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 04/60] 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 05/60] 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 06/60] 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 07/60] 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 08/60] 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 09/60] 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 10/60] 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 11/60] 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 12/60] 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 13/60] 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 14/60] 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 15/60] 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 From 0f59f1001e72a3449c689553462ae49653f0e80b Mon Sep 17 00:00:00 2001 From: Alexander Entinger Date: Fri, 21 Aug 2020 06:23:53 +0200 Subject: [PATCH 16/60] Add support for strings stored in flash --- src/Arduino_DebugUtils.cpp | 31 ++++++++++++++++++++++++++++--- src/Arduino_DebugUtils.h | 1 + 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/src/Arduino_DebugUtils.cpp b/src/Arduino_DebugUtils.cpp index 09c2c37..f7775a5 100644 --- a/src/Arduino_DebugUtils.cpp +++ b/src/Arduino_DebugUtils.cpp @@ -58,11 +58,14 @@ void Arduino_DebugUtils::timestampOff() { _timestamp_on = false; } -void Arduino_DebugUtils::print(int const debug_level, const char * fmt, ...) { +void Arduino_DebugUtils::print(int const debug_level, const char * fmt, ...) +{ if (debug_level >= DBG_ERROR && debug_level <= DBG_VERBOSE && - debug_level <= _debug_level) { - if (_timestamp_on) { + debug_level <= _debug_level) + { + if (_timestamp_on) + { char timestamp[20]; snprintf(timestamp, 20, "[ %lu ] ", millis()); _debug_output_stream->print(timestamp); @@ -75,6 +78,28 @@ void Arduino_DebugUtils::print(int const debug_level, const char * fmt, ...) { } } +void Arduino_DebugUtils::print(int const debug_level, const __FlashStringHelper * fmt, ...) +{ + if (debug_level >= DBG_ERROR && + debug_level <= DBG_VERBOSE && + debug_level <= _debug_level) + { + if (_timestamp_on) + { + char timestamp[20]; + snprintf(timestamp, 20, "[ %lu ] ", millis()); + _debug_output_stream->print(timestamp); + } + + String fmt_str(fmt); + + va_list args; + va_start(args, fmt_str.c_str()); + vPrint(fmt_str.c_str(), args); + va_end(args); + } +} + /****************************************************************************** PRIVATE MEMBER FUNCTIONS ******************************************************************************/ diff --git a/src/Arduino_DebugUtils.h b/src/Arduino_DebugUtils.h index 77bfe45..10e9b70 100644 --- a/src/Arduino_DebugUtils.h +++ b/src/Arduino_DebugUtils.h @@ -57,6 +57,7 @@ class Arduino_DebugUtils { void timestampOff(); void print(int const debug_level, const char * fmt, ...); + void print(int const debug_level, const __FlashStringHelper * fmt, ...); private: From 2194004cfebcb0d891bcbbbc9d8460b3f33e2bc6 Mon Sep 17 00:00:00 2001 From: Alexander Entinger Date: Fri, 21 Aug 2020 06:26:45 +0200 Subject: [PATCH 17/60] Disable code formatting check --- .travis.yml | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/.travis.yml b/.travis.yml index 17a2d81..8c6cbef 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,25 +10,6 @@ matrix: - BOARD="arduino:samd:mkrwifi1010" - env: - BOARD="arduino:samd:mkrgsm1400" - - env: - - NAME=Code Formatting Check - # must define an empty before_install phase, otherwise the default one is used - before_install: true - install: - # install Artistic Style code formatter tool: http://astyle.sourceforge.net - - | - mkdir "${HOME}/astyle"; - wget --no-verbose --output-document="${HOME}/astyle/astyle.tar.gz" "https://iweb.dl.sourceforge.net/project/astyle/astyle/astyle%203.1/astyle_3.1_linux.tar.gz"; - tar --extract --file="${HOME}/astyle/astyle.tar.gz" --directory="${HOME}/astyle"; - cd "${HOME}/astyle/astyle/build/gcc"; - make; - export PATH=$PWD/bin:$PATH; - cd "$TRAVIS_BUILD_DIR" - # download Arduino's Artistic Style configuration file - - wget --directory-prefix="${HOME}/astyle" https://raw.githubusercontent.com/arduino/Arduino/master/build/shared/examples_formatter.conf - script: - # check code formatting - - find . -regextype posix-extended -path './.git' -prune -or \( -iregex '.*\.((ino)|(h)|(hpp)|(hh)|(hxx)|(h\+\+)|(cpp)|(cc)|(cxx)|(c\+\+)|(cp)|(c)|(ipp)|(ii)|(ixx)|(inl)|(tpp)|(txx)|(tpl))$' -and -type f \) -print0 | xargs -0 -L1 bash -c 'if ! diff "$0" <(astyle --options=${HOME}/astyle/examples_formatter.conf --dry-run < "$0"); then echo "Non-compliant code formatting in $0"; false; fi' - env: - NAME=Spell Check language: python From 0b9bc1a13e33c409005a2313611754f749c766ff Mon Sep 17 00:00:00 2001 From: Alexander Entinger Date: Fri, 21 Aug 2020 06:40:03 +0200 Subject: [PATCH 18/60] Extract common functionality 'printTimestamp' in order to reduce code duplication --- src/Arduino_DebugUtils.cpp | 19 +++++++++---------- src/Arduino_DebugUtils.h | 1 + 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Arduino_DebugUtils.cpp b/src/Arduino_DebugUtils.cpp index f7775a5..81edb67 100644 --- a/src/Arduino_DebugUtils.cpp +++ b/src/Arduino_DebugUtils.cpp @@ -65,11 +65,7 @@ void Arduino_DebugUtils::print(int const debug_level, const char * fmt, ...) debug_level <= _debug_level) { if (_timestamp_on) - { - char timestamp[20]; - snprintf(timestamp, 20, "[ %lu ] ", millis()); - _debug_output_stream->print(timestamp); - } + printTimestamp(); va_list args; va_start(args, fmt); @@ -85,11 +81,7 @@ void Arduino_DebugUtils::print(int const debug_level, const __FlashStringHelper debug_level <= _debug_level) { if (_timestamp_on) - { - char timestamp[20]; - snprintf(timestamp, 20, "[ %lu ] ", millis()); - _debug_output_stream->print(timestamp); - } + printTimestamp(); String fmt_str(fmt); @@ -113,6 +105,13 @@ void Arduino_DebugUtils::vPrint(char const * fmt, va_list args) { _debug_output_stream->println(msg_buf); } +void Arduino_DebugUtils::printTimestamp() +{ + char timestamp[20]; + snprintf(timestamp, 20, "[ %lu ] ", millis()); + _debug_output_stream->print(timestamp); +} + /****************************************************************************** CLASS INSTANTIATION ******************************************************************************/ diff --git a/src/Arduino_DebugUtils.h b/src/Arduino_DebugUtils.h index 10e9b70..7968e22 100644 --- a/src/Arduino_DebugUtils.h +++ b/src/Arduino_DebugUtils.h @@ -67,6 +67,7 @@ class Arduino_DebugUtils { Stream * _debug_output_stream; void vPrint(char const * fmt, va_list args); + void printTimestamp(); }; From eee2fce063b2d2ddf316a99297e5197c5ff89273 Mon Sep 17 00:00:00 2001 From: Alexander Entinger Date: Fri, 21 Aug 2020 06:43:51 +0200 Subject: [PATCH 19/60] Extracting check wether or not a debug message should be printed into shared function to avoid code duplication --- src/Arduino_DebugUtils.cpp | 53 +++++++++++++++++++------------------- src/Arduino_DebugUtils.h | 1 + 2 files changed, 28 insertions(+), 26 deletions(-) diff --git a/src/Arduino_DebugUtils.cpp b/src/Arduino_DebugUtils.cpp index 81edb67..63c9444 100644 --- a/src/Arduino_DebugUtils.cpp +++ b/src/Arduino_DebugUtils.cpp @@ -60,36 +60,32 @@ void Arduino_DebugUtils::timestampOff() { void Arduino_DebugUtils::print(int const debug_level, const char * fmt, ...) { - if (debug_level >= DBG_ERROR && - debug_level <= DBG_VERBOSE && - debug_level <= _debug_level) - { - if (_timestamp_on) - printTimestamp(); - - va_list args; - va_start(args, fmt); - vPrint(fmt, args); - va_end(args); - } + if (!shouldPrint(debug_level)) + return; + + if (_timestamp_on) + printTimestamp(); + + va_list args; + va_start(args, fmt); + vPrint(fmt, args); + va_end(args); } void Arduino_DebugUtils::print(int const debug_level, const __FlashStringHelper * fmt, ...) { - if (debug_level >= DBG_ERROR && - debug_level <= DBG_VERBOSE && - debug_level <= _debug_level) - { - if (_timestamp_on) - printTimestamp(); - - String fmt_str(fmt); - - va_list args; - va_start(args, fmt_str.c_str()); - vPrint(fmt_str.c_str(), args); - va_end(args); - } + if (!shouldPrint(debug_level)) + return; + + if (_timestamp_on) + printTimestamp(); + + String fmt_str(fmt); + + va_list args; + va_start(args, fmt_str.c_str()); + vPrint(fmt_str.c_str(), args); + va_end(args); } /****************************************************************************** @@ -112,6 +108,11 @@ void Arduino_DebugUtils::printTimestamp() _debug_output_stream->print(timestamp); } +bool Arduino_DebugUtils::shouldPrint(int const debug_level) const +{ + return ((debug_level >= DBG_ERROR) && (debug_level <= DBG_VERBOSE) && (debug_level <= _debug_level)); +} + /****************************************************************************** CLASS INSTANTIATION ******************************************************************************/ diff --git a/src/Arduino_DebugUtils.h b/src/Arduino_DebugUtils.h index 7968e22..bfbb41d 100644 --- a/src/Arduino_DebugUtils.h +++ b/src/Arduino_DebugUtils.h @@ -68,6 +68,7 @@ class Arduino_DebugUtils { void vPrint(char const * fmt, va_list args); void printTimestamp(); + bool shouldPrint(int const debug_level) const; }; From aeb086d1d6a5a732df814fb9843ccdd08a10840e Mon Sep 17 00:00:00 2001 From: Alexander Entinger Date: Fri, 21 Aug 2020 06:54:01 +0200 Subject: [PATCH 20/60] Release v0.1.3 --- library.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library.properties b/library.properties index fd1a3c6..170a2c4 100644 --- a/library.properties +++ b/library.properties @@ -1,9 +1,9 @@ name=Arduino_DebugUtils -version=0.1.2 +version=0.1.3 author=Arduino maintainer=Arduino sentence=Debugging module with different debug levels, timestamps and printf-style output. paragraph=This class provides functionality useful for debugging sketches via printf-style statements. category=Communication url=https://github.com/arduino-libraries/Arduino_DebugUtils -architectures=* \ No newline at end of file +architectures=* From 3b90c2578b69f249292b3d7848e0c27d5be1a692 Mon Sep 17 00:00:00 2001 From: Alexander Entinger Date: Tue, 25 Aug 2020 15:32:28 +0200 Subject: [PATCH 21/60] Release v1.1.0 (since release 0.1.0 already had a version number of 1.1.0 and has therefore prevalence over 0.1.3) --- library.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library.properties b/library.properties index 170a2c4..30c17d8 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Arduino_DebugUtils -version=0.1.3 +version=1.1.0 author=Arduino maintainer=Arduino sentence=Debugging module with different debug levels, timestamps and printf-style output. From d4c97145381eb6ef23540342088ad0f838ab0202 Mon Sep 17 00:00:00 2001 From: per1234 Date: Sun, 11 Apr 2021 03:46:36 -0700 Subject: [PATCH 22/60] Configure Dependabot to check for outdated actions used in workflows Dependabot will periodically check the versions of all actions used in the repository's workflows. If any are found to be outdated, it will submit a pull request to update them. NOTE: Dependabot's PRs will sometimes try to pin to the patch version of the action (e.g., updating `uses: foo/bar@v1` to `uses: foo/bar@v2.3.4`). When the action author has provided a major version ref, use that instead (e.g., `uses: foo/bar@v2`). Dependabot will automatically close its PR once the workflow has been updated. More information: https://docs.github.com/en/github/administering-a-repository/keeping-your-actions-up-to-date-with-dependabot --- .github/dependabot.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..03600dd --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,10 @@ +# See: https://docs.github.com/en/github/administering-a-repository/configuration-options-for-dependency-updates#about-the-dependabotyml-file +version: 2 + +updates: + # Configure check for outdated GitHub Actions actions in workflows. + # See: https://docs.github.com/en/github/administering-a-repository/keeping-your-actions-up-to-date-with-dependabot + - package-ecosystem: github-actions + directory: / # Check the repository's workflows under /.github/workflows/ + schedule: + interval: daily From 6b42a95c387f799458e13d704ebe99fb278fc7c2 Mon Sep 17 00:00:00 2001 From: per1234 Date: Sun, 11 Apr 2021 03:46:56 -0700 Subject: [PATCH 23/60] Update CI workflow to check for commonly misspelled words On every push, pull request, and periodically, use the codespell-project/actions-codespell action to check for commonly misspelled words. In the event of a false positive, the problematic word should be added, in all lowercase, to the ignore-words-list field of ./.codespellrc. Regardless of the case of the word in the false positive, it must be in all lowercase in the ignore list. The ignore list is comma-separated with no spaces. --- .codespellrc | 7 +++++++ .github/workflows/spell-check.yml | 22 ++++++++++++++++++++++ .travis.yml | 11 ----------- README.md | 2 ++ extras/codespell-ignore-words-list.txt | 0 5 files changed, 31 insertions(+), 11 deletions(-) create mode 100644 .codespellrc create mode 100644 .github/workflows/spell-check.yml delete mode 100644 extras/codespell-ignore-words-list.txt diff --git a/.codespellrc b/.codespellrc new file mode 100644 index 0000000..101edae --- /dev/null +++ b/.codespellrc @@ -0,0 +1,7 @@ +# See: https://github.com/codespell-project/codespell#using-a-config-file +[codespell] +# In the event of a false positive, add the problematic word, in all lowercase, to a comma-separated list here: +ignore-words-list = , +check-filenames = +check-hidden = +skip = ./.git diff --git a/.github/workflows/spell-check.yml b/.github/workflows/spell-check.yml new file mode 100644 index 0000000..01bee87 --- /dev/null +++ b/.github/workflows/spell-check.yml @@ -0,0 +1,22 @@ +name: Spell Check + +# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows +on: + push: + pull_request: + schedule: + # Run every Tuesday at 8 AM UTC to catch new misspelling detections resulting from dictionary updates. + - cron: "0 8 * * TUE" + workflow_dispatch: + repository_dispatch: + +jobs: + spellcheck: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Spell check + uses: codespell-project/actions-codespell@master diff --git a/.travis.yml b/.travis.yml index 8c6cbef..a9821b7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,17 +10,6 @@ matrix: - BOARD="arduino:samd:mkrwifi1010" - env: - BOARD="arduino:samd:mkrgsm1400" - - env: - - NAME=Spell Check - language: python - python: 3.6 - # must define an empty before_install phase, otherwise the default one is used - before_install: true - install: - # https://github.com/codespell-project/codespell - - pip install codespell - script: - - codespell --skip="${TRAVIS_BUILD_DIR}/.git" --ignore-words="${TRAVIS_BUILD_DIR}/extras/codespell-ignore-words-list.txt" "${TRAVIS_BUILD_DIR}" # default phases before_install: - wget http://downloads.arduino.cc/arduino-cli/arduino-cli-$CLI_VERSION-linux64.tar.bz2 diff --git a/README.md b/README.md index 32a5558..8f21f21 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ Arduino_DebugUtils ================== +[![Spell Check status](https://github.com/arduino-libraries/Arduino_DebugUtils/actions/workflows/spell-check.yml/badge.svg)](https://github.com/arduino-libraries/Arduino_DebugUtils/actions/workflows/spell-check.yml) + This class provides functionality useful for debugging sketches via `printf`-style statements. # How-To-Use Basic diff --git a/extras/codespell-ignore-words-list.txt b/extras/codespell-ignore-words-list.txt deleted file mode 100644 index e69de29..0000000 From fd56e62cd4903625df4bd244d8d3dcb1c3283652 Mon Sep 17 00:00:00 2001 From: per1234 Date: Sun, 11 Apr 2021 03:57:58 -0700 Subject: [PATCH 24/60] Correct typos in comments and documentation --- README.md | 2 +- examples/Arduino_Debug_Advance/Arduino_Debug_Advance.ino | 9 +++++---- src/Arduino_DebugUtils.cpp | 2 +- src/Arduino_DebugUtils.h | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 8f21f21..c2e17e3 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ float pi = 3.1459; Debug.print(DBG_VERBOSE, "i = %d, pi = %f", i, pi); ``` -If desired timestamps can be prefixed to the debug message. Timestamp output can be enabled and disabled via `timestampOn` and `timestampOff`. +If desired, timestamps can be prefixed to the debug message. Timestamp output can be enabled and disabled via `timestampOn` and `timestampOff`. # 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)`. diff --git a/examples/Arduino_Debug_Advance/Arduino_Debug_Advance.ino b/examples/Arduino_Debug_Advance/Arduino_Debug_Advance.ino index 5ebbcc1..5837b52 100644 --- a/examples/Arduino_Debug_Advance/Arduino_Debug_Advance.ino +++ b/examples/Arduino_Debug_Advance/Arduino_Debug_Advance.ino @@ -1,11 +1,12 @@ /* Advanced Debug can be helpful in embedded applications when - there are more that two microcontrollers connected serially + there are more than 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. + that will send data wirelessly to other XBee nodes. - In boards like Arduino Nano, UNO, MEGA only one serial port is available, - therefore additional Software Serial ports can be made using SoftwareSerial + In boards like Arduino Nano, UNO, or MEGA only one serial port is available, + therefore additional software serial ports can be made using the + SoftwareSerial library. */ #include "Arduino_DebugUtils.h" diff --git a/src/Arduino_DebugUtils.cpp b/src/Arduino_DebugUtils.cpp index 63c9444..f1f9440 100644 --- a/src/Arduino_DebugUtils.cpp +++ b/src/Arduino_DebugUtils.cpp @@ -120,4 +120,4 @@ bool Arduino_DebugUtils::shouldPrint(int const debug_level) const Arduino_DebugUtils Debug; void setDebugMessageLevel(int const debug_level) { Debug.setDebugLevel(debug_level); -} \ No newline at end of file +} diff --git a/src/Arduino_DebugUtils.h b/src/Arduino_DebugUtils.h index bfbb41d..a44b5ac 100644 --- a/src/Arduino_DebugUtils.h +++ b/src/Arduino_DebugUtils.h @@ -78,4 +78,4 @@ class Arduino_DebugUtils { extern Arduino_DebugUtils Debug; -#endif /* ARDUINO_DEBUG_UTILS_H_ */ \ No newline at end of file +#endif /* ARDUINO_DEBUG_UTILS_H_ */ From 9967a0f980c77e2435e99627d8f30a5c5d4d2fe0 Mon Sep 17 00:00:00 2001 From: per1234 Date: Sun, 11 Apr 2021 03:58:19 -0700 Subject: [PATCH 25/60] Add CI workflow to do Arduino project-specific linting On every push, pull request, and periodically, run Arduino Lint to check for common problems not related to the project code. --- .github/workflows/check-arduino.yml | 28 ++++++++++++++++++++++++++++ README.md | 1 + 2 files changed, 29 insertions(+) create mode 100644 .github/workflows/check-arduino.yml diff --git a/.github/workflows/check-arduino.yml b/.github/workflows/check-arduino.yml new file mode 100644 index 0000000..0d969f6 --- /dev/null +++ b/.github/workflows/check-arduino.yml @@ -0,0 +1,28 @@ +name: Check Arduino + +# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows +on: + push: + pull_request: + schedule: + # Run every Tuesday at 8 AM UTC to catch breakage caused by new rules added to Arduino Lint. + - cron: "0 8 * * TUE" + workflow_dispatch: + repository_dispatch: + +jobs: + lint: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Arduino Lint + uses: arduino/arduino-lint-action@v1 + with: + compliance: specification + library-manager: update + # Always use this setting for official repositories. Remove for 3rd party projects. + official: true + project-type: library diff --git a/README.md b/README.md index c2e17e3..2a54b7d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ Arduino_DebugUtils ================== +[![Check Arduino status](https://github.com/arduino-libraries/Arduino_DebugUtils/actions/workflows/check-arduino.yml/badge.svg)](https://github.com/arduino-libraries/Arduino_DebugUtils/actions/workflows/check-arduino.yml) [![Spell Check status](https://github.com/arduino-libraries/Arduino_DebugUtils/actions/workflows/spell-check.yml/badge.svg)](https://github.com/arduino-libraries/Arduino_DebugUtils/actions/workflows/spell-check.yml) This class provides functionality useful for debugging sketches via `printf`-style statements. From 5782bb6691fe705e080c283684a8d0b79caaad6b Mon Sep 17 00:00:00 2001 From: per1234 Date: Sun, 11 Apr 2021 03:59:53 -0700 Subject: [PATCH 26/60] Update "smoke test" examples compilation CI workflow On every push or pull request that affects library source or example files, and periodically, compile all example sketches for the specified boards. --- .github/workflows/compile-examples.yml | 101 +++++++++++++++++++++++++ .travis.yml | 35 --------- README.md | 1 + 3 files changed, 102 insertions(+), 35 deletions(-) create mode 100644 .github/workflows/compile-examples.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/compile-examples.yml b/.github/workflows/compile-examples.yml new file mode 100644 index 0000000..9032dfb --- /dev/null +++ b/.github/workflows/compile-examples.yml @@ -0,0 +1,101 @@ +name: Compile Examples + +# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows +on: + push: + paths: + - ".github/workflows/compile-examples.yml" + - "examples/**" + - "src/**" + pull_request: + paths: + - ".github/workflows/compile-examples.yml" + - "examples/**" + - "src/**" + schedule: + # Run every Tuesday at 8 AM UTC to catch breakage caused by changes to external resources (libraries, platforms). + - cron: "0 8 * * TUE" + workflow_dispatch: + repository_dispatch: + +jobs: + build: + name: ${{ matrix.board.fqbn }} + runs-on: ubuntu-latest + + strategy: + fail-fast: false + + matrix: + board: + - fqbn: arduino:avr:nano + platforms: | + - name: arduino:avr + softwareserial: true + - fqbn: arduino:avr:mega + platforms: | + - name: arduino:avr + softwareserial: true + - fqbn: arduino:avr:leonardo + platforms: | + - name: arduino:avr + softwareserial: true + - fqbn: arduino:megaavr:nona4809 + platforms: | + - name: arduino:megaavr + softwareserial: true + - fqbn: arduino:sam:arduino_due_x_dbg + platforms: | + - name: arduino:sam + softwareserial: false + - fqbn: arduino:samd:mkrzero + platforms: | + - name: arduino:samd + softwareserial: false + - fqbn: arduino:mbed_portenta:envie_m4 + platforms: | + - name: arduino:mbed_portenta + softwareserial: false + - fqbn: arduino:mbed_portenta:envie_m7 + platforms: | + - name: arduino:mbed_portenta + softwareserial: false + - fqbn: arduino:mbed_nano:nano33ble + platforms: | + - name: arduino:mbed_nano + softwareserial: false + - fqbn: arduino:mbed_nano:nanorp2040connect + platforms: | + - name: arduino:mbed_nano + softwareserial: false + + # Make board type-specific customizations to the matrix jobs + include: + - board: + # Boards with a SoftwareSerial library + softwareserial: true + # Compile these sketches in addition to the ones defined by env.UNIVERSAL_SKETCH_PATHS + sketch-paths: | + - examples/Arduino_Debug_Advance + - board: + softwareserial: false + sketch-paths: "" + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Compile examples + uses: arduino/compile-sketches@v1 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + fqbn: ${{ matrix.board.fqbn }} + platforms: ${{ matrix.board.platforms }} + libraries: | + # Install the library from the local path. + - source-path: ./ + # Additional library dependencies can be listed here. + # See: https://github.com/arduino/compile-sketches#libraries + sketch-paths: | + - examples/Arduino_Debug_Basic + ${{ matrix.sketch-paths }} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index a9821b7..0000000 --- a/.travis.yml +++ /dev/null @@ -1,35 +0,0 @@ -language: generic -env: - global: - - CLI_VERSION=latest -matrix: - include: - - env: - - BOARD="arduino:samd:mkr1000" - - env: - - BOARD="arduino:samd:mkrwifi1010" - - env: - - BOARD="arduino:samd:mkrgsm1400" -# default phases -before_install: - - wget http://downloads.arduino.cc/arduino-cli/arduino-cli-$CLI_VERSION-linux64.tar.bz2 - - tar xf arduino-cli-$CLI_VERSION-linux64.tar.bz2 - - mkdir -p "$HOME/bin" - - mv arduino-cli $HOME/bin - - export PATH="$PATH:$HOME/bin" - - arduino-cli core update-index - - if [[ "$BOARD" =~ "arduino:samd:" ]]; then - arduino-cli core install arduino:samd; - fi - - buildExampleSketch() { arduino-cli compile --warnings all --fqbn $BOARD $PWD/examples/$1; } -install: - - mkdir -p $HOME/Arduino/libraries - - ln -s $PWD $HOME/Arduino/libraries/. -script: - - buildExampleSketch Arduino_Debug_Basic -notifications: - webhooks: - urls: - - https://www.travisbuddy.com/ - on_success: never - on_failure: always diff --git a/README.md b/README.md index 2a54b7d..5156760 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ Arduino_DebugUtils ================== [![Check Arduino status](https://github.com/arduino-libraries/Arduino_DebugUtils/actions/workflows/check-arduino.yml/badge.svg)](https://github.com/arduino-libraries/Arduino_DebugUtils/actions/workflows/check-arduino.yml) +[![Compile Examples status](https://github.com/arduino-libraries/Arduino_DebugUtils/actions/workflows/compile-examples.yml/badge.svg)](https://github.com/arduino-libraries/Arduino_DebugUtils/actions/workflows/compile-examples.yml) [![Spell Check status](https://github.com/arduino-libraries/Arduino_DebugUtils/actions/workflows/spell-check.yml/badge.svg)](https://github.com/arduino-libraries/Arduino_DebugUtils/actions/workflows/spell-check.yml) This class provides functionality useful for debugging sketches via `printf`-style statements. From d5471eb266e20f818d31b379c4d6cfd52bf82ba2 Mon Sep 17 00:00:00 2001 From: per1234 Date: Sun, 11 Apr 2021 04:00:18 -0700 Subject: [PATCH 27/60] Report changes in memory usage that would result from merging a PR On creation or commit to a pull request, a report of the resulting change in memory usage of the examples will be commented to the PR thread. --- .github/workflows/compile-examples.yml | 12 ++++++++++++ .github/workflows/report-size-deltas.yml | 24 ++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 .github/workflows/report-size-deltas.yml diff --git a/.github/workflows/compile-examples.yml b/.github/workflows/compile-examples.yml index 9032dfb..746839e 100644 --- a/.github/workflows/compile-examples.yml +++ b/.github/workflows/compile-examples.yml @@ -23,6 +23,9 @@ jobs: name: ${{ matrix.board.fqbn }} runs-on: ubuntu-latest + env: + SKETCHES_REPORTS_PATH: sketches-reports + strategy: fail-fast: false @@ -99,3 +102,12 @@ jobs: sketch-paths: | - examples/Arduino_Debug_Basic ${{ matrix.sketch-paths }} + enable-deltas-report: true + sketches-report-path: ${{ env.SKETCHES_REPORTS_PATH }} + + - name: Save sketches report as workflow artifact + uses: actions/upload-artifact@v2 + with: + if-no-files-found: error + path: ${{ env.SKETCHES_REPORTS_PATH }} + name: ${{ env.SKETCHES_REPORTS_PATH }} diff --git a/.github/workflows/report-size-deltas.yml b/.github/workflows/report-size-deltas.yml new file mode 100644 index 0000000..652be5d --- /dev/null +++ b/.github/workflows/report-size-deltas.yml @@ -0,0 +1,24 @@ +name: Report Size Deltas + +# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows +on: + push: + paths: + - ".github/workflows/report-size-deltas.yml" + schedule: + # Run at the minimum interval allowed by GitHub Actions. + # Note: GitHub Actions periodically has outages which result in workflow failures. + # In this event, the workflows will start passing again once the service recovers. + - cron: "*/5 * * * *" + workflow_dispatch: + repository_dispatch: + +jobs: + report: + runs-on: ubuntu-latest + steps: + - name: Comment size deltas reports to PRs + uses: arduino/report-size-deltas@v1 + with: + # The name of the workflow artifact created by the sketch compilation workflow + sketches-reports-source: sketches-reports From adc39b30306cf216d35818deb07410b99c23478e Mon Sep 17 00:00:00 2001 From: Alexander Entinger Date: Wed, 30 Jun 2021 05:48:57 +0200 Subject: [PATCH 28/60] Fix: va_start(va_list ap, paramN) needs to be parametrized with the latest named parameter in the parameter list. (#13) --- src/Arduino_DebugUtils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Arduino_DebugUtils.cpp b/src/Arduino_DebugUtils.cpp index f1f9440..c467a78 100644 --- a/src/Arduino_DebugUtils.cpp +++ b/src/Arduino_DebugUtils.cpp @@ -83,7 +83,7 @@ void Arduino_DebugUtils::print(int const debug_level, const __FlashStringHelper String fmt_str(fmt); va_list args; - va_start(args, fmt_str.c_str()); + va_start(args, fmt); vPrint(fmt_str.c_str(), args); va_end(args); } From f84108b8df5f232e3e2023db3018e485a034bf5e Mon Sep 17 00:00:00 2001 From: per1234 Date: Mon, 10 Jan 2022 01:06:32 -0800 Subject: [PATCH 29/60] Add GitHub Actions workflow to synchronize with shared repository labels (#16) On every push that changes relevant files, and periodically, configure the repository's issue and pull request labels according to the universal, shared, and local label configuration files. --- .github/dependabot.yml | 2 + .github/workflows/sync-labels.yml | 138 ++++++++++++++++++++++++++++++ 2 files changed, 140 insertions(+) create mode 100644 .github/workflows/sync-labels.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 03600dd..fa738ec 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -8,3 +8,5 @@ updates: directory: / # Check the repository's workflows under /.github/workflows/ schedule: interval: daily + labels: + - "topic: infrastructure" diff --git a/.github/workflows/sync-labels.yml b/.github/workflows/sync-labels.yml new file mode 100644 index 0000000..3ee6feb --- /dev/null +++ b/.github/workflows/sync-labels.yml @@ -0,0 +1,138 @@ +# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/sync-labels.md +name: Sync Labels + +# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows +on: + push: + paths: + - ".github/workflows/sync-labels.ya?ml" + - ".github/label-configuration-files/*.ya?ml" + pull_request: + paths: + - ".github/workflows/sync-labels.ya?ml" + - ".github/label-configuration-files/*.ya?ml" + schedule: + # Run daily at 8 AM UTC to sync with changes to shared label configurations. + - cron: "0 8 * * *" + workflow_dispatch: + repository_dispatch: + +env: + CONFIGURATIONS_FOLDER: .github/label-configuration-files + CONFIGURATIONS_ARTIFACT: label-configuration-files + +jobs: + check: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Download JSON schema for labels configuration file + id: download-schema + uses: carlosperate/download-file-action@v1 + with: + file-url: https://raw.githubusercontent.com/arduino/tooling-project-assets/main/workflow-templates/assets/sync-labels/arduino-tooling-gh-label-configuration-schema.json + location: ${{ runner.temp }}/label-configuration-schema + + - name: Install JSON schema validator + run: | + sudo npm install \ + --global \ + ajv-cli \ + ajv-formats + + - name: Validate local labels configuration + run: | + # See: https://github.com/ajv-validator/ajv-cli#readme + ajv validate \ + --all-errors \ + -c ajv-formats \ + -s "${{ steps.download-schema.outputs.file-path }}" \ + -d "${{ env.CONFIGURATIONS_FOLDER }}/*.{yml,yaml}" + + download: + needs: check + runs-on: ubuntu-latest + + strategy: + matrix: + filename: + # Filenames of the shared configurations to apply to the repository in addition to the local configuration. + # https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/sync-labels + - universal.yml + + steps: + - name: Download + uses: carlosperate/download-file-action@v1 + with: + file-url: https://raw.githubusercontent.com/arduino/tooling-project-assets/main/workflow-templates/assets/sync-labels/${{ matrix.filename }} + + - name: Pass configuration files to next job via workflow artifact + uses: actions/upload-artifact@v2 + with: + path: | + *.yaml + *.yml + if-no-files-found: error + name: ${{ env.CONFIGURATIONS_ARTIFACT }} + + sync: + needs: download + runs-on: ubuntu-latest + + steps: + - name: Set environment variables + run: | + # See: https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable + echo "MERGED_CONFIGURATION_PATH=${{ runner.temp }}/labels.yml" >> "$GITHUB_ENV" + + - name: Determine whether to dry run + id: dry-run + if: > + github.event_name == 'pull_request' || + ( + ( + github.event_name == 'push' || + github.event_name == 'workflow_dispatch' + ) && + github.ref != format('refs/heads/{0}', github.event.repository.default_branch) + ) + run: | + # Use of this flag in the github-label-sync command will cause it to only check the validity of the + # configuration. + echo "::set-output name=flag::--dry-run" + + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Download configuration files artifact + uses: actions/download-artifact@v2 + with: + name: ${{ env.CONFIGURATIONS_ARTIFACT }} + path: ${{ env.CONFIGURATIONS_FOLDER }} + + - name: Remove unneeded artifact + uses: geekyeggo/delete-artifact@v1 + with: + name: ${{ env.CONFIGURATIONS_ARTIFACT }} + + - name: Merge label configuration files + run: | + # Merge all configuration files + shopt -s extglob + cat "${{ env.CONFIGURATIONS_FOLDER }}"/*.@(yml|yaml) > "${{ env.MERGED_CONFIGURATION_PATH }}" + + - name: Install github-label-sync + run: sudo npm install --global github-label-sync + + - name: Sync labels + env: + GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + # See: https://github.com/Financial-Times/github-label-sync + github-label-sync \ + --labels "${{ env.MERGED_CONFIGURATION_PATH }}" \ + ${{ steps.dry-run.outputs.flag }} \ + ${{ github.repository }} From 270c73ef71427a4e14f71f38722e4d2ecd01216a Mon Sep 17 00:00:00 2001 From: john Date: Fri, 18 Feb 2022 10:41:30 -0600 Subject: [PATCH 30/60] add "newlineOn" and "newlineOff" methods --- README.md | 20 ++++++++++++++++++++ src/Arduino_DebugUtils.cpp | 15 ++++++++++++++- src/Arduino_DebugUtils.h | 4 ++++ 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5156760..8f08544 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,26 @@ Debug.timestampOff(); Debug.print(DBG_VERBOSE, "i = %d", i); //Output looks like : i = 21 ``` +### Debug.newlineOn() : +Calling this function ensures that a newline will be sent at the end of the `Debug.print()` function call; +By default, a newline is sent +Return type: void. + +Example: +``` +Debug.newlineOn(); +``` + +### Debug.newlineOff() : +Calling this function ensure that a newline will NOT be sent at the end of the `Debug.print()` function call; +By default a newline is sent. Call this to shut that functionality off. +Return type: void. + +Example: +``` +Debug.timestampOff(); +``` + ### 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). diff --git a/src/Arduino_DebugUtils.cpp b/src/Arduino_DebugUtils.cpp index c467a78..b1e3e75 100644 --- a/src/Arduino_DebugUtils.cpp +++ b/src/Arduino_DebugUtils.cpp @@ -34,6 +34,7 @@ static Stream * DEFAULT_OUTPUT_STREAM = &Serial; Arduino_DebugUtils::Arduino_DebugUtils() { timestampOff(); + newlineOn(); setDebugLevel(DEFAULT_DEBUG_LEVEL); setDebugOutputStream(DEFAULT_OUTPUT_STREAM); } @@ -50,6 +51,14 @@ void Arduino_DebugUtils::setDebugOutputStream(Stream * stream) { _debug_output_stream = stream; } +void Arduino_DebugUtils::newlineOn() { + _newline_on = true; +} + +void Arduino_DebugUtils::newlineOff() { + _newline_on = false; +} + void Arduino_DebugUtils::timestampOn() { _timestamp_on = true; } @@ -98,7 +107,11 @@ void Arduino_DebugUtils::vPrint(char const * fmt, va_list args) { vsnprintf(msg_buf, MSG_BUF_SIZE, fmt, args); - _debug_output_stream->println(msg_buf); + if (_newline_on) { + _debug_output_stream->println(msg_buf); + } else { + _debug_output_stream->print(msg_buf); + } } void Arduino_DebugUtils::printTimestamp() diff --git a/src/Arduino_DebugUtils.h b/src/Arduino_DebugUtils.h index a44b5ac..b759534 100644 --- a/src/Arduino_DebugUtils.h +++ b/src/Arduino_DebugUtils.h @@ -56,6 +56,9 @@ class Arduino_DebugUtils { void timestampOn(); void timestampOff(); + void newlineOn(); + void newlineOff(); + void print(int const debug_level, const char * fmt, ...); void print(int const debug_level, const __FlashStringHelper * fmt, ...); @@ -63,6 +66,7 @@ class Arduino_DebugUtils { private: bool _timestamp_on; + bool _newline_on; int _debug_level; Stream * _debug_output_stream; From 05eda1a406b520cb8d5868bd216707fbec58448b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 2 Mar 2022 12:11:12 +0000 Subject: [PATCH 31/60] Bump actions/checkout from 2 to 3 Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 3. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v2...v3) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/check-arduino.yml | 2 +- .github/workflows/compile-examples.yml | 2 +- .github/workflows/spell-check.yml | 2 +- .github/workflows/sync-labels.yml | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/check-arduino.yml b/.github/workflows/check-arduino.yml index 0d969f6..3e0d26c 100644 --- a/.github/workflows/check-arduino.yml +++ b/.github/workflows/check-arduino.yml @@ -16,7 +16,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Arduino Lint uses: arduino/arduino-lint-action@v1 diff --git a/.github/workflows/compile-examples.yml b/.github/workflows/compile-examples.yml index 746839e..753b6a6 100644 --- a/.github/workflows/compile-examples.yml +++ b/.github/workflows/compile-examples.yml @@ -86,7 +86,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Compile examples uses: arduino/compile-sketches@v1 diff --git a/.github/workflows/spell-check.yml b/.github/workflows/spell-check.yml index 01bee87..3f6b03f 100644 --- a/.github/workflows/spell-check.yml +++ b/.github/workflows/spell-check.yml @@ -16,7 +16,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Spell check uses: codespell-project/actions-codespell@master diff --git a/.github/workflows/sync-labels.yml b/.github/workflows/sync-labels.yml index 3ee6feb..4ea5755 100644 --- a/.github/workflows/sync-labels.yml +++ b/.github/workflows/sync-labels.yml @@ -27,7 +27,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Download JSON schema for labels configuration file id: download-schema @@ -105,7 +105,7 @@ jobs: echo "::set-output name=flag::--dry-run" - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Download configuration files artifact uses: actions/download-artifact@v2 From 6300e09966bf79b116eef379c5840b22108fb35c Mon Sep 17 00:00:00 2001 From: Abhay D Date: Fri, 18 Mar 2022 23:20:18 -0700 Subject: [PATCH 32/60] Remove hardcoded line limit --- src/Arduino_DebugUtils.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/Arduino_DebugUtils.cpp b/src/Arduino_DebugUtils.cpp index b1e3e75..327c44f 100644 --- a/src/Arduino_DebugUtils.cpp +++ b/src/Arduino_DebugUtils.cpp @@ -102,16 +102,27 @@ void Arduino_DebugUtils::print(int const debug_level, const __FlashStringHelper ******************************************************************************/ void Arduino_DebugUtils::vPrint(char const * fmt, va_list args) { - static size_t const MSG_BUF_SIZE = 120; - char msg_buf[MSG_BUF_SIZE] = {0}; + // calculate required buffer length + int msg_buf_size = vsnprintf(nullptr, 0, fmt, args) + 1; // add one for null terminator +#if __STDC_NO_VLA__ == 1 + // in the rare case where VLA is not allowed by compiler, fall back on heap-allocated memory + char * msg_buf = new char[msg_buf_size]; +#else + char msg_buf[msg_buf_size] = {0}; +#endif - vsnprintf(msg_buf, MSG_BUF_SIZE, fmt, args); + vsnprintf(msg_buf, msg_buf_size, fmt, args); if (_newline_on) { _debug_output_stream->println(msg_buf); } else { _debug_output_stream->print(msg_buf); } + +#if __STDC_NO_VLA__ == 1 + // remember to clean up memory + delete[] msg_buf; +#endif } void Arduino_DebugUtils::printTimestamp() From 0f3038ba721f0ecee722f20f7d6f9cbe76ce784f Mon Sep 17 00:00:00 2001 From: Abhay D Date: Fri, 18 Mar 2022 23:44:03 -0700 Subject: [PATCH 33/60] Fix compiler error --- src/Arduino_DebugUtils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Arduino_DebugUtils.cpp b/src/Arduino_DebugUtils.cpp index 327c44f..7111715 100644 --- a/src/Arduino_DebugUtils.cpp +++ b/src/Arduino_DebugUtils.cpp @@ -108,7 +108,7 @@ void Arduino_DebugUtils::vPrint(char const * fmt, va_list args) { // in the rare case where VLA is not allowed by compiler, fall back on heap-allocated memory char * msg_buf = new char[msg_buf_size]; #else - char msg_buf[msg_buf_size] = {0}; + char msg_buf[msg_buf_size]; #endif vsnprintf(msg_buf, msg_buf_size, fmt, args); From 941538f03689e1c71dd64d4f7d7740a5122db2bf Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Apr 2022 12:35:14 +0000 Subject: [PATCH 34/60] Bump actions/download-artifact from 2 to 3 Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 2 to 3. - [Release notes](https://github.com/actions/download-artifact/releases) - [Commits](https://github.com/actions/download-artifact/compare/v2...v3) --- updated-dependencies: - dependency-name: actions/download-artifact dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/sync-labels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sync-labels.yml b/.github/workflows/sync-labels.yml index 4ea5755..e84e803 100644 --- a/.github/workflows/sync-labels.yml +++ b/.github/workflows/sync-labels.yml @@ -108,7 +108,7 @@ jobs: uses: actions/checkout@v3 - name: Download configuration files artifact - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v3 with: name: ${{ env.CONFIGURATIONS_ARTIFACT }} path: ${{ env.CONFIGURATIONS_FOLDER }} From d7f602cba19c7cc439907cc81c15f5dca7cf338b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Apr 2022 12:35:17 +0000 Subject: [PATCH 35/60] Bump actions/upload-artifact from 2 to 3 Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 2 to 3. - [Release notes](https://github.com/actions/upload-artifact/releases) - [Commits](https://github.com/actions/upload-artifact/compare/v2...v3) --- updated-dependencies: - dependency-name: actions/upload-artifact dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/compile-examples.yml | 2 +- .github/workflows/sync-labels.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/compile-examples.yml b/.github/workflows/compile-examples.yml index 753b6a6..b880357 100644 --- a/.github/workflows/compile-examples.yml +++ b/.github/workflows/compile-examples.yml @@ -106,7 +106,7 @@ jobs: sketches-report-path: ${{ env.SKETCHES_REPORTS_PATH }} - name: Save sketches report as workflow artifact - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: if-no-files-found: error path: ${{ env.SKETCHES_REPORTS_PATH }} diff --git a/.github/workflows/sync-labels.yml b/.github/workflows/sync-labels.yml index 4ea5755..1d969d5 100644 --- a/.github/workflows/sync-labels.yml +++ b/.github/workflows/sync-labels.yml @@ -70,7 +70,7 @@ jobs: file-url: https://raw.githubusercontent.com/arduino/tooling-project-assets/main/workflow-templates/assets/sync-labels/${{ matrix.filename }} - name: Pass configuration files to next job via workflow artifact - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: path: | *.yaml From 11c1385250ce81b82213d016a420f05bd0a8e747 Mon Sep 17 00:00:00 2001 From: Alexander Entinger Date: Wed, 15 Jun 2022 06:49:31 +0200 Subject: [PATCH 36/60] Release v1.2.0. --- library.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library.properties b/library.properties index 30c17d8..8bbc786 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Arduino_DebugUtils -version=1.1.0 +version=1.2.0 author=Arduino maintainer=Arduino sentence=Debugging module with different debug levels, timestamps and printf-style output. From bfce1fed45ece0693d2481a3da5c926c5f7cc52e Mon Sep 17 00:00:00 2001 From: Alexander Entinger Date: Wed, 22 Jun 2022 10:33:20 +0200 Subject: [PATCH 37/60] Adding API to retrieve the debug level. (#24) This fixes #14. --- src/Arduino_DebugUtils.cpp | 9 +++++++++ src/Arduino_DebugUtils.h | 2 ++ 2 files changed, 11 insertions(+) diff --git a/src/Arduino_DebugUtils.cpp b/src/Arduino_DebugUtils.cpp index 7111715..c8df64d 100644 --- a/src/Arduino_DebugUtils.cpp +++ b/src/Arduino_DebugUtils.cpp @@ -47,6 +47,10 @@ void Arduino_DebugUtils::setDebugLevel(int const debug_level) { _debug_level = debug_level; } +int Arduino_DebugUtils::getDebugLevel() const { + return _debug_level; +} + void Arduino_DebugUtils::setDebugOutputStream(Stream * stream) { _debug_output_stream = stream; } @@ -142,6 +146,11 @@ bool Arduino_DebugUtils::shouldPrint(int const debug_level) const ******************************************************************************/ Arduino_DebugUtils Debug; + void setDebugMessageLevel(int const debug_level) { Debug.setDebugLevel(debug_level); } + +int getDebugMessageLevel() { + return Debug.getDebugLevel(); +} diff --git a/src/Arduino_DebugUtils.h b/src/Arduino_DebugUtils.h index b759534..af04022 100644 --- a/src/Arduino_DebugUtils.h +++ b/src/Arduino_DebugUtils.h @@ -38,6 +38,7 @@ static int const DBG_DEBUG = 3; static int const DBG_VERBOSE = 4; void setDebugMessageLevel(int const debug_level); +int getDebugMessageLevel(); /****************************************************************************** CLASS DECLARATION @@ -50,6 +51,7 @@ class Arduino_DebugUtils { Arduino_DebugUtils(); void setDebugLevel(int const debug_level); + int getDebugLevel() const; void setDebugOutputStream(Stream * stream); From 7b07264ef29537ccb1633d67792983689b1e48a1 Mon Sep 17 00:00:00 2001 From: Alexander Entinger Date: Wed, 22 Jun 2022 13:35:01 +0200 Subject: [PATCH 38/60] Adding note explaining that there is no printf/float support on AVR. (#26) --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 8f08544..bd8dcd6 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,7 @@ int i = 1; float pi = 3.1459; Debug.print(DBG_VERBOSE, "i = %d, pi = %f", i, pi); ``` +**Note**: The output of floating point numbers (`%f`) does NOT work on [ArduinoCore-avr](https://github.com/arduino/ArduinoCore-avr). If desired, timestamps can be prefixed to the debug message. Timestamp output can be enabled and disabled via `timestampOn` and `timestampOff`. From c7eec9afdcdaef260c242035a23cd4bf73faeac7 Mon Sep 17 00:00:00 2001 From: Alexander Entinger Date: Wed, 22 Jun 2022 14:28:32 +0200 Subject: [PATCH 39/60] Provide API for printing the debug level as a string. (#27) This fixes #7. --- src/Arduino_DebugUtils.cpp | 33 +++++++++++++++++++++++++++++++++ src/Arduino_DebugUtils.h | 5 +++++ 2 files changed, 38 insertions(+) diff --git a/src/Arduino_DebugUtils.cpp b/src/Arduino_DebugUtils.cpp index c8df64d..e2818e5 100644 --- a/src/Arduino_DebugUtils.cpp +++ b/src/Arduino_DebugUtils.cpp @@ -35,6 +35,7 @@ static Stream * DEFAULT_OUTPUT_STREAM = &Serial; Arduino_DebugUtils::Arduino_DebugUtils() { timestampOff(); newlineOn(); + debugLabelOff(); setDebugLevel(DEFAULT_DEBUG_LEVEL); setDebugOutputStream(DEFAULT_OUTPUT_STREAM); } @@ -63,6 +64,14 @@ void Arduino_DebugUtils::newlineOff() { _newline_on = false; } +void Arduino_DebugUtils::debugLabelOn() { + _print_debug_label = true; +} + +void Arduino_DebugUtils::debugLabelOff() { + _print_debug_label = false; +} + void Arduino_DebugUtils::timestampOn() { _timestamp_on = true; } @@ -76,6 +85,9 @@ void Arduino_DebugUtils::print(int const debug_level, const char * fmt, ...) if (!shouldPrint(debug_level)) return; + if (_print_debug_label) + printDebugLabel(debug_level); + if (_timestamp_on) printTimestamp(); @@ -90,6 +102,9 @@ void Arduino_DebugUtils::print(int const debug_level, const __FlashStringHelper if (!shouldPrint(debug_level)) return; + if (_print_debug_label) + printDebugLabel(debug_level); + if (_timestamp_on) printTimestamp(); @@ -136,6 +151,24 @@ void Arduino_DebugUtils::printTimestamp() _debug_output_stream->print(timestamp); } +void Arduino_DebugUtils::printDebugLabel(int const debug_level) +{ + static char const * DEBUG_MODE_STRING[5] = + { + "[DBG_ERROR ] ", + "[DBG_WARNING] ", + "[DBG_INFO ] ", + "[DBG_DEBUG ] ", + "[DBG_VERBOSE] ", + }; + + bool is_valid_debug_level = (debug_level >= DBG_ERROR) && (debug_level <= DBG_VERBOSE); + if (!is_valid_debug_level) + return; + + _debug_output_stream->print(DEBUG_MODE_STRING[debug_level]); +} + bool Arduino_DebugUtils::shouldPrint(int const debug_level) const { return ((debug_level >= DBG_ERROR) && (debug_level <= DBG_VERBOSE) && (debug_level <= _debug_level)); diff --git a/src/Arduino_DebugUtils.h b/src/Arduino_DebugUtils.h index af04022..2fe7392 100644 --- a/src/Arduino_DebugUtils.h +++ b/src/Arduino_DebugUtils.h @@ -61,6 +61,9 @@ class Arduino_DebugUtils { void newlineOn(); void newlineOff(); + void debugLabelOn(); + void debugLabelOff(); + void print(int const debug_level, const char * fmt, ...); void print(int const debug_level, const __FlashStringHelper * fmt, ...); @@ -69,11 +72,13 @@ class Arduino_DebugUtils { bool _timestamp_on; bool _newline_on; + bool _print_debug_label; int _debug_level; Stream * _debug_output_stream; void vPrint(char const * fmt, va_list args); void printTimestamp(); + void printDebugLabel(int const debug_level); bool shouldPrint(int const debug_level) const; }; From 901abd1bb744c7d4c35a5b191cef9571f3f8e44f Mon Sep 17 00:00:00 2001 From: Alexander Entinger Date: Thu, 23 Jun 2022 06:51:02 +0200 Subject: [PATCH 40/60] Enable conditional formatting of timestamp. (#28) This fixes #5. --- src/Arduino_DebugUtils.cpp | 44 ++++++++++++++++++++++++++++++++++++-- src/Arduino_DebugUtils.h | 4 ++++ 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/src/Arduino_DebugUtils.cpp b/src/Arduino_DebugUtils.cpp index e2818e5..3ffde7b 100644 --- a/src/Arduino_DebugUtils.cpp +++ b/src/Arduino_DebugUtils.cpp @@ -36,6 +36,7 @@ Arduino_DebugUtils::Arduino_DebugUtils() { timestampOff(); newlineOn(); debugLabelOff(); + formatTimestampOff(); setDebugLevel(DEFAULT_DEBUG_LEVEL); setDebugOutputStream(DEFAULT_OUTPUT_STREAM); } @@ -72,6 +73,14 @@ void Arduino_DebugUtils::debugLabelOff() { _print_debug_label = false; } +void Arduino_DebugUtils::formatTimestampOn() { + _format_timestamp_on = true; +} + +void Arduino_DebugUtils::formatTimestampOff() { + _format_timestamp_on = false; +} + void Arduino_DebugUtils::timestampOn() { _timestamp_on = true; } @@ -146,8 +155,39 @@ void Arduino_DebugUtils::vPrint(char const * fmt, va_list args) { void Arduino_DebugUtils::printTimestamp() { - char timestamp[20]; - snprintf(timestamp, 20, "[ %lu ] ", millis()); + char timestamp[32]; + + if (_format_timestamp_on) + { + auto const msCount = millis(); + + uint16_t const milliseconds = msCount % 1000; // ms remaining when converted to seconds + uint16_t const allSeconds = msCount / 1000; // total number of seconds to calculate remaining values + + uint16_t const hours = allSeconds / 3600; // convert seconds to hours + uint16_t const secondsRemaining = allSeconds % 3600; // seconds left over + + uint16_t const minutes = secondsRemaining / 60 ; // convert seconds left over to minutes + uint16_t const seconds = secondsRemaining % 60; // seconds left over + + snprintf(timestamp, sizeof(timestamp), // "prints" formatted output to a char array (string) + "[ " + "%02d:" //HH: + "%02d:" //MM: + "%02d." //SS. + "%03d" //MMM + " ] ", + hours, + minutes, + seconds, + milliseconds + ); + } + else + { + snprintf(timestamp, sizeof(timestamp), "[ %lu ] ", millis()); + } + _debug_output_stream->print(timestamp); } diff --git a/src/Arduino_DebugUtils.h b/src/Arduino_DebugUtils.h index 2fe7392..335f1c5 100644 --- a/src/Arduino_DebugUtils.h +++ b/src/Arduino_DebugUtils.h @@ -64,6 +64,9 @@ class Arduino_DebugUtils { void debugLabelOn(); void debugLabelOff(); + void formatTimestampOn(); + void formatTimestampOff(); + void print(int const debug_level, const char * fmt, ...); void print(int const debug_level, const __FlashStringHelper * fmt, ...); @@ -73,6 +76,7 @@ class Arduino_DebugUtils { bool _timestamp_on; bool _newline_on; bool _print_debug_label; + bool _format_timestamp_on; int _debug_level; Stream * _debug_output_stream; From 8bfebae5a78f9f6e66cb6ed540aaded0c548a151 Mon Sep 17 00:00:00 2001 From: Alexander Entinger Date: Thu, 23 Jun 2022 06:51:51 +0200 Subject: [PATCH 41/60] Release v1.3.0. --- library.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library.properties b/library.properties index 8bbc786..c1099ca 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Arduino_DebugUtils -version=1.2.0 +version=1.3.0 author=Arduino maintainer=Arduino sentence=Debugging module with different debug levels, timestamps and printf-style output. From a814b8b65b6e03220e5aab14b41a354ffba16fea Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 13 Oct 2022 12:09:23 +0000 Subject: [PATCH 42/60] Bump geekyeggo/delete-artifact from 1 to 2 Bumps [geekyeggo/delete-artifact](https://github.com/geekyeggo/delete-artifact) from 1 to 2. - [Release notes](https://github.com/geekyeggo/delete-artifact/releases) - [Commits](https://github.com/geekyeggo/delete-artifact/compare/v1...v2) --- updated-dependencies: - dependency-name: geekyeggo/delete-artifact dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/sync-labels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sync-labels.yml b/.github/workflows/sync-labels.yml index 986bda6..10abaea 100644 --- a/.github/workflows/sync-labels.yml +++ b/.github/workflows/sync-labels.yml @@ -114,7 +114,7 @@ jobs: path: ${{ env.CONFIGURATIONS_FOLDER }} - name: Remove unneeded artifact - uses: geekyeggo/delete-artifact@v1 + uses: geekyeggo/delete-artifact@v2 with: name: ${{ env.CONFIGURATIONS_ARTIFACT }} From 086b772e68fff1d5e1a18655322331b5bda1e709 Mon Sep 17 00:00:00 2001 From: Alexander Entinger Date: Mon, 17 Oct 2022 13:33:08 +0200 Subject: [PATCH 43/60] Ignore .vscode folder. --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..687f872 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.vscode/ + From da94c6b85906036e61f1ae94d4c1a7b188a6ff13 Mon Sep 17 00:00:00 2001 From: Alexander Entinger Date: Mon, 17 Oct 2022 13:35:44 +0200 Subject: [PATCH 44/60] Use debug macros instead of using the longform access via instantiated object. --- .../Arduino_Debug_Advance.ino | 2 +- .../Arduino_Debug_Basic.ino | 2 +- src/Arduino_DebugUtils.h | 24 +++++++++++++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/examples/Arduino_Debug_Advance/Arduino_Debug_Advance.ino b/examples/Arduino_Debug_Advance/Arduino_Debug_Advance.ino index 5837b52..2138601 100644 --- a/examples/Arduino_Debug_Advance/Arduino_Debug_Advance.ino +++ b/examples/Arduino_Debug_Advance/Arduino_Debug_Advance.ino @@ -24,7 +24,7 @@ void setup() { int i = 0; void loop() { - Debug.print(DBG_VERBOSE, "i = %d", i); + DBG_VERBOSE("i = %d", i); i++; delay(1000); } diff --git a/examples/Arduino_Debug_Basic/Arduino_Debug_Basic.ino b/examples/Arduino_Debug_Basic/Arduino_Debug_Basic.ino index ddfedfe..03f0446 100644 --- a/examples/Arduino_Debug_Basic/Arduino_Debug_Basic.ino +++ b/examples/Arduino_Debug_Basic/Arduino_Debug_Basic.ino @@ -8,7 +8,7 @@ void setup() { int i = 0; void loop() { - Debug.print(DBG_INFO, "i = %d", i); + DBG_INFO("i = %d", i); i++; delay(1000); } diff --git a/src/Arduino_DebugUtils.h b/src/Arduino_DebugUtils.h index 335f1c5..635c72e 100644 --- a/src/Arduino_DebugUtils.h +++ b/src/Arduino_DebugUtils.h @@ -93,4 +93,28 @@ class Arduino_DebugUtils { extern Arduino_DebugUtils Debug; +/************************************************************************************** + * DEFINE + **************************************************************************************/ + +#ifndef DBG_ERROR +# define DBG_ERROR(fmt, ...) Debug.print(DBG_ERROR, fmt, ## __VA_ARGS__) +#endif + +#ifndef DBG_WARNING +# define DBG_WARNING(fmt, ...) Debug.print(DBG_WARNING, fmt, ## __VA_ARGS__) +#endif + +#ifndef DBG_INFO +# define DBG_INFO(fmt, ...) Debug.print(DBG_INFO, fmt, ## __VA_ARGS__) +#endif + +#ifndef DBG_DEBUG +# define DBG_DEBUG(fmt, ...) Debug.print(DBG_DEBUG, fmt, ## __VA_ARGS__) +#endif + +#ifndef DBG_VERBOSE +# define DBG_VERBOSE(fmt, ...) Debug.print(DBG_VERBOSE, fmt, ## __VA_ARGS__) +#endif + #endif /* ARDUINO_DEBUG_UTILS_H_ */ From 53f1679bbeedbd0322d1251959ab292233a5a67c Mon Sep 17 00:00:00 2001 From: Alexander Entinger Date: Mon, 17 Oct 2022 13:43:24 +0200 Subject: [PATCH 45/60] Rename DBG_* to DEBUG_* to avoid a conflict with the similiarly defined constants. --- .../Arduino_Debug_Advance.ino | 2 +- .../Arduino_Debug_Basic.ino | 2 +- src/Arduino_DebugUtils.h | 20 +++++++++---------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/examples/Arduino_Debug_Advance/Arduino_Debug_Advance.ino b/examples/Arduino_Debug_Advance/Arduino_Debug_Advance.ino index 2138601..dbc704c 100644 --- a/examples/Arduino_Debug_Advance/Arduino_Debug_Advance.ino +++ b/examples/Arduino_Debug_Advance/Arduino_Debug_Advance.ino @@ -24,7 +24,7 @@ void setup() { int i = 0; void loop() { - DBG_VERBOSE("i = %d", i); + DEBUG_VERBOSE("i = %d", i); i++; delay(1000); } diff --git a/examples/Arduino_Debug_Basic/Arduino_Debug_Basic.ino b/examples/Arduino_Debug_Basic/Arduino_Debug_Basic.ino index 03f0446..1806e90 100644 --- a/examples/Arduino_Debug_Basic/Arduino_Debug_Basic.ino +++ b/examples/Arduino_Debug_Basic/Arduino_Debug_Basic.ino @@ -8,7 +8,7 @@ void setup() { int i = 0; void loop() { - DBG_INFO("i = %d", i); + DEBUG_INFO("i = %d", i); i++; delay(1000); } diff --git a/src/Arduino_DebugUtils.h b/src/Arduino_DebugUtils.h index 635c72e..73e6287 100644 --- a/src/Arduino_DebugUtils.h +++ b/src/Arduino_DebugUtils.h @@ -97,24 +97,24 @@ extern Arduino_DebugUtils Debug; * DEFINE **************************************************************************************/ -#ifndef DBG_ERROR -# define DBG_ERROR(fmt, ...) Debug.print(DBG_ERROR, fmt, ## __VA_ARGS__) +#ifndef DEBUG_ERROR +# define DEBUG_ERROR(fmt, ...) Debug.print(DBG_ERROR, fmt, ## __VA_ARGS__) #endif -#ifndef DBG_WARNING -# define DBG_WARNING(fmt, ...) Debug.print(DBG_WARNING, fmt, ## __VA_ARGS__) +#ifndef DEBUG_WARNING +# define DEBUG_WARNING(fmt, ...) Debug.print(DBG_WARNING, fmt, ## __VA_ARGS__) #endif -#ifndef DBG_INFO -# define DBG_INFO(fmt, ...) Debug.print(DBG_INFO, fmt, ## __VA_ARGS__) +#ifndef DEBUG_INFO +# define DEBUG_INFO(fmt, ...) Debug.print(DBG_INFO, fmt, ## __VA_ARGS__) #endif -#ifndef DBG_DEBUG -# define DBG_DEBUG(fmt, ...) Debug.print(DBG_DEBUG, fmt, ## __VA_ARGS__) +#ifndef DEBUG_DEBUG +# define DEBUG_DEBUG(fmt, ...) Debug.print(DBG_DEBUG, fmt, ## __VA_ARGS__) #endif -#ifndef DBG_VERBOSE -# define DBG_VERBOSE(fmt, ...) Debug.print(DBG_VERBOSE, fmt, ## __VA_ARGS__) +#ifndef DEBUG_VERBOSE +# define DEBUG_VERBOSE(fmt, ...) Debug.print(DBG_VERBOSE, fmt, ## __VA_ARGS__) #endif #endif /* ARDUINO_DEBUG_UTILS_H_ */ From 3e93e8d403a02a1a5a29c8296e4dc9e17c04f45d Mon Sep 17 00:00:00 2001 From: Alexander Entinger Date: Mon, 17 Oct 2022 13:46:21 +0200 Subject: [PATCH 46/60] Update README showing macro usage. --- README.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index bd8dcd6..23ea200 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ Example: ```C++ int i = 1; float pi = 3.1459; -Debug.print(DBG_VERBOSE, "i = %d, pi = %f", i, pi); +DEBUG_VERBOSE("i = %d, pi = %f", i, pi); ``` **Note**: The output of floating point numbers (`%f`) does NOT work on [ArduinoCore-avr](https://github.com/arduino/ArduinoCore-avr). @@ -43,7 +43,7 @@ Parameter debug_level in order of lowest to highest priority are : `DBG_NONE`, ` Return type: void. Example: -``` +```C++ Debug.setDebugLevel(DBG_VERBOSE); ``` ### Debug.setDebugOutputStream(Stream * stream) : @@ -52,7 +52,7 @@ By default, Output Stream is Serial. In advanced cases other objects could be ot Return type: void. Example: -``` +```C++ SoftwareSerial mySerial(10, 11); // RX, TX Debug.setDebugOutputStream(&mySerial); ``` @@ -63,9 +63,9 @@ By default, printing timestamp is off, unless turned on using this function call Return type: void. Example: -``` +```C++ Debug.timestampOn(); -Debug.print(DBG_VERBOSE, "i = %d", i); //Output looks like : [ 21007 ] i = 21 +DBG_VERBOSE("i = %d", i); //Output looks like : [ 21007 ] i = 21 ``` ### Debug.timestampOff() : @@ -74,9 +74,9 @@ Calling this function switches off the timestamp in the `Debug.print()` function Return type: void. Example: -``` +```C++ Debug.timestampOff(); -Debug.print(DBG_VERBOSE, "i = %d", i); //Output looks like : i = 21 +DEBUG_VERBOSE("i = %d", i); //Output looks like : i = 21 ``` ### Debug.newlineOn() : @@ -85,7 +85,7 @@ By default, a newline is sent Return type: void. Example: -``` +```C++ Debug.newlineOn(); ``` @@ -95,7 +95,7 @@ By default a newline is sent. Call this to shut that functionality off. Return type: void. Example: -``` +```C++ Debug.timestampOff(); ``` @@ -106,8 +106,8 @@ This function prints the message if parameter `debug_level` in the `Debug.print( Return type: void. Example: -``` +```C++ Debug.setDebugLevel(DBG_VERBOSE); int i = 0; -Debug.print(DBG_VERBOSE, "DBG_VERBOSE i = %d", i); +DEBUG_VERBOSE("DBG_VERBOSE i = %d", i); ``` From 7b468684ab2d4c2d3f8d6a771ec6fd2978a6e417 Mon Sep 17 00:00:00 2001 From: Alexander Entinger Date: Mon, 17 Oct 2022 13:47:33 +0200 Subject: [PATCH 47/60] List DEBUG_* macros for correct syntax highlighting. --- keywords.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/keywords.txt b/keywords.txt index e5c2020..d175771 100644 --- a/keywords.txt +++ b/keywords.txt @@ -17,6 +17,11 @@ setDebugOutputStream KEYWORD2 timestampOn KEYWORD2 timestampOff KEYWORD2 print KEYWORD2 +DEBUG_ERROR KEYWORD2 +DEBUG_WARNING KEYWORD2 +DEBUG_INFO KEYWORD2 +DEBUG_DEBUG KEYWORD2 +DEBUG_VERBOSE KEYWORD2 ####################################### # Constants (LITERAL1) From 3d14d821f7f9cb42d3876abf5bebee9d9adcb35b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Oct 2022 12:09:25 +0000 Subject: [PATCH 48/60] Bump carlosperate/download-file-action from 1 to 2 Bumps [carlosperate/download-file-action](https://github.com/carlosperate/download-file-action) from 1 to 2. - [Release notes](https://github.com/carlosperate/download-file-action/releases) - [Commits](https://github.com/carlosperate/download-file-action/compare/v1...v2) --- updated-dependencies: - dependency-name: carlosperate/download-file-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/sync-labels.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sync-labels.yml b/.github/workflows/sync-labels.yml index 10abaea..94938f3 100644 --- a/.github/workflows/sync-labels.yml +++ b/.github/workflows/sync-labels.yml @@ -31,7 +31,7 @@ jobs: - name: Download JSON schema for labels configuration file id: download-schema - uses: carlosperate/download-file-action@v1 + uses: carlosperate/download-file-action@v2 with: file-url: https://raw.githubusercontent.com/arduino/tooling-project-assets/main/workflow-templates/assets/sync-labels/arduino-tooling-gh-label-configuration-schema.json location: ${{ runner.temp }}/label-configuration-schema @@ -65,7 +65,7 @@ jobs: steps: - name: Download - uses: carlosperate/download-file-action@v1 + uses: carlosperate/download-file-action@v2 with: file-url: https://raw.githubusercontent.com/arduino/tooling-project-assets/main/workflow-templates/assets/sync-labels/${{ matrix.filename }} From af1530c7da403998b96ee90b83532ff3a50dafd3 Mon Sep 17 00:00:00 2001 From: Alexander Entinger Date: Wed, 2 Nov 2022 09:23:12 +0100 Subject: [PATCH 49/60] Release v1.4.0. --- library.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library.properties b/library.properties index c1099ca..b59e2da 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Arduino_DebugUtils -version=1.3.0 +version=1.4.0 author=Arduino maintainer=Arduino sentence=Debugging module with different debug levels, timestamps and printf-style output. From 82a7bfeb255b3f8b122791e0f861941b86c136ff Mon Sep 17 00:00:00 2001 From: Alexander Entinger Date: Fri, 10 Mar 2023 12:03:13 +0100 Subject: [PATCH 50/60] Fix: envie_m4 is no longer a valid FQBN. (#34) --- .github/workflows/compile-examples.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/compile-examples.yml b/.github/workflows/compile-examples.yml index b880357..32ef392 100644 --- a/.github/workflows/compile-examples.yml +++ b/.github/workflows/compile-examples.yml @@ -55,7 +55,7 @@ jobs: platforms: | - name: arduino:samd softwareserial: false - - fqbn: arduino:mbed_portenta:envie_m4 + - fqbn: arduino:mbed_portenta:envie_m7:target_core=cm4 platforms: | - name: arduino:mbed_portenta softwareserial: false From 23e9b52ecde6088205931557bf97f6e566260389 Mon Sep 17 00:00:00 2001 From: pennam Date: Tue, 25 Jul 2023 10:27:01 +0200 Subject: [PATCH 51/60] CI: Add new boards to compile examples workflow --- .github/workflows/compile-examples.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/.github/workflows/compile-examples.yml b/.github/workflows/compile-examples.yml index 32ef392..0023a34 100644 --- a/.github/workflows/compile-examples.yml +++ b/.github/workflows/compile-examples.yml @@ -71,6 +71,30 @@ jobs: platforms: | - name: arduino:mbed_nano softwareserial: false + - fqbn: arduino:mbed_nicla:nicla_vision + platforms: | + - name: arduino:mbed_nicla + softwareserial: false + - fqbn: arduino:mbed_opta:opta + platforms: | + - name: arduino:mbed_opta + softwareserial: false + - fqbn: arduino:mbed_giga:giga + platforms: | + - name: arduino:mbed_giga + softwareserial: false + - fqbn: arduino:renesas_portenta:portenta_c33 + platforms: | + - name: arduino:renesas_portenta + softwareserial: false + - fqbn: arduino:renesas_uno:unor4wifi + platforms: | + - name: arduino:renesas_uno + softwareserial: false + - fqbn: arduino:esp32:nano_nora + platforms: | + - name: arduino:esp32 + softwareserial: false # Make board type-specific customizations to the matrix jobs include: From 1e835928d70cdc4eafeeb19b364245f58090de47 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Sep 2023 12:40:16 +0000 Subject: [PATCH 52/60] Bump actions/checkout from 3 to 4 Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/check-arduino.yml | 2 +- .github/workflows/compile-examples.yml | 2 +- .github/workflows/spell-check.yml | 2 +- .github/workflows/sync-labels.yml | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/check-arduino.yml b/.github/workflows/check-arduino.yml index 3e0d26c..adb330f 100644 --- a/.github/workflows/check-arduino.yml +++ b/.github/workflows/check-arduino.yml @@ -16,7 +16,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Arduino Lint uses: arduino/arduino-lint-action@v1 diff --git a/.github/workflows/compile-examples.yml b/.github/workflows/compile-examples.yml index 0023a34..93e5f39 100644 --- a/.github/workflows/compile-examples.yml +++ b/.github/workflows/compile-examples.yml @@ -110,7 +110,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Compile examples uses: arduino/compile-sketches@v1 diff --git a/.github/workflows/spell-check.yml b/.github/workflows/spell-check.yml index 3f6b03f..ef7d894 100644 --- a/.github/workflows/spell-check.yml +++ b/.github/workflows/spell-check.yml @@ -16,7 +16,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Spell check uses: codespell-project/actions-codespell@master diff --git a/.github/workflows/sync-labels.yml b/.github/workflows/sync-labels.yml index 94938f3..9cde1ac 100644 --- a/.github/workflows/sync-labels.yml +++ b/.github/workflows/sync-labels.yml @@ -27,7 +27,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Download JSON schema for labels configuration file id: download-schema @@ -105,7 +105,7 @@ jobs: echo "::set-output name=flag::--dry-run" - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Download configuration files artifact uses: actions/download-artifact@v3 From 6ebae165d0aa464402a434bfca4d967e33cd5f80 Mon Sep 17 00:00:00 2001 From: Oleg Obolenskiy Date: Mon, 8 Jan 2024 09:43:49 +0300 Subject: [PATCH 53/60] fix vPrint crashes on platforms where vsnprintf invalidates va_list, in particular on epoxyduino (#40) Co-authored-by: olegobolenskiy --- src/Arduino_DebugUtils.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Arduino_DebugUtils.cpp b/src/Arduino_DebugUtils.cpp index 3ffde7b..270927b 100644 --- a/src/Arduino_DebugUtils.cpp +++ b/src/Arduino_DebugUtils.cpp @@ -130,6 +130,10 @@ void Arduino_DebugUtils::print(int const debug_level, const __FlashStringHelper ******************************************************************************/ void Arduino_DebugUtils::vPrint(char const * fmt, va_list args) { + + va_list args_copy; + va_copy(args_copy, args); + // calculate required buffer length int msg_buf_size = vsnprintf(nullptr, 0, fmt, args) + 1; // add one for null terminator #if __STDC_NO_VLA__ == 1 @@ -139,7 +143,8 @@ void Arduino_DebugUtils::vPrint(char const * fmt, va_list args) { char msg_buf[msg_buf_size]; #endif - vsnprintf(msg_buf, msg_buf_size, fmt, args); + vsnprintf(msg_buf, msg_buf_size, fmt, args_copy); + va_end(args_copy); if (_newline_on) { _debug_output_stream->println(msg_buf); From 806d96ebe0ef235dce5af207fd1d642d467963c0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 29 Feb 2024 05:38:00 +0100 Subject: [PATCH 54/60] Bump actions/upload-artifact from 3 to 4 (#37) Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 3 to 4. - [Release notes](https://github.com/actions/upload-artifact/releases) - [Commits](https://github.com/actions/upload-artifact/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/upload-artifact dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/compile-examples.yml | 2 +- .github/workflows/sync-labels.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/compile-examples.yml b/.github/workflows/compile-examples.yml index 93e5f39..5686ce5 100644 --- a/.github/workflows/compile-examples.yml +++ b/.github/workflows/compile-examples.yml @@ -130,7 +130,7 @@ jobs: sketches-report-path: ${{ env.SKETCHES_REPORTS_PATH }} - name: Save sketches report as workflow artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: if-no-files-found: error path: ${{ env.SKETCHES_REPORTS_PATH }} diff --git a/.github/workflows/sync-labels.yml b/.github/workflows/sync-labels.yml index 9cde1ac..7680b37 100644 --- a/.github/workflows/sync-labels.yml +++ b/.github/workflows/sync-labels.yml @@ -70,7 +70,7 @@ jobs: file-url: https://raw.githubusercontent.com/arduino/tooling-project-assets/main/workflow-templates/assets/sync-labels/${{ matrix.filename }} - name: Pass configuration files to next job via workflow artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: path: | *.yaml From 0ba07ae107a995a27f92b4dafe120a2fcd743871 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 29 Feb 2024 05:38:13 +0100 Subject: [PATCH 55/60] Bump actions/download-artifact from 3 to 4 (#38) Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 3 to 4. - [Release notes](https://github.com/actions/download-artifact/releases) - [Commits](https://github.com/actions/download-artifact/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/download-artifact dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/sync-labels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sync-labels.yml b/.github/workflows/sync-labels.yml index 7680b37..2e1d6e0 100644 --- a/.github/workflows/sync-labels.yml +++ b/.github/workflows/sync-labels.yml @@ -108,7 +108,7 @@ jobs: uses: actions/checkout@v4 - name: Download configuration files artifact - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: ${{ env.CONFIGURATIONS_ARTIFACT }} path: ${{ env.CONFIGURATIONS_FOLDER }} From 91bfa40636121b6d45836aa75403543118f2d6bd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 29 Feb 2024 05:38:26 +0100 Subject: [PATCH 56/60] Bump geekyeggo/delete-artifact from 2 to 4 (#39) Bumps [geekyeggo/delete-artifact](https://github.com/geekyeggo/delete-artifact) from 2 to 4. - [Release notes](https://github.com/geekyeggo/delete-artifact/releases) - [Changelog](https://github.com/GeekyEggo/delete-artifact/blob/main/CHANGELOG.md) - [Commits](https://github.com/geekyeggo/delete-artifact/compare/v2...v4) --- updated-dependencies: - dependency-name: geekyeggo/delete-artifact dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/sync-labels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sync-labels.yml b/.github/workflows/sync-labels.yml index 2e1d6e0..47ac50a 100644 --- a/.github/workflows/sync-labels.yml +++ b/.github/workflows/sync-labels.yml @@ -114,7 +114,7 @@ jobs: path: ${{ env.CONFIGURATIONS_FOLDER }} - name: Remove unneeded artifact - uses: geekyeggo/delete-artifact@v2 + uses: geekyeggo/delete-artifact@v4 with: name: ${{ env.CONFIGURATIONS_ARTIFACT }} From 56e0e9c0e404a3e3a7961f0c63d5a34ebd775699 Mon Sep 17 00:00:00 2001 From: Alexander Entinger Date: Mon, 4 Mar 2024 06:02:07 +0100 Subject: [PATCH 57/60] Fix regression re report-size-deltas after updating actions/upload-artifact. (#42) For more information see https://github.com/arduino/report-size-deltas/blob/main/docs/FAQ.md#size-deltas-report-workflow-triggered-by-schedule-event . --- .github/workflows/compile-examples.yml | 18 +++++++++++++++++- .github/workflows/report-size-deltas.yml | 4 ++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/.github/workflows/compile-examples.yml b/.github/workflows/compile-examples.yml index 5686ce5..ac696fc 100644 --- a/.github/workflows/compile-examples.yml +++ b/.github/workflows/compile-examples.yml @@ -35,66 +35,82 @@ jobs: platforms: | - name: arduino:avr softwareserial: true + artifact-name-suffix: arduino-avr-uno - fqbn: arduino:avr:mega platforms: | - name: arduino:avr softwareserial: true + artifact-name-suffix: arduino-avr-mega - fqbn: arduino:avr:leonardo platforms: | - name: arduino:avr softwareserial: true + artifact-name-suffix: arduino-avr-leonardo - fqbn: arduino:megaavr:nona4809 platforms: | - name: arduino:megaavr softwareserial: true + artifact-name-suffix: arduino-megaavr-nona4809 - fqbn: arduino:sam:arduino_due_x_dbg platforms: | - name: arduino:sam softwareserial: false + artifact-name-suffix: arduino-sam-arduino_due_x_dbg - fqbn: arduino:samd:mkrzero platforms: | - name: arduino:samd softwareserial: false + artifact-name-suffix: arduino-samd-mkrzero - fqbn: arduino:mbed_portenta:envie_m7:target_core=cm4 platforms: | - name: arduino:mbed_portenta softwareserial: false + artifact-name-suffix: arduino-mbed_portenta-envie_m7-target_core-cm4 - fqbn: arduino:mbed_portenta:envie_m7 platforms: | - name: arduino:mbed_portenta softwareserial: false + artifact-name-suffix: arduino-mbed_portenta-envie_m7 - fqbn: arduino:mbed_nano:nano33ble platforms: | - name: arduino:mbed_nano softwareserial: false + artifact-name-suffix: arduino-mbed_nano-nano33ble - fqbn: arduino:mbed_nano:nanorp2040connect platforms: | - name: arduino:mbed_nano softwareserial: false + artifact-name-suffix: arduino-mbed_nano-nanorp2040connect - fqbn: arduino:mbed_nicla:nicla_vision platforms: | - name: arduino:mbed_nicla softwareserial: false + artifact-name-suffix: arduino-mbed_nicla-nicla_vision - fqbn: arduino:mbed_opta:opta platforms: | - name: arduino:mbed_opta softwareserial: false + artifact-name-suffix: arduino-mbed_opta-opta - fqbn: arduino:mbed_giga:giga platforms: | - name: arduino:mbed_giga softwareserial: false + artifact-name-suffix: arduino-mbed_giga-giga - fqbn: arduino:renesas_portenta:portenta_c33 platforms: | - name: arduino:renesas_portenta softwareserial: false + artifact-name-suffix: arduino-renesas_portenta-portenta_c33 - fqbn: arduino:renesas_uno:unor4wifi platforms: | - name: arduino:renesas_uno softwareserial: false + artifact-name-suffix: arduino-renesas_uno-unor4wifi - fqbn: arduino:esp32:nano_nora platforms: | - name: arduino:esp32 softwareserial: false + artifact-name-suffix: arduino-esp32-nano_nora # Make board type-specific customizations to the matrix jobs include: @@ -134,4 +150,4 @@ jobs: with: if-no-files-found: error path: ${{ env.SKETCHES_REPORTS_PATH }} - name: ${{ env.SKETCHES_REPORTS_PATH }} + name: sketches-report-${{ matrix.board.artifact-name-suffix }} diff --git a/.github/workflows/report-size-deltas.yml b/.github/workflows/report-size-deltas.yml index 652be5d..39e2a0a 100644 --- a/.github/workflows/report-size-deltas.yml +++ b/.github/workflows/report-size-deltas.yml @@ -20,5 +20,5 @@ jobs: - name: Comment size deltas reports to PRs uses: arduino/report-size-deltas@v1 with: - # The name of the workflow artifact created by the sketch compilation workflow - sketches-reports-source: sketches-reports + # Regex matching the names of the workflow artifacts created by the "Compile Examples" workflow + sketches-reports-source: ^sketches-report-.+ From 26cc8bf761fc623f1d20ec89a11e854853439b9e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 19 Mar 2024 15:00:25 +0100 Subject: [PATCH 58/60] Bump geekyeggo/delete-artifact from 4 to 5 (#43) Bumps [geekyeggo/delete-artifact](https://github.com/geekyeggo/delete-artifact) from 4 to 5. - [Release notes](https://github.com/geekyeggo/delete-artifact/releases) - [Changelog](https://github.com/GeekyEggo/delete-artifact/blob/main/CHANGELOG.md) - [Commits](https://github.com/geekyeggo/delete-artifact/compare/v4...v5) --- updated-dependencies: - dependency-name: geekyeggo/delete-artifact dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/sync-labels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sync-labels.yml b/.github/workflows/sync-labels.yml index 47ac50a..53a9f54 100644 --- a/.github/workflows/sync-labels.yml +++ b/.github/workflows/sync-labels.yml @@ -114,7 +114,7 @@ jobs: path: ${{ env.CONFIGURATIONS_FOLDER }} - name: Remove unneeded artifact - uses: geekyeggo/delete-artifact@v4 + uses: geekyeggo/delete-artifact@v5 with: name: ${{ env.CONFIGURATIONS_ARTIFACT }} From a9ff9a0ccac90ae7e4e7cef3ec90671f8a7b6b1c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 8 Oct 2024 12:37:52 +0000 Subject: [PATCH 59/60] Bump arduino/arduino-lint-action from 1 to 2 Bumps [arduino/arduino-lint-action](https://github.com/arduino/arduino-lint-action) from 1 to 2. - [Release notes](https://github.com/arduino/arduino-lint-action/releases) - [Commits](https://github.com/arduino/arduino-lint-action/compare/v1...v2) --- updated-dependencies: - dependency-name: arduino/arduino-lint-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/check-arduino.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check-arduino.yml b/.github/workflows/check-arduino.yml index adb330f..e818685 100644 --- a/.github/workflows/check-arduino.yml +++ b/.github/workflows/check-arduino.yml @@ -19,7 +19,7 @@ jobs: uses: actions/checkout@v4 - name: Arduino Lint - uses: arduino/arduino-lint-action@v1 + uses: arduino/arduino-lint-action@v2 with: compliance: specification library-manager: update From 89e86f196dfe244337355f3b9498bd3b41c665c4 Mon Sep 17 00:00:00 2001 From: per1234 Date: Fri, 9 May 2025 03:32:20 -0700 Subject: [PATCH 60/60] Standardize license file Standardization in license documentation is important because, in addition to making it easy for humans to find this vital information, it allows machines to automate the process of license type determination, which is useful both for discovering suitable open source projects as well as checking open source license compliance. The open source license of this project is already stored in a standardized location in a dedicated license file. However, even though the project is licensed under a standardized open source license, additional text was added to the license file which offers the option to purchase an exception for proprietary use of the project. Even though this offer does not have any legal effect on the open source license, the presence of that text made it so that the open license type could not be identified with 100% confidence by machines (e.g., the Licensee Gem used by the GitHub website), which meant identification could only be made by a human carefully evaluating the license text. Since there is no need to place the exception offer in the license file, it can be moved to the readme, with the license file containing only the verbatim standardized open source license text. The result is that the project's open source license type can now be automatically identified, without making any change to the licensing. --- LICENSE | 20 +++----------------- README.md | 6 ++++++ 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/LICENSE b/LICENSE index cd4defc..f288702 100644 --- a/LICENSE +++ b/LICENSE @@ -1,17 +1,3 @@ -This file includes licensing information for Arduino_DebugUtils. - -Copyright (c) 2018 ARDUINO SA (www.arduino.cc) - -The software is released under the GNU General Public License, which covers the main body -of the Arduino_DebugUtils code. The terms of this license can be found at: -https://www.gnu.org/licenses/gpl-3.0.en.html - -You can be released from the requirements of the above licenses by purchasing -a commercial license. Buying such a license is mandatory if you want to modify or -otherwise use the software for commercial activities involving the Arduino -software without disclosing the source code of your own applications. To purchase -a commercial license, send an email to license@arduino.cc - GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 @@ -645,8 +631,8 @@ to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. - Arduino_DebugUtils encapsulates functionality useful for debugging code via printf statements. - Copyright (C) Arduino SA, 2019, Author: Alexander Entinger + + Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -666,7 +652,7 @@ Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: - Arduino_DebugUtils Copyright (C) 2019, Arduino SA + Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. diff --git a/README.md b/README.md index 23ea200..c59b804 100644 --- a/README.md +++ b/README.md @@ -111,3 +111,9 @@ Debug.setDebugLevel(DBG_VERBOSE); int i = 0; DEBUG_VERBOSE("DBG_VERBOSE i = %d", i); ``` + +# License + +Arduino_DebugUtils is licensed under the GNU General Public License v3.0. + +You can be released from the requirements of the above license by purchasing a commercial license. Buying such a license is mandatory if you want to modify or otherwise use the software for commercial activities involving the Arduino software without disclosing the source code of your own applications. To purchase a commercial license, send an email to license@arduino.cc