serial_port_win32
serial_port_win32 copied to clipboard
The resulting data is divided into several segments
No \0
in your string. It's possible to truncate your string due to windows API. And the API is designed that it will return the read data when win32 function returns the sending is complete (Maybe I/O just delay). So readBytesSize
may be less than bytesSize.
You can increase dataPollingInterval
to wait data io is complete.
Or use readBytesUntil
function. The function waits flag string in endless loop;
ReadIntervalTimeout
is useful for this problem. https://learn.microsoft.com/en-us/windows/win32/api/winbase/ns-winbase-commtimeouts
void readBytesOnListen(int bytesSize, Function(Uint8List value) onData,
{void onBefore()?,
Duration dataPollingInterval = const Duration(microseconds: 500)})
I think I should add wait until bytesSize is ready
parameter to fix this problem in readBytesOnListen
. I will publish the change in next version.