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 1.7k 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.
  • AWIA Offline
    AWIA 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
    
    sundberg84S karl261K 2 Replies Last reply
    8
    • AWIA 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
      
      sundberg84S Offline
      sundberg84S 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
      • Martin TellblomM Offline
        Martin TellblomM 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
        • AWIA 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
          
          karl261K Offline
          karl261K 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
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          19

          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