Closed bobosette closed 3 weeks ago
It is the expected behaviour. The device sends data bytes one by one. So, if some bytes are delayed or vanished by accident, you may get a part of data in async read mode.
But you are right, the API should implement a function which will read bytes until required size
In version 2.0.0
, now has APIs:
Future<Uint8List> readBytes(int bytesSize, {required Duration? timeout})
Future<Uint8List> readFixedSizeBytes(int bytesSize, {Duration dataPollingInterval = const Duration(microseconds: 500)})
It should provide flexible timeout control and read size control.
Hi everybody. I don't know if I am wrong and where I am wrong, but I use readBytesOnListen() to read data from a serial port and I don't receive the whole message in one time, but splitted into several times. I don't know If it is the expected behaviour, in my thoughts I should receive the whole message in one time as an Uint8List list (as you can see in the image, I would like to receive the word hello in one time, not splitted). I'm pretty sure that is related to a port configuration problem. My code:
` //open port selectedPort!.openWithSettings( BaudRate: 115200, );
`
Someone can help me? Thanks