[Log] Keep (serial)port active even when no logging is being produced & fetched

This commit is contained in:
Ton Huisman
2026-08-26 17:07:57 +02:00
parent e259cc5fc5
commit 59322134fd
5 changed files with 11 additions and 7 deletions
+5 -1
View File
@@ -34,7 +34,7 @@ bool LogBuffer::getNext(LogDestination logDestination, uint32_t& timestamp, Stri
return false;
}
uint32_t LogBuffer::getNrMessages(LogDestination logDestination) const
uint32_t LogBuffer::getNrMessages(LogDestination logDestination)
{
uint32_t res{};
@@ -47,6 +47,10 @@ uint32_t LogBuffer::getNrMessages(LogDestination logDestination) const
++res;
}
}
if (!res) {
lastReadTimeStamp[logDestination] = millis(); // Reset if we aren't going to fetch a next message
}
return res;
}
+1 -1
View File
@@ -53,7 +53,7 @@ struct LogBuffer {
uint8_t & loglevel);
// Return the number of messages left for given log destination.
uint32_t getNrMessages(LogDestination logDestination) const;
uint32_t getNrMessages(LogDestination logDestination);
bool logActiveRead(LogDestination logDestination);
+3 -3
View File
@@ -220,9 +220,9 @@ ESPEasySerialPort EspEasy_Console_Port::getPortType() const
bool EspEasy_Console_Port::process_serialWriteBuffer()
{
if (_serialWriteBuffer.getNrMessages() == 0) { return false; }
if (_serial == nullptr) { return false; }
if ((_serial == nullptr) || (_serialWriteBuffer.getNrMessages() == 0)) {
return false;
}
#ifdef ESP32
if (!xPortCanYield()) { return false; }
+1 -1
View File
@@ -60,7 +60,7 @@ bool LogHelper::getNext(LogDestination logDestination, uint32_t& timestamp, Stri
return _logBuffer.getNext(logDestination, timestamp, message, loglevel);
}
uint32_t LogHelper::getNrMessages(LogDestination logDestination) const
uint32_t LogHelper::getNrMessages(LogDestination logDestination)
{
return _logBuffer.getNrMessages(logDestination);
}
+1 -1
View File
@@ -19,7 +19,7 @@ public:
String & message,
uint8_t & loglevel);
uint32_t getNrMessages(LogDestination logDestination) const;
uint32_t getNrMessages(LogDestination logDestination);
void loop(bool serialOnly);