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

Framework support to disable Serial.print from production build #255

Open
tichaonax opened this issue Sep 11, 2021 · 0 comments
Open

Framework support to disable Serial.print from production build #255

tichaonax opened this issue Sep 11, 2021 · 0 comments

Comments

@tichaonax
Copy link

tichaonax commented Sep 11, 2021

One way we can reduce the build size is to add support to disable
Serial.print(), Serial.println() or anything to do with Serial.print.
This can save additional space. I have seen this code on the web and it does the trick I tested it works.

#define DEBUG 0

#if DEBUG == 1
  #define debug(x) Serial.print(x)
  #define debugln(x) Serial.println(x)
#else
  #define debug(x)
  #define debugln(x)
#endif // DEBUG

Then in the use case:

Serial.print(F("WiFi Disconnected. Reason code="));

becomes:

debug(F("WiFi Disconnected. Reason code="));

However it needs support in the Framework so we can turn Serial printing ON/OFF through desired features.ini or the platform.ini.

There is significant Serial print in the framework we could save that and user has option to turn ON/OFF like we do other features.

If there are libraries that can do that without large footprint the better. I just liked the simplicity of that approach.

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

1 participant