Prepend debug message only on serial gateway (#882)

This commit is contained in:
Marcelo Aquino
2017-07-24 21:40:46 +02:00
committed by Olivier
parent 6f10745f0a
commit 90793e734c
6 changed files with 18 additions and 30 deletions
+3 -5
View File
@@ -171,7 +171,7 @@ void hwDebugPrint(const char *fmt, ...)
{
#ifndef MY_DISABLED_SERIAL
char fmtBuffer[MY_SERIAL_OUTPUT_SIZE];
#ifdef MY_GATEWAY_FEATURE
#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;%d;0;%d;%lu "), C_INTERNAL, I_LOG_MESSAGE,
hwMillis());
@@ -183,13 +183,11 @@ void hwDebugPrint(const char *fmt, ...)
#endif
va_list args;
va_start(args, fmt);
#ifdef MY_GATEWAY_FEATURE
// Truncate message if this is gateway node
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';
#else
vsnprintf_P(fmtBuffer, sizeof(fmtBuffer), fmt, args);
#endif
va_end(args);
MY_SERIALDEVICE.print(fmtBuffer);