I am trying to create a debug print wrapper that eventually calls the Serial.printlnf function
I am using variable args in the exact same way the Serial library uses but the parameters alway come out as garbage.
Is there any reason why the code below would not work?
void SerialPrint(E_dbgSrc Src, E_dbgDest Dst, const char \*format, ...)
{
va_list args;
if ( Src < dbg_Src_NumOf)
{
if ( DBG_ENABLE\[Src\] != false)
{
va_start(args, format);
if ( Dst == dbg_Dst_USB)
{
Serial.printlnf(format, args);
}
else if ( Dst == dbg_Dst_Serial)
{
Serial1.printlnf(format, args);
}
va_end(args);
}
}
}
When I call this function as
SerialPrint(dbg_Src_Main, dbg_Dst_USB, "Two Arg %d, %d", 10, 1000);
I get this output
Two Arg 536964180, 536964152