mirror of
https://github.com/thooge/esp32-nmea2000-obp60.git
synced 2026-01-15 12:13:06 +01:00
add flush for gwserial
This commit is contained in:
@@ -67,7 +67,7 @@ size_t GwSerial::enqueue(const uint8_t *data, size_t len)
|
|||||||
}
|
}
|
||||||
GwBuffer::WriteStatus GwSerial::write(){
|
GwBuffer::WriteStatus GwSerial::write(){
|
||||||
if (! isInitialized()) return GwBuffer::ERROR;
|
if (! isInitialized()) return GwBuffer::ERROR;
|
||||||
return buffer->fetchData(writer,false);
|
return buffer->fetchData(writer,-1,false);
|
||||||
}
|
}
|
||||||
void GwSerial::sendToClients(const char *buf,int sourceId){
|
void GwSerial::sendToClients(const char *buf,int sourceId){
|
||||||
if ( sourceId == id) return;
|
if ( sourceId == id) return;
|
||||||
@@ -92,4 +92,11 @@ bool GwSerial::readMessages(GwBufferWriter *writer){
|
|||||||
if (! isInitialized()) return false;
|
if (! isInitialized()) return false;
|
||||||
if (! allowRead) return false;
|
if (! allowRead) return false;
|
||||||
return readBuffer->fetchMessage(writer,'\n',true) == GwBuffer::OK;
|
return readBuffer->fetchMessage(writer,'\n',true) == GwBuffer::OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GwSerial::flush(){
|
||||||
|
if (! isInitialized()) return;
|
||||||
|
while (buffer->fetchData(writer,-1,false) == GwBuffer::AGAIN){
|
||||||
|
vTaskDelay(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -26,5 +26,6 @@ class GwSerial{
|
|||||||
void sendToClients(const char *buf,int sourceId);
|
void sendToClients(const char *buf,int sourceId);
|
||||||
void loop(bool handleRead=true);
|
void loop(bool handleRead=true);
|
||||||
bool readMessages(GwBufferWriter *writer);
|
bool readMessages(GwBufferWriter *writer);
|
||||||
|
void flush();
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
Reference in New Issue
Block a user