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

Flush is broken for SoftwareSerial, WiFiClient TCP and UDP and other classes #4029

Closed
drmpf opened this issue Oct 25, 2015 · 2 comments
Closed
Assignees
Labels
Library: Ethernet The Ethernet Arduino library Library: SoftwareSerial The SoftwareSerial Arduino library Library: Wifi The Wifi Arduino library Type: Bug
Milestone

Comments

@drmpf
Copy link

drmpf commented Oct 25, 2015

Flush is broken for SoftwareSerial, WiFiClient TCP and UDP and other classes
They does not honor the update description for Flush in the stream class

the current docs for Flush() https://www.arduino.cc/en/Serial/Flush say
"Waits for the transmission of outgoing serial data to complete. (Prior to Arduino 1.0, this instead removed any buffered incoming serial data.)
flush() inherits from the Stream utility class."

However for WiFiClient::flush(), WiFiUDP::flush(), SoftwareSerial::flush(), EthernetUDP::flush()
the current code, as of V1.6.4, clears the RX buffer, which is unexpected and leads to loss of incoming data.

I found this while tracking down why my WiFi connection was losing incoming messages sometimes.

Some classes implementations of flush() do nothing so a simple fix would be to replace the non-complient methods with empty methods.

@matthijskooijman
Copy link
Collaborator

Confirmed for SoftwareSerial. Fix is simply removing the flush() implementation, since SoftwareSerial does not do any TX buffering, so flush() is a no-op.

@cmaglie cmaglie added Type: Bug Library: Wifi The Wifi Arduino library Library: Ethernet The Ethernet Arduino library Library: SoftwareSerial The SoftwareSerial Arduino library labels Nov 11, 2015
cmaglie added a commit to cmaglie/Arduino that referenced this issue Nov 11, 2015
We still need to check if trasmission is completed, BTW this commit
should alleviate bugs involving data loss.

See arduino#4029
cmaglie added a commit to cmaglie/Arduino that referenced this issue Nov 11, 2015
We still need to check if trasmission is completed, BTW this commit
should alleviate bugs involving data loss.

See arduino#4029
@cmaglie cmaglie added this to the Release 1.6.7 milestone Nov 18, 2015
@cmaglie
Copy link
Member

cmaglie commented Nov 18, 2015

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Library: Ethernet The Ethernet Arduino library Library: SoftwareSerial The SoftwareSerial Arduino library Library: Wifi The Wifi Arduino library Type: Bug
Projects
None yet
Development

No branches or pull requests

3 participants