RemoteDebug icon indicating copy to clipboard operation
RemoteDebug copied to clipboard

Ability to use flash strings in debug messages

Open kostuch opened this issue 5 years ago • 3 comments

Is your feature request related to a problem? Please describe.

All messages processed by debug are stored in RAM memory. So in effect, observing/debugging application causes huge difference in RAM utilisation.

Describe the solution you'd like

Something like: debugI(F("some message stored in flash"));

Besides: excellent library.

kostuch avatar Feb 13 '20 11:02 kostuch

I doubt if the messages are stored in RAM, maybe for just a little time until it is processed, but is that really an issue?

jeroenst avatar Mar 02 '20 08:03 jeroenst

As far as I know, all commands like debugI("Debug message") or Serial.print("something to print") by default put string data to the RAM. When I compile my app with many debug inserts, I can see that RAM utilization grows rapidly. If there is a huge amount of RAM available, then there is no issue, but sometime we hit the limit and additional consumption by debug is a problem.

kostuch avatar Mar 02 '20 10:03 kostuch

You can use this:

if (Debug.isActive(Debug.INFO)) Debug.printf(cF("example"));

With cf and this macro's:

#define _gFmtBufSize 100+1

// ERB - Force format strings and string constants into FLASH Memory
#define sF(x) String( F(x) )
         // Used as an F() when being used as the first Element
         // of a Multi-Element Expression
char _gFmtBuf[_gFmtBufSize];
         // Buffer, Used with cF() to store constants in program space (FLASH)
#define cF(x) strncpy_P(_gFmtBuf, (PGM_P)PSTR(x), sizeof(_gFmtBuf)) 
// Used with printf() for the char format string

jeroenst avatar Jan 26 '24 07:01 jeroenst