SerialPortHelper icon indicating copy to clipboard operation
SerialPortHelper copied to clipboard

发送命令时,可能会造成空指针异常

Open StarShine761 opened this issue 5 years ago • 7 comments

SphDataProcess 这个类的writeData()方法 if (concurrentCom.getCurrentCmdEntity() == null) { } 这里if判断 偶尔会造成空指针异常

StarShine761 avatar Jul 31 '19 07:07 StarShine761

大兄弟,这个问题你是怎么解决的?我也会遇到这个问题,偶尔会报空

707643186 avatar Jul 13 '20 02:07 707643186

简单的先try catch 掉

StarShine761 avatar Feb 24 '21 00:02 StarShine761

你好, 我也遇到了同样的问题,请问是要try catch 修改源码吗 在 SphDataProcess 中改吗 ?

xiaozhangwx avatar Apr 08 '21 10:04 xiaozhangwx

不好意思很久 没有登录邮箱了 是的 在报错的那里try catch 掉 ,不过后续我已经换掉这个框架了,因为遇到过发送命令下位机无返回数据的情况,应该是由于这套框架引起的

在 2021-04-08 18:08:26,"小张哥" @.***> 写道:

你好, 我也遇到了同样的问题,请问是要try catch 修改源码吗 在 SphDataProcess 中改吗 ?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

StarShine761 avatar Apr 17 '21 07:04 StarShine761

我这边下位机也是无数据返回的,但是我这边发一次数据,一直在这个写入数据的循环,导致不能发送第二次数据。 image

ChloeDimen avatar May 31 '21 02:05 ChloeDimen

不好意思很久 没有登录邮箱了 是的 在报错的那里try catch 掉 ,不过后续我已经换掉这个框架了,因为遇到过发送命令下位机无返回数据的情况,应该是由于这套框架引起的 在 2021-04-08 18:08:26,"小张哥" @.***> 写道: 你好, 我也遇到了同样的问题,请问是要try catch 修改源码吗 在 SphDataProcess 中改吗 ? — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

新的框架在哪?

ChloeDimen avatar May 31 '21 06:05 ChloeDimen

你好 ,这是我现在用的库,目前没有发现问题,自己写的首发线程,这个库只是通过c层增加了停止位等设置 https://github.com/licheedev/Android-SerialPort-API

你这个问题 不太好说 也有可能是调用此方法的数据有问题导致的 ,

在 2021-05-31 10:44:57,"ChloeDimen" @.***> 写道:

我这边下位机也是无数据返回的,但是我这边发一次数据,会多次Byte[15]或byte[16]的数据

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

StarShine761 avatar Jun 16 '21 00:06 StarShine761