[SOLVED]Disable Serial #ifdef DEBUG not working, Best practice?

Hi There

Coming from the arduino environment i was used to have the following settings:

//#define DEBUG //enable/disable serial debug output

#ifdef DEBUG
#define DEBUG_PRINT(x) Serial.print(x)
#define DEBUG_PRINTDEC(x) Serial.print(x, DEC)
#define DEBUG_PRINTLN(x) Serial.println(x)
#define DEBUG_PRINT(x)
#define DEBUG_PRINTLN(x)

So with comment or uncomment i could enable or disable serial output, somehow this is not working with the particle photon. I used this often because without serial connection my arduinos often had problem (stand-alone) if serial was enabled but not connected. Also speed was much better without serial.

What’s the best practice for debug (on/off) with the particle photon?

Best M

@metforx, you can use the same approach with the Core/Photon, however I believe DEBUG is already defined so simply use another flag name like DEBUGP for example. :smile:

@peekay123, this worked perfectly. thanks :smiley:

1 Like

Firmware has support for debugging and logging with different levels. https://github.com/spark/firmware/blob/develop/docs/debugging.md

Cheers :smile: