Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to use flash strings in debug messages #64

Open
kostuch opened this issue Feb 13, 2020 · 3 comments
Open

Ability to use flash strings in debug messages #64

kostuch opened this issue Feb 13, 2020 · 3 comments

Comments

@kostuch
Copy link

kostuch commented Feb 13, 2020

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.

@jeroenst
Copy link
Contributor

jeroenst commented Mar 2, 2020

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?

@kostuch
Copy link
Author

kostuch commented Mar 2, 2020

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.

@jeroenst
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants