to debug or not to debug



  • Hi All,

    Just as question: Does it have a lot of influence if I leave the debug option "on" when I install a (new) node?

    I used to do so (I always leave debug on) but I can imagine it has effect on performance. Or is this irrelevant😳

    BR,

    Boozz


  • Hardware Contributor

    @boozz A quick research told me - yes, it could have a lot of influence. Especially when using low buad rate and sending a lot of characters over serial line. Of course there are other ways to debug.


  • Mod

    If you do a lot of screen drawing, play sound or anything that requires precise timing, running with debug might have an effect. But if it did, you would have noticed it when you tested the node. So performance-wise you can probably leave it on.

    However, if your node is battery-powered, having the serial chip active might hurt battery life. Therefore I disable debug before deploying nodes.

    If you add your own debug statements in your sketch, this makes it easy to turn them off (I got the idea from here😞

    #ifdef DEBUG
      #define debuglogln(args...) Serial.println(args)
    #else
      #define debuglogln(args...)
    #endif
    
    void setup()
    {
    #ifdef DEBUG
      Serial.begin(BAUD_RATE);
    #endif
    
    debuglogln("hello");
    ...
    

    If you turn DEBUG off, debuglogln will do nothing. If DEBUG is on, all debuglogln statements will work as Serial.println. You can do the same for Serial.print (without ln) if you use that.



  • Thank you both for the contributions.

    @mfalkvidd: Thanks a lot for pointing me towards the technique to turn it on /off. This will become very handy in the future for sure.

    BR,

    Boozz


Log in to reply
 

Suggested Topics

  • 1
  • 6
  • 10
  • 2
  • 3
  • 5

61
Online

11.4k
Users

11.1k
Topics

112.7k
Posts