Skip to content

Why is flush() in Stream and not in Print? #102

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
JAndrassy opened this issue Nov 8, 2019 · 7 comments · Fixed by #104
Closed

Why is flush() in Stream and not in Print? #102

JAndrassy opened this issue Nov 8, 2019 · 7 comments · Fixed by #104
Assignees
Labels

Comments

@JAndrassy
Copy link
Contributor

JAndrassy commented Nov 8, 2019

Why is in Stream.h virtual void flush() = 0;?
flush() is output related and should be in Print as it is in AVR core.

@matthijskooijman
Copy link
Collaborator

Hm, it surprises me that it is. In the AVR and SAM cores, this method was moved to Print a long time ago: arduino/Arduino#2387

I wonder what version this API was based on, or if it was maybe moved back for some reason?

@PaulStoffregen
Copy link

PaulStoffregen commented Nov 9, 2019

This repository also seem to still pre-date the addition of availableForWrite(), which has been a part of the core library for a very long time. I mentioned this ~4 years ago. #64 (comment) Maybe it should be its own issue? But frankly, I've having a hard time taking this repository seriously. :(

@JAndrassy
Copy link
Contributor Author

This repository also seem to still pre-date the addition of availableForWrite(), which has been a part of the core library for a very long time. I mentioned this ~4 years ago. #64 (comment) Maybe it should be its own issue? But frankly, I've having a hard time taking this repository seriously. :(

but it is used in megaavr core and in mbed core

@bxparks
Copy link

bxparks commented Nov 11, 2019

It is even more confusing that:

  • the ESP32 core defines flush() in its Stream.h, while
  • the ESP8266 core defines flush() in its Print.h.

I had to use #if conditional macros to create code that worked across AVR, ESP8266, ESP32, etc. I would have thought that something as fundamental as Print would have a consistent API across all the Arduino platforms.

@JAndrassy
Copy link
Contributor Author

It is even more confusing that:

* the ESP32 core defines `flush()` in its [Stream.h](https://github.com/espressif/arduino-esp32/blob/master/cores/esp32/Stream.h#L51), while

* the ESP8266 core defines `flush()` in its [Print.h](https://github.com/esp8266/Arduino/blob/master/cores/esp8266/Print.h#L103).

I had to use #if conditional macros to create code that worked across AVR, ESP8266, ESP32, etc. I would have thought that something as fundamental as Print would have a consistent API across all the Arduino platforms.

espressif/arduino-esp32#943

@JAndrassy
Copy link
Contributor Author

and in the namespace arduino branch for mbed core?

@facchinm
Copy link
Member

I'm rebasing it there too

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

Successfully merging a pull request may close this issue.

6 participants