LennartHennigs / ESPTelnet

ESP library that allows you to setup a telnet server for debugging.
MIT License
213 stars 32 forks source link

ESP32 : No way to flush the stream. #68

Open xgnata opened 1 month ago

xgnata commented 1 month ago

Hi,

I'm using the ESPTelnet in serveral tasks on ESP32. The issue is that telnet.flush() does not flush the telnet stream on esp32. There is no way to make sure that one stream has been fully sent before sending another one. The mutex is useless because telnet.print() returns before the stream has been fully sent. Serial.flush() does the job for Serial.

`template void ToSerialAndTelnet(T msg) { xSemaphoreTake(xMutexPrint, portMAX_DELAY); Serial.print(msg); Serial.flush(); telnet.print(msg); // how to make sure that the msg has been fully sent??? xSemaphoreGive(xMutexPrint); }

template void SerialAndTelnet(Args &&...args) { (ToSerialAndTelnet(args), ...); }

template void SerialAndTelnetln(Args &&...args) { if constexpr (sizeof...(Args) == 0) { ToSerialAndTelnet('\n'); } else { (ToSerialAndTelnet(args), ...); ToSerialAndTelnet('\n'); } } `