Open
Conversation
Owner
|
|
bastengao
reviewed
Jan 3, 2025
| sender.sendEvent(DataReceivedEvent, event); | ||
| } | ||
|
|
||
| Thread.sleep(10); |
Owner
There was a problem hiding this comment.
这里不需要强制休眠,Inputstream.read 方法是阻塞,如果没有读到数据会阻塞住,并不是一直空跑 while 循环
Owner
|
你当前的改动已经超过了修复问题吧?建议当前 MR 只修复问题。其他新加的特性单独提一个MR,另外注释最好用英文,方便沟通。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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