Keep Serial from being linked when disabled (#877)

Even with MY_DISABLED_SERIAL defined, the linker is still adding the
Serial object to the binary.

That's because a) the MySensors *.cpp files are actually included
into the sketch and compiled as part of it (and not compiled
separately and then linked) and b) due the the default(?) behavior of
the linker (https://github.com/arduino/Arduino/issues/4579).
This commit is contained in:
Rainer Clasen
2017-07-24 21:33:46 +02:00
committed by Olivier
parent 8f58b18e1a
commit 6f10745f0a
6 changed files with 12 additions and 0 deletions
+2
View File
@@ -303,6 +303,7 @@ uint16_t hwFreeMem()
void hwDebugPrint(const char *fmt, ... )
{
#ifndef MY_DISABLED_SERIAL
char fmtBuffer[MY_SERIAL_OUTPUT_SIZE];
#ifdef MY_GATEWAY_FEATURE
// prepend debug message to be handled correctly by controller (C_INTERNAL, I_LOG_MESSAGE)
@@ -327,4 +328,5 @@ void hwDebugPrint(const char *fmt, ... )
va_end (args);
MY_SERIALDEVICE.print(fmtBuffer);
MY_SERIALDEVICE.flush();
#endif
}
+2
View File
@@ -149,6 +149,7 @@ uint16_t hwFreeMem()
void hwDebugPrint(const char *fmt, ... )
{
#ifndef MY_DISABLED_SERIAL
char fmtBuffer[MY_SERIAL_OUTPUT_SIZE];
#ifdef MY_GATEWAY_FEATURE
// prepend debug message to be handled correctly by controller (C_INTERNAL, I_LOG_MESSAGE)
@@ -173,4 +174,5 @@ void hwDebugPrint(const char *fmt, ... )
va_end (args);
MY_SERIALDEVICE.print(fmtBuffer);
MY_SERIALDEVICE.flush();
#endif
}
+2
View File
@@ -472,6 +472,7 @@ uint16_t hwFreeMem()
void hwDebugPrint(const char *fmt, ...)
{
#ifndef MY_DISABLED_SERIAL
char fmtBuffer[MY_SERIAL_OUTPUT_SIZE];
#ifdef MY_GATEWAY_FEATURE
// prepend debug message to be handled correctly by controller (C_INTERNAL, I_LOG_MESSAGE)
@@ -496,4 +497,5 @@ void hwDebugPrint(const char *fmt, ...)
va_end (args);
MY_SERIALDEVICE.print(fmtBuffer);
MY_SERIALDEVICE.flush();
#endif
}
+2
View File
@@ -181,6 +181,7 @@ uint16_t hwFreeMem()
void hwDebugPrint(const char *fmt, ... )
{
#ifndef MY_DISABLED_SERIAL
if (MY_SERIALDEVICE) {
char fmtBuffer[MY_SERIAL_OUTPUT_SIZE];
#ifdef MY_GATEWAY_FEATURE
@@ -207,4 +208,5 @@ void hwDebugPrint(const char *fmt, ... )
MY_SERIALDEVICE.print(fmtBuffer);
// MY_SERIALDEVICE.flush();
}
#endif
}
+2
View File
@@ -169,6 +169,7 @@ uint16_t hwFreeMem()
void hwDebugPrint(const char *fmt, ...)
{
#ifndef MY_DISABLED_SERIAL
char fmtBuffer[MY_SERIAL_OUTPUT_SIZE];
#ifdef MY_GATEWAY_FEATURE
// prepend debug message to be handled correctly by controller (C_INTERNAL, I_LOG_MESSAGE)
@@ -195,4 +196,5 @@ void hwDebugPrint(const char *fmt, ...)
// Disable flush since current STM32duino implementation performs a reset
// instead of an actual flush
//MY_SERIALDEVICE.flush();
#endif
}
+2
View File
@@ -167,6 +167,7 @@ void hwRandomNumberInit(void)
void hwDebugPrint(const char *fmt, ...)
{
#ifndef MY_DISABLED_SERIAL
char fmtBuffer[MY_SERIAL_OUTPUT_SIZE];
#ifdef MY_GATEWAY_FEATURE
// prepend debug message to be handled correctly by controller (C_INTERNAL, I_LOG_MESSAGE)
@@ -190,4 +191,5 @@ void hwDebugPrint(const char *fmt, ...)
#endif
va_end(args);
MY_SERIALDEVICE.print(fmtBuffer);
#endif
}