Skip to content
New issue

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

无法接受串口返回数据 #15

Open
zhaobinsir opened this issue Jun 28, 2018 · 6 comments
Open

无法接受串口返回数据 #15

zhaobinsir opened this issue Jun 28, 2018 · 6 comments

Comments

@zhaobinsir
Copy link

用电脑连接串口可以,串口初始化也ok了,可以发送但无法接收

@AndyAls
Copy link

AndyAls commented Oct 8, 2018

您好 串口问题请教 加一下好友吧 qq 841020929 或微信 1973328389 谢谢 遇到同样问题 发送但接收不到数据

@AndyAls
Copy link

AndyAls commented Oct 8, 2018

用电脑连接串口可以,串口初始化也ok了,可以发送但无法接收

您好 串口问题请教 加一下好友吧 qq 841020929 或微信 1973328389 谢谢 遇到同样问题 发送但接收不到数据

@gxh-apologize
Copy link

@AndyAls 您好,返回数据接收不到解决了吗?我也遇到了相同的问题。

@zhaoxiuyu
Copy link

@gxh-apologize @zhaobinsir @AndyAls 你好,请问解决了吗

@121104115wyb
Copy link

我也遇到相同的问题,发送成功,但是接收失败

@121104115wyb
Copy link

121104115wyb commented Apr 28, 2020

哇,我解決了,这个问题,是我的代码错误,我在发送了数据后,就把串口关闭了,我要为我的错误反思:下面是我的代码,希望大家不要犯相同的错误
```
String inputCommand = editText.getText().toString().trim();
if (openSerialPort && !TextUtils.isEmpty(inputCommand)) {
boolean sendBytes = mSerialPortManager.sendBytes(hexToByteArray(inputCommand));
Log.d(TAG, "initViews: ----发送:" + (sendBytes ? "成功" : "失败"));
Toast.makeText(this, "发送" + (sendBytes ? "成功" : "失败"), Toast.LENGTH_SHORT).show();
//我原来并没有把这行代码注释掉,注释掉就能接收到数据了
// mSerialPortManager.closeSerialPort();
} else {
Toast.makeText(this, "串口连接错误或者命令为空", Toast.LENGTH_SHORT).show();
}


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants