dwilches/Ardity

Thread is blocking for readTimeout even when no data is available

elRadish opened this issue · 0 comments

https://github.com/dwilches/Ardity/blob/42a047a6216c5054dfa51e66e0605fef4f527074/UnityProject/Assets/Ardity/Scripts/Threads/AbstractSerialThread.cs#L256C1-L257C1

The thread is waiting here for 100ms! for data to arrive, even if no data is returned after a write. For some (many?) protocols, that is the case. That limits the write rate to 10/s when no data is returned.

Wouldn't it be better to check with https://learn.microsoft.com/de-de/dotnet/api/system.io.ports.serialport.bytestoread and read the data into a buffer without blocking? Once, the line delimiter is read, the message is enqueued and the buffer is emptied.