We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
while (!isInterrupted()) { try { if (null == mInputStream) { return; } int available = mInputStream.available(); if(available > 0){ Log.i(TAG, "run: "); int size = mInputStream.read(mReadBuffer); if (-1 == size || 0 >= size) { return; } if(size > 0){ byte[] readBytes = new byte[size]; System.arraycopy(mReadBuffer, 0, readBytes, 0, size); Log.i(TAG, "run: readBytes = " + new String(readBytes)); onDataReceived(readBytes); } }else { SystemClock.sleep(50); }
The text was updated successfully, but these errors were encountered:
我遇到了只能接收32位 用了这个方法解决了
Sorry, something went wrong.
在我们后续的项目里,我们尝试了两种方案来解决串口数据分包粘包问题,仅供参考:1.私有协议,定义结束符,读取到结束符则认为一条指令结束;2.根据协议数据读取完毕所需的时间判断,当读取某条指令大于一定时间,则认为指令结束。有更好的思路欢迎交流!
No branches or pull requests
The text was updated successfully, but these errors were encountered: