Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
让我详细解释为什么固定64字节的缓冲区会导致数据丢失:
串口数据流的特点:
原代码中的问题:
byte[] buffer = new byte[64]; size = in.read(buffer);
主要改进包括:
把缓冲区大小从64字节增加到1024字节,并定义为常量
1.添加了10毫秒的休眠时间,减少CPU占用
2.增加了更详细的错误日志
3.使用单独的数据缓冲区,避免数据覆盖
这些修改能够:
fixbug:
onReceived buff 最长64位吗? #52