FengChendian / serial_port_win32

A flutter SerialPort library using win32 API.
BSD 3-Clause "New" or "Revised" License
30 stars 8 forks source link

Read COM port is missing message #24

Closed maiducgiang closed 10 months ago

maiducgiang commented 1 year ago

In my Flutter project windows, I connect COM with setting: port = SerialPort(namePort, openNow: true, BaudRate: baudRate, Parity: parity, StopBits: stopBits, ByteSize: byteSize, ReadIntervalTimeout: readIntervalTimeout, ReadTotalTimeoutConstant: readTotalTimeoutConstant, ReadTotalTimeoutMultiplier: readTotalTimeoutMulti); port?.readBytesSize = 50; when i make the COM data return listener the data is sometimes lost a few bytes

image

Can anyone give me a solution?

FengChendian commented 1 year ago

Do you insert '\0' at the end of char buffer? And Strings may be truncated due to read timeout.

Can you give me some ESP CODE about serial port?

PS: Some people have also encountered this problem, but I have not been able to reproduce it on Windows 11.

FengChendian commented 10 months ago

The bug is due to PurgeComm should be executed before read. But purge operation may be processed after read. So messae is lost.

Please try 1.1.0. The bug should be fixed. If there is still bug, please reopen this issue.