Hi,
I use a snippet of code to show which line I'm on in my code for debug purposes - and it works very well:
void printDebugLine(uint16_t lineNo){
#ifdef DEBUG
Serial.print(F("We are at LINE: "));
Serial.println(lineNo);
#endif
}
It works using the following call:
printDebugLine(__LINE__);
It fails to be informative however when multiple tabs are used as all I get is line xxx where there are many lines with this number spread across many tabs; Is there a similar call I can use that returns the name of the tab where the printDebugLine(LINE) originates?
Just in case it wasn't clear from DrDiettrich's answer, each of the tabs shown in the Arduino IDE are actually a file. The IDE hides the file extension when it is .ino. For example, a tab named "Blink" is a file named "Blink.ino".
// Strip path details from the FILE information, show only the file NAME
#define __NAME__ (strrchr(__FILE__,'\\') ? strrchr(__FILE__,'\\')+1 : __FILE__)
Use this FUNCTION:
/*
* Handle Serial printing of line/tab info for debugging
*/
void printDebugLine(uint16_t lineNo, const char* FileName ){
#ifdef DEBUG
Serial.print(F("We are at LINE: "));
Serial.print(lineNo);
Serial.print(F(" in TAB: "));
Serial.println(FileName);
#endif
}
and call the Debug info once DEBUG is invoked by inserting this line strategically where needed: