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

[enhancement] let println() set the endline characters #498

Open
atesin opened this issue Sep 11, 2022 · 1 comment
Open

[enhancement] let println() set the endline characters #498

atesin opened this issue Sep 11, 2022 · 1 comment

Comments

@atesin
Copy link

atesin commented Sep 11, 2022

hi.... something that set me itchy sometimes is the inability to change the hardcoded \r\n line endings in println()...

additionally with adding an EXTRA BYTE to every println() (maybe not in source code but in printing for sure), there are many consoles and terminal emulators and systems that can perfectly handle just \n (come on... that \r\n thing is from telegraph and teletype writers epoch)....

and would be also easier to code... for example for received strings, a single Stream.readBytesUntil(buffer, '\n') would do the trick, without the need to trim the remaining trailing \r that could complicate things further.... could even add support for other protocols (some uses \r, \0, \xFF ; or other line ending instead of \n)

i know how to do it for myself alone... it would suffice with editing cores/Print.h|cpp and define some macro to println(), that way i could just redefine the macro in my sketch.... but i am really talking about include it in the next release so everyone could enjoy this enhancement natively, not just me

@atesin
Copy link
Author

atesin commented Sep 13, 2022

i propose these changes, as you will see they are very easy!...

core/arduino/Print.h: line ~36 (in preproc defines, before Print class definition)

#define PRINTLN_NEWLINE "\r\n"

core/arduino/Print.cpp: lines ~126-129

size_t Print::println(void)
{
  return write(PRINTLN_NEWLINE);
}

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

No branches or pull requests

2 participants