Paul
I just read the Stream.flush documentation and I have some remarks.
flush() clears the buffer once all outgoing characters have been sent.
The stream documentation states :Stream defines the reading functions in Arduino.
The stream flush states: flush() clears the buffer once all outgoing characters have been sent.
I would expect that to be incoming characters have been read as it is a reading functionality.
flush() clears the buffer once all outgoing characters have been sent.
There is no explanation what exactly is involved in clearing a buffer once the characters have been sent/read.
From my understanding I would describe the function
Reads the input from the input device and puts that information in a memory buffer. The information received from the external device is now available to the sketch from the memory buffer.
Returns boolean
The declaration of the method is virtual void flush(void);
I know in C/C++ void actually is the same as int and boolean but this is confusing.
The actual implementation in hardware serial doesn't return anything.
I think that now I understand why this method is called flush. It flushes the data from the SPI port to memory (like you flush from the toilet to the cesspool). From a end user perspective the name is at the least weird because as an end user you do not want to know about the cesspool.
I feel the documentation of this method needs a good look.
Please see my proposition below
Best regards
Jantje
My proposition:
flush()
Description
Reads the input from the external input device and puts that information in a memory buffer. The information received from the external input device is now available to the sketch from the memory buffer.
This method is part of the Stream class, and is a pure virtual method (which means there is no code attached to this method in the Stream class) as such it can only be called by a class that inherits from the Stream class and implements this method (in other words the class inheriting from Stream adds code to the method flush).
Inherited classes are : Wire, Serial, ....
See the Stream class main page for more information.
Syntax
stream.flush()
Parameters
stream : an instance of a class that inherits from Stream and implemented flush.
Returns
void
See also