Skip to content
  • 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
N

nelsonov

@nelsonov
  • Getting Started
  • Controller
  • Build
  • Hardware
  • Download/API
  • Forum
  • Store
About
Posts
16
Topics
3
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • MY_SERIALDEVICE overrides MY_DEBUG_HWSERIAL
    N nelsonov

    @mfalkvidd I'm using an AVR board for my serial gateway. I modified hwDebugPrint in MyHwAVR.cpp with an extra #ifndef to look for MY_DEBUGDEVICE or copy MY_SERIALDEVICE to it. Then all occurrences of MY_SERIALDEVICE were changed to MY_DEBUGDEVICE.

    I added this to my sketch:

    #define MY_DEBUGDEVICE Serial  // Redirect debug to Serial
    

    The result was what I wanted. Controller <-> Gateway configuration went over Serial1 (/dev/ttyS0 on my RPi) and debugging output went to Serial (/dev/ttyACM0 on my RPi). This allows me to easily debug without having to take any special steps with my controller.

    void hwDebugPrint(const char *fmt, ... )
    {
    #ifndef MY_DEBUGDEVICE
    #define MY_DEBUGDEVICE MY_SERIALDEVICE
    #endif
    #ifndef MY_DISABLED_SERIAL
    	char fmtBuffer[MY_SERIAL_OUTPUT_SIZE];
    #ifdef MY_GATEWAY_SERIAL
    	// prepend debug message to be handled correctly by controller (C_INTERNAL, I_LOG_MESSAGE)
    	snprintf_P(fmtBuffer, sizeof(fmtBuffer), PSTR("0;255;%" PRIu8 ";0;%" PRIu8 ";%" PRIu32 " "),
    	           C_INTERNAL, I_LOG_MESSAGE, hwMillis());
    	MY_DEBUGDEVICE.print(fmtBuffer);
    #else
    	// prepend timestamp
    	MY_DEBUGDEVICE.print(hwMillis());
    	MY_DEBUGDEVICE.print(F(" "));
    #endif
    	va_list args;
    	va_start (args, fmt );
    	vsnprintf_P(fmtBuffer, sizeof(fmtBuffer), fmt, args);
    #ifdef MY_GATEWAY_SERIAL
    	// Truncate message if this is gateway node
    	fmtBuffer[sizeof(fmtBuffer) - 2] = '\n';
    	fmtBuffer[sizeof(fmtBuffer) - 1] = '\0';
    #endif
    	va_end (args);
    	MY_DEBUGDEVICE.print(fmtBuffer);
    	MY_DEBUGDEVICE.flush();
    #else
    	(void)fmt;
    #endif
    }
    
    Troubleshooting

  • MY_SERIALDEVICE overrides MY_DEBUG_HWSERIAL
    N nelsonov

    @mfalkvidd I'm quite willing to open a pull request. This will be my first time. Do you want me to create an issue as well? Also what would this be called? Perhaps something like "Alternate Port Debugging"? It's hard to think of something that's 'googlable'.

    Troubleshooting
  • Login

  • Don't have an account? Register

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