johnwasser:
Please provide the full declaration of the original macro APPDBGBF_PRINTF.
I think the solution might be something like:
#define APPDBGBF_PRINTF(Type,Level,Nad, Fmt, ...) \
do {sprintf_P(tmpstr, F(Fmt), VA_ARGS); Serial.print (tmpstr); Serial.println();} while (0)
Hello,
thanks all for help, this seems like a step in the right direction...
Now I get this error :
In file included from sketch\canbus.cpp:6:0:
sketch\canbus.cpp: In function 'uint_32 CANBus_Parse_RX_Message(uint_32, uint_8, unsigned char*)':
canbus.h:288:56: error: cannot convert 'const __FlashStringHelper*' to 'const char*' for argument '2' to 'int sprintf_P(char*, const char*, ...)'
do {sprintf_P(tmpstr, F(Fmt), __VA_ARGS__); Serial.print (tmpstr); Serial.println();} while (0)
^
sketch\canbus.cpp:114:33: note: in expansion of macro 'APPDBGBF_PRINTF'
APPDBGBF_PRINTF(CAN,256,iex_NAD,"CAN_RX[%5d]: STAT_ID:0x%04x |Slot:%d|Class:%d|Dir:%d|Arg:%d|NAD:%d|Len:%d| CardID: %d StatBits: 0b%016b \n", iex_NAD, FPData.IEXModules[iex_slot].Status.all, iex_slot, iex_class, iex_dir, iex_arg, iex_NAD, msg_size,dptr[2]*256+dptr[3],dptr[0]*256+dptr[1]);
^~~~~~~~~~~~~~~
canbus.h:288:56: error: cannot convert 'const __FlashStringHelper*' to 'const char*' for argument '2' to 'int sprintf_P(char*, const char*, ...)'
do {sprintf_P(tmpstr, F(Fmt), __VA_ARGS__); Serial.print (tmpstr); Serial.println();} while (0)
^
sketch\canbus.cpp:121:33: note: in expansion of macro 'APPDBGBF_PRINTF'
APPDBGBF_PRINTF(CAN,1,iex_NAD,"CAN_RX[WARN]: CANBus_Parse_RX_Message: STATUS_ID CAN message with wrong length: Class:%d|Dir:%d|Arg:%d|NAD:%d|Len:%d\n", iex_class, iex_dir, iex_arg, iex_NAD, msg_size);
^~~~~~~~~~~~~~~
... (repeats for each macro call)
More info attached :
.cpp file:
#define TMPSTR_SIZE 48
char tmpstr[TMPSTR_SIZE ];
...
APPDBGBF_PRINTF(CAN,256,iex_NAD,"CAN_RX[%5d]: STAT_ID:0x%04x |Slot:%d|Class:%d|Dir:%d|Arg:%d|NAD:%d|Len:%d| CardID: %d StatBits: 0b%016b \n", iex_NAD, FPData.IEXModules[iex_slot].Status.all, iex_slot, iex_class, iex_dir, iex_arg, iex_NAD, msg_size,dptr[2]*256+dptr[3],dptr[0]*256+dptr[1]);
...
.h file:
#ifdef CFGAPP_DEBUG_ENABLE
#define APPDBGBF_PRINTF(Type,Level,Nad, Fmt, ...) \
do {sprintf_P(tmpstr, F(Fmt), __VA_ARGS__); Serial.print (tmpstr); Serial.println();} while (0)
#else
#define APPDBGBF_PRINTF(Type,Level,Nad, Fmt, ...) {}
#endif