-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Inconsitent meaning of WiFiUDP::flush() across cores. #8312
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
Comments
I don't fully agree: https://www.arduino.cc/en/Reference/ClientFlush and in Stream: https://www.arduino.cc/reference/en/language/functions/communication/stream/streamflush/
It was so before we fixed it (if I remember correctly)
This comment indeed does not reflect what's under the hood and has had taken its source from
Beside, official Ethernet implementation does not seem to discard anything. Do you have links to other implementations not behaving similarly as in this core ? Should we update this unclear comment ? |
https://www.arduino.cc/reference/en/language/functions/communication/serial/flush/ |
So the current behavior which is waiting for the output buffer ( |
Well, first thing that comes to mind is the "big brother" ESP32: But maybe it's ESP32 that is not compliant. Probably the general meaning of flush() changed at one point of time, but I'm pretty sure to have seen it used as "clearing buffers" plenty of times. So, I agree, the code comment should be changed, and the ESP32 implementation. |
On the other hand: https://www.arduino.cc/en/Reference/WiFiUDPFlush The API documentation is clear as it says: Discard any bytes that have been written to the client but not yet read. |
Well I missed that one. So Ethernet UDP and WiFi UDP do not behave similarly ? |
right. :-( |
only the doc is wrong. see the release notes I linked in my comment. there is the complete history. search "flush" https://github.com/arduino-libraries/Ethernet/blob/master/src/EthernetUdp.cpp#L176-L179 |
AFAICS ESP8266 is the only Arduino platform where
WiFiUDP::flush()
behaves like what one expects on a POSIX system. Meaning sending/writing any pending data. But Arduino chose to use it as a means to discard buffers. And that's how it is implemented on most (all?) cores AND stated in the documentation. https://github.com/esp8266/Arduino/blob/master/cores/esp8266/Udp.h#L79On ESP8266
WiFiUDP::flush()
just callsendPacket()
which is not really useful, while a function to drain the receive buffer IS. At least IMHO.I propose to change the flush() method according to the Arduino standard.
The text was updated successfully, but these errors were encountered: