Skip to content
Jim Lee edited this page Oct 7, 2019 · 3 revisions

debug

Abstract:

Like I seem to be saying over and over, we're human. And, being human, we make mistakes. There is not a lot of debugging options for Arduinos. The main tool people are currently using is to send out stuff to the serial monitor. This has its drawbacks though. First its a lot of typing. Seriously this starts being an issue. But a bigger issue is that, on some of the faster processors (teensy 3.2 for example), the processor can crash and shut down before the text gets to the monitor. So you really have a tough time figuring out what went wrong and where it went wrong. What you really want is for it to actually stop somewhere and reliably tell you what's going on. These are the issues that debug was written to address.

Currently debug is quite a "new" class and it's still in its formative stages. So this documentation may lag behind reality for awhile.

Constructors.

debug(void);
Debug only has this one blank constructor. And, it actually does nothing. Its just a kind of place holder. This allows the class to create a global debugger instance for you to use in your code (db).

extern debug db;
The global that it creates.

Other methods.

void trace(char* message,bool hold=true);
This version of trace outputs your message c string to the serial monitor. Then it will optionally hold the process at that point in your code by waiting for an inputted character from the serial port. Typing a return into the serial monitor allows the program to continue execution. All the trace cals act the same way, they just have different input parameters.

void trace(char* message,int inNum,bool hold=true);
In this version you can pass in a message c string and an integer to be displayed. And, as always a boolean telling whether or not you'd like it to hold at that point in your code.

void trace(char* message,char* inStr,bool hold=true);
Here we have two message strings. This one comes in handy when doing string processing or formatting. It allows your message along with the second parameter that can be used to pass in the string in question for display.

Clone this wiki locally