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. Remote debug messages with V_TEXT

Remote debug messages with V_TEXT

Scheduled Pinned Locked Moved Development
4 Posts 4 Posters 2.0k Views 10 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.
  • A Offline
    A Offline
    AWI
    Hero Member
    wrote on last edited by
    #1

    Sometimes I want to have debug information from my nodes while these are not connected through serial. I.e. to discover "random" freezes of an outside weather node. So I rewrote a familiar macro

    #define LOCAL_DEBUG
    #ifdef LOCAL_DEBUG
    	#define Sprint(a) (Serial.print(a))						// macro as substitute for print, enable if no print wanted
    	#define Sprintln(a) (Serial.println(a))					// macro as substitute for println
    #else														// no print
    	#define Sprint(a)
    	#define Sprintln(a)
    #endif
    

    to include "remote debugging" by using "sprintf()" (formatted print). It is a (working) first attempt with limitations. Suggestions for improvement are more than welcome. The debug information is sent with V_TEXT and needs to be handled by the controller or a "logging node" (I will publish one soon)

    // Helper for Debug:  1 = Serial debug output ; 2 = V_TEXT remote output ; else no debug
    // Use Formats described in fprint() : http://www.cplusplus.com/reference/cstdio/printf/  
    // Example: 	Printf("Temp %2d Hum %2d\n", temperature, humidity);
    // warning: max print size < 24 ; float = NOT supported in Arduino, you need to convert it yourself, ie. dtostrf(Temperature, 5, 2, tempBuf)
    #define _DEBUG 2												// 0 = no output ; 1 = Serial debug output ; 2 = V_TEXT remote output 
    #if _DEBUG == 1													// Serial output
    	char printBuf[24] ;											// need temporary buffer
    	#define Printf(...) { sprintf(printBuf, __VA_ARGS__) ; Serial.print(printBuf);}	// macro to substitute Printf()
    #elif _DEBUG == 2												// if remote debug you need to define a child and present it to the controller
    	#define DEBUG_CHILD_ID 10									// Child id of V_TEXT
    	MyMessage debugMsg(DEBUG_CHILD_ID, V_TEXT);					// get the debug message ready
    	char printBuf[24] ;											// need temporary buffer
    	#define Printf(...) { sprintf(printBuf, __VA_ARGS__) ; send(debugMsg.set(printBuf)); }	// macro to substitute Printf()						
    #else															// No debug wanted
    	#define Printf(...)										
    #endif
    
    S K 2 Replies Last reply
    8
    • A AWI

      Sometimes I want to have debug information from my nodes while these are not connected through serial. I.e. to discover "random" freezes of an outside weather node. So I rewrote a familiar macro

      #define LOCAL_DEBUG
      #ifdef LOCAL_DEBUG
      	#define Sprint(a) (Serial.print(a))						// macro as substitute for print, enable if no print wanted
      	#define Sprintln(a) (Serial.println(a))					// macro as substitute for println
      #else														// no print
      	#define Sprint(a)
      	#define Sprintln(a)
      #endif
      

      to include "remote debugging" by using "sprintf()" (formatted print). It is a (working) first attempt with limitations. Suggestions for improvement are more than welcome. The debug information is sent with V_TEXT and needs to be handled by the controller or a "logging node" (I will publish one soon)

      // Helper for Debug:  1 = Serial debug output ; 2 = V_TEXT remote output ; else no debug
      // Use Formats described in fprint() : http://www.cplusplus.com/reference/cstdio/printf/  
      // Example: 	Printf("Temp %2d Hum %2d\n", temperature, humidity);
      // warning: max print size < 24 ; float = NOT supported in Arduino, you need to convert it yourself, ie. dtostrf(Temperature, 5, 2, tempBuf)
      #define _DEBUG 2												// 0 = no output ; 1 = Serial debug output ; 2 = V_TEXT remote output 
      #if _DEBUG == 1													// Serial output
      	char printBuf[24] ;											// need temporary buffer
      	#define Printf(...) { sprintf(printBuf, __VA_ARGS__) ; Serial.print(printBuf);}	// macro to substitute Printf()
      #elif _DEBUG == 2												// if remote debug you need to define a child and present it to the controller
      	#define DEBUG_CHILD_ID 10									// Child id of V_TEXT
      	MyMessage debugMsg(DEBUG_CHILD_ID, V_TEXT);					// get the debug message ready
      	char printBuf[24] ;											// need temporary buffer
      	#define Printf(...) { sprintf(printBuf, __VA_ARGS__) ; send(debugMsg.set(printBuf)); }	// macro to substitute Printf()						
      #else															// No debug wanted
      	#define Printf(...)										
      #endif
      
      S Offline
      S Offline
      sundberg84
      Hardware Contributor
      wrote on last edited by
      #2

      @AWI - Woaw! Great idea Awi!
      Looks awesome - keep it up!

      Controller: Proxmox VM - Home Assistant
      MySensors GW: Arduino Uno - W5100 Ethernet, Gw Shield Nrf24l01+ 2,4Ghz
      MySensors GW: Arduino Uno - Gw Shield RFM69, 433mhz
      RFLink GW - Arduino Mega + RFLink Shield, 433mhz

      1 Reply Last reply
      0
      • M Offline
        M Offline
        Martin Tellblom
        wrote on last edited by
        #3

        Very nice... love to have this

        MySensors MQTT Client Gateway, Openhab, Dashing, Razberry, 1-wire

        1 Reply Last reply
        0
        • A AWI

          Sometimes I want to have debug information from my nodes while these are not connected through serial. I.e. to discover "random" freezes of an outside weather node. So I rewrote a familiar macro

          #define LOCAL_DEBUG
          #ifdef LOCAL_DEBUG
          	#define Sprint(a) (Serial.print(a))						// macro as substitute for print, enable if no print wanted
          	#define Sprintln(a) (Serial.println(a))					// macro as substitute for println
          #else														// no print
          	#define Sprint(a)
          	#define Sprintln(a)
          #endif
          

          to include "remote debugging" by using "sprintf()" (formatted print). It is a (working) first attempt with limitations. Suggestions for improvement are more than welcome. The debug information is sent with V_TEXT and needs to be handled by the controller or a "logging node" (I will publish one soon)

          // Helper for Debug:  1 = Serial debug output ; 2 = V_TEXT remote output ; else no debug
          // Use Formats described in fprint() : http://www.cplusplus.com/reference/cstdio/printf/  
          // Example: 	Printf("Temp %2d Hum %2d\n", temperature, humidity);
          // warning: max print size < 24 ; float = NOT supported in Arduino, you need to convert it yourself, ie. dtostrf(Temperature, 5, 2, tempBuf)
          #define _DEBUG 2												// 0 = no output ; 1 = Serial debug output ; 2 = V_TEXT remote output 
          #if _DEBUG == 1													// Serial output
          	char printBuf[24] ;											// need temporary buffer
          	#define Printf(...) { sprintf(printBuf, __VA_ARGS__) ; Serial.print(printBuf);}	// macro to substitute Printf()
          #elif _DEBUG == 2												// if remote debug you need to define a child and present it to the controller
          	#define DEBUG_CHILD_ID 10									// Child id of V_TEXT
          	MyMessage debugMsg(DEBUG_CHILD_ID, V_TEXT);					// get the debug message ready
          	char printBuf[24] ;											// need temporary buffer
          	#define Printf(...) { sprintf(printBuf, __VA_ARGS__) ; send(debugMsg.set(printBuf)); }	// macro to substitute Printf()						
          #else															// No debug wanted
          	#define Printf(...)										
          #endif
          
          K Offline
          K Offline
          karl261
          wrote on last edited by
          #4

          @AWI This sounds extremely cool. I will try it asap! Thanks for sharing!

          1 Reply Last reply
          0

          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

          With your input, this post could be even better 💗

          Register Login
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          11

          Online

          12.0k

          Users

          11.2k

          Topics

          113.4k

          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