Skip to content

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

Closed
@drmpf

Description

@drmpf

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions