-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Description
Related area
WiFi / Ethernet
Hardware specification
All ESP32 versions
Is your feature request related to a problem?
Arduino describe Stream::flush()
as "sending all outgoing outstanding data"
https://www.arduino.cc/reference/en/language/functions/communication/stream/streamflush/
Stream
is the base interface class for all IO implementations (WiFi, HarwareSerial, USBCDC, SPI, Wire)
So also in Serial
arduino interface behaviour is maintained:
https://www.arduino.cc/reference/en/language/functions/communication/serial/flush/
HardwareSerial
here in Esp32 is conformant too:
arduino-esp32/cores/esp32/HardwareSerial.cpp
Lines 472 to 475 in 0a26a8c
void HardwareSerial::flush(void) | |
{ | |
uartFlush(_uart); | |
} |
arduino-esp32/cores/esp32/esp32-hal-uart.c
Lines 753 to 766 in 0a26a8c
void uartFlushTxOnly(uart_t* uart, bool txOnly) | |
{ | |
if(uart == NULL) { | |
return; | |
} | |
UART_MUTEX_LOCK(); | |
while(!uart_ll_is_tx_idle(UART_LL_GET_HW(uart->num))); | |
if ( !txOnly ) { | |
ESP_ERROR_CHECK(uart_flush_input(uart->num)); | |
} | |
UART_MUTEX_UNLOCK(); | |
} |
But then WiFiClient::flush()
is still maintaining old arduino behaviour of clearing RX input:
arduino-esp32/libraries/WiFi/src/WiFiClient.cpp
Lines 162 to 167 in 0a26a8c
void flush(){ | |
if(r_available()){ | |
fillBuffer(); | |
} | |
_pos = _fill; | |
} |
This is not compliant with the Stream
interface
Describe the solution you'd like
WiFiClient::flush()
to actually send al outstanding data to the client to the other end without clearing the input buffer
Describe alternatives you've considered
Overloading WiFiClient
class with a custom flush function
Additional context
Yes is true that original WiFiClient::flush()
from arduino define a different behaviour
https://www.arduino.cc/reference/en/libraries/wifi/client.flush/
But it is also true that that documentation is both obsolete and it don't even adhere to the Stream::flush()
interface from which it inherit
https://www.arduino.cc/reference/en/language/functions/communication/stream/streamflush/
I have checked existing list of Feature requests and the Contribution Guide
- I confirm I have checked existing list of Feature requests and Contribution Guide.
(closest is WiFiClient - rename flush() to clear() (breaking) #8871 but it don't actually address the problem)
Metadata
Metadata
Assignees
Labels
Type
Projects
Status