ArduinoCore-mbed icon indicating copy to clipboard operation
ArduinoCore-mbed copied to clipboard

Implement the Wire.flush() funtion

Open watershade opened this issue 2 years ago • 7 comments

  1. implement flush of wire. (flush functions have never been implemented before. But it is useful.)

watershade avatar Nov 24 '23 02:11 watershade

Wire.flush() is useful, if I haven't read obsolete data from it. I will get a wrong number via Wire.available() because the size have include the obsolete data. And If I use Wire.read(), the data I read out is include the obsolete data also. Yes, I can read the obsolete data out via Wire.read(), but it is not necessary. If Wire.flush() is I implemented, It will become perfect. Thanks!

watershade avatar Nov 24 '23 03:11 watershade

@facchinm Hi Martino, I don't know if you time to check this merge. Thanks.

watershade avatar Nov 25 '23 02:11 watershade

Duplicate of https://github.com/arduino/ArduinoCore-mbed/pull/760

tokiedokie avatar Feb 01 '24 02:02 tokiedokie

Flush should be intended as a way to send all data out of the TX buffer not to cleanup the RX. See Serial.flush() https://www.arduino.cc/reference/it/language/functions/communication/serial/flush/

pennam avatar Feb 01 '24 08:02 pennam

Should the RX buffer cleanup API be called clear()?

tokiedokie avatar Feb 01 '24 08:02 tokiedokie

Should the RX buffer cleanup API be called clear()?

I don't think there is a standard Arduino API, but personally i think is a more appropriate name.

pennam avatar Feb 01 '24 08:02 pennam

@pennam Thanks for your reply.

I remember flush really flush all data away in old Arduino version.

Prior to Arduino 1.0, this instead removed any buffered incoming serial data.

I will check the new version and try to find a better name. Maybe clear and it is just like @tokiedokie have said .

Thanks again.

watershade avatar Feb 03 '24 05:02 watershade