Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

This class provides functionality useful for debugging sketches via printf-style statements.

License

NotificationsYou must be signed in to change notification settings

arduino-libraries/Arduino_DebugUtils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

96 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Check Arduino statusCompile Examples statusSpell Check status

This class provides functionality useful for debugging sketches viaprintf-style statements.

How-To-Use Basic

Arduino_DebugUtils has 6 different debug levels (described descending from highest to lowest priority):

  • DBG_NONE - no debug output is shown
  • DBG_ERROR - critical errors
  • DBG_WARNING - non-critical errors
  • DBG_INFO - information
  • DBG_DEBUG - more information
  • DBG_VERBOSE - most information

The desired debug level can be set viasetDebugLevel(DBG_WARNING).

Debug messages are written viaprint which supportsprintf-style formatted output.

Example:

int i =1;float pi =3.1459;DEBUG_VERBOSE("i = %d, pi = %f", i, pi);

Note: The output of floating point numbers (%f) does NOT work onArduinoCore-avr.

If desired, timestamps can be prefixed to the debug message. Timestamp output can be enabled and disabled viatimestampOn andtimestampOff.

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 ofsetDebugOutputStream(&Serial2).

Documentation

Debug :

Arduino_DebugUtils Object that will be used for calling member functions.

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, andDBG_VERBOSE.

Return type: void.

Example:

Debug.setDebugLevel(DBG_VERBOSE);

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:

SoftwareSerialmySerial(10,11);// RX, TXDebug.setDebugOutputStream(&mySerial);

Debug.timestampOn() :

Calling this function switches on the timestamp in theDebug.print() function call;By default, printing timestamp is off, unless turned on using this function call.

Return type: void.

Example:

Debug.timestampOn();DBG_VERBOSE("i = %d", i);//Output looks like : [ 21007 ] i = 21

Debug.timestampOff() :

Calling this function switches off the timestamp in theDebug.print() function call;

Return type: void.

Example:

Debug.timestampOff();DEBUG_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 theDebug.print() function call;By default, a newline is sentReturn type: void.

Example:

Debug.newlineOn();

Debug.newlineOff() :

Calling this function ensure that a newline will NOT be sent at the end of theDebug.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 parameterdebug_level in theDebug.print(debug_level, ...) function call belongs to the range: DBG_ERROR <= debug_level <= (<DBG_LEVEL> that has been set usingsetDebugLevel() function).

Return type: void.

Example:

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 tolicense@arduino.cc

About

This class provides functionality useful for debugging sketches via printf-style statements.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp