Skip to content

Allow println to send \n and not \r\n #7364

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

Closed
wants to merge 1 commit into from

Conversation

hmaarrfk
Copy link

No description provided.

@per1234 per1234 added the Print and Stream class The Arduino core library's Print and Stream classes label Mar 22, 2018
@matthijskooijman
Copy link
Collaborator

I'm not sure if adding this to the API really is a good idea (to avoid cluttering the API). Doing a manual print("\n") can already do what you want, of course.

@hmaarrfk
Copy link
Author

I understand not wanting clutter. I can reimplement this with a switch.

Maybe an option to choose between \n and \r\n.

Serial.setln("\n");

maybe?

I am working with large code bases many times new programmers where at times the difference betwen \r\n and \n. The code works, but the serial line endings are all over the place.

Refractoring the code is hard because it is challenging to test hardware with automated tests.

Would you consider alternative ways to changing the line ending?

@hmaarrfk
Copy link
Author

@matthijskooijman I changed the implementation now to be less polluting. Default behaviour is the same, but it should be much easier to change the line endings if the user wants to.

let me know what you think

@hmaarrfk hmaarrfk changed the title printlf: prinln with only \n and not \r\n Allow println to send \n and not \r\n Mar 30, 2018
@matthijskooijman
Copy link
Collaborator

This looks a lot better to me. I do still see a lot of whitespace changes in your PR, those must certainly be removed before merging.

One other question is the performance impact of this change. I wonder if the compiler is smart enough to optimize the line ending variable away.

Finally, it's not my call to merge this, but @cmaglie's or @facchinm's.

@hmaarrfk
Copy link
Author

@matthijskooijman, Thanks for considering this. I will remove the whitespace if the PR is considered.

@hmaarrfk
Copy link
Author

I guess I found the new home for this code

arduino/ArduinoCore-avr#18

@matthijskooijman
Copy link
Collaborator

Correct, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Print and Stream class The Arduino core library's Print and Stream classes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants