Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Development
  3. debug output

debug output

Scheduled Pinned Locked Moved Development
12 Posts 5 Posters 4.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • marceltrapmanM Offline
    marceltrapmanM Offline
    marceltrapman
    Mod
    wrote on last edited by
    #3

    @hek Is there a reason why it is not public?

    Fulltime Servoy Developer
    Parttime Moderator MySensors board

    I use Domoticz as controller for Z-Wave and MySensors (previously Indigo and OpenHAB).
    I have a FABtotum to print cases.

    1 Reply Last reply
    0
    • marceltrapmanM Offline
      marceltrapmanM Offline
      marceltrapman
      Mod
      wrote on last edited by marceltrapman
      #4

      @hek let me change my previous question :)
      Is it possible to make this public by default?
      I would like to avoid changing the libs and it would also make my library more accessible...
      Or is there an important reason not to do this?

      Fulltime Servoy Developer
      Parttime Moderator MySensors board

      I use Domoticz as controller for Z-Wave and MySensors (previously Indigo and OpenHAB).
      I have a FABtotum to print cases.

      hekH 1 Reply Last reply
      0
      • marceltrapmanM marceltrapman

        @hek let me change my previous question :)
        Is it possible to make this public by default?
        I would like to avoid changing the libs and it would also make my library more accessible...
        Or is there an important reason not to do this?

        hekH Offline
        hekH Offline
        hek
        Admin
        wrote on last edited by
        #5

        @marceltrapman said:

        Is it possible to make this public by default?

        Yes

        I would like to avoid changing the libs and it would also make my library more accessible...
        Or is there an important reason not to do this?

        I don't know if debug prints is part of the core things we would like to expose for a communication library. It doesn't really fit the profile ;). We might decide to change or remove this without any notice and your sketches would stop working.

        There are probably much better debug print libraries available. Another option is just to copy the code to you own marcel-utility library. :)

        YveauxY 1 Reply Last reply
        0
        • hekH hek

          @marceltrapman said:

          Is it possible to make this public by default?

          Yes

          I would like to avoid changing the libs and it would also make my library more accessible...
          Or is there an important reason not to do this?

          I don't know if debug prints is part of the core things we would like to expose for a communication library. It doesn't really fit the profile ;). We might decide to change or remove this without any notice and your sketches would stop working.

          There are probably much better debug print libraries available. Another option is just to copy the code to you own marcel-utility library. :)

          YveauxY Offline
          YveauxY Offline
          Yveaux
          Mod
          wrote on last edited by
          #6

          @hek said:

          I don't know if debug prints is part of the core things we would like to expose for a communication library.

          Good point hek! :+1:
          Stick to the subject ;-)

          http://yveaux.blogspot.nl

          1 Reply Last reply
          0
          • marceltrapmanM Offline
            marceltrapmanM Offline
            marceltrapman
            Mod
            wrote on last edited by
            #7

            @hek now that I think of it I have access to MyConfig.h anyway so creating my own stuff is basically a no-brainer :)

            Fulltime Servoy Developer
            Parttime Moderator MySensors board

            I use Domoticz as controller for Z-Wave and MySensors (previously Indigo and OpenHAB).
            I have a FABtotum to print cases.

            BulldogLowellB 1 Reply Last reply
            0
            • marceltrapmanM marceltrapman

              @hek now that I think of it I have access to MyConfig.h anyway so creating my own stuff is basically a no-brainer :)

              BulldogLowellB Offline
              BulldogLowellB Offline
              BulldogLowell
              Contest Winner
              wrote on last edited by
              #8

              @marceltrapman

              Why not just drop in your own debug flag:

              boolean myBugFlag = true;
              

              then add it to your code

              if (myBugFlag) Serial.print("Expect to see something here...");
              
              YveauxY 1 Reply Last reply
              0
              • BulldogLowellB BulldogLowell

                @marceltrapman

                Why not just drop in your own debug flag:

                boolean myBugFlag = true;
                

                then add it to your code

                if (myBugFlag) Serial.print("Expect to see something here...");
                
                YveauxY Offline
                YveauxY Offline
                Yveaux
                Mod
                wrote on last edited by
                #9

                @BulldogLowell Here's Macro-guy again ;-)

                How about (at the top of your sketch):

                #ifdef DEBUG
                #define debug(x)     Serial.print(x)
                #define debugln(x)   Serial.println(x)
                #else
                #define debug(x)     // define empty, so macro does nothing
                #define debugln(x)
                #endif 
                

                Use like regular Serial.print throughout your code:

                debug("This is some debug text\n");
                debugln("This is some debug text with newline");
                

                When you #define DEBUG in your code the debug text will be output to the serial port, when you don't define it the debug output will not be compiled in (saves some flash/ram, but doesn't allow dynamic switching of debug statements -- this also can be done though)

                http://yveaux.blogspot.nl

                1 Reply Last reply
                0
                • BulldogLowellB Offline
                  BulldogLowellB Offline
                  BulldogLowell
                  Contest Winner
                  wrote on last edited by
                  #10

                  Yes, even better.

                  Also to help avoid the ram issue, building on that, just use the F() macro to put all if your text constants into Flash

                  DeBugln(F("here is your example."));
                  
                  1 Reply Last reply
                  0
                  • marceltrapmanM Offline
                    marceltrapmanM Offline
                    marceltrapman
                    Mod
                    wrote on last edited by
                    #11

                    Guys, thanks for thinking with me.

                    I like to just use the DEBUG variable as defined in config.h.

                    And @Yveaux nice thinking but I want to be able to use formatting so I am going to do something similar to what @hek uses.

                    And @BulldogLowell I use PCNL(...) right now. Any (dis-)advantage of either one that you can think of?

                    Fulltime Servoy Developer
                    Parttime Moderator MySensors board

                    I use Domoticz as controller for Z-Wave and MySensors (previously Indigo and OpenHAB).
                    I have a FABtotum to print cases.

                    1 Reply Last reply
                    0
                    • Z Offline
                      Z Offline
                      Zeph
                      Hero Member
                      wrote on last edited by Zeph
                      #12

                      Just in case it's useful to somebody, my current approach is:

                      // Debug PRinting with LiNefeed and maybe Flash strings or 2nd mode param
                      #ifdef DEBUG
                      #define DPR(x)      Serial.print(x)
                      #define DPR2(x,m)   Serial.print(x,m)
                      #define DPRLIN()    Serial.println()
                      #define DPRLN(x)    Serial.println(x)
                      #define DPRLN2(x,m) Serial.println(x,m)
                      // saving string in Flash ProgMem
                      #define DPRF(x)     Serial.print(F(x))
                      #define DPRLNF(x)   Serial.println(F(x))
                      #else
                      #define DPR(x)
                      #define DPR2(x,m)
                      #define DPRLIN()
                      #define DPRLN(x)
                      #define DPRLN2(x,m)
                      #define DPRF(x)
                      #define DPRLNF(x)
                      #endif
                      

                      This allows substitute for println() with no args, and for print(val, HEX) type modes as well. I got tired of typing the extra F(...) so added macros to incorporate that too.

                      You can make this into a library to include as a .h file - as a note, you still need a corresponding .c file even if empty.

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      23

                      Online

                      11.7k

                      Users

                      11.2k

                      Topics

                      113.1k

                      Posts


                      Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • MySensors
                      • OpenHardware.io
                      • Categories
                      • Recent
                      • Tags
                      • Popular