在java中获取AT命令的意外结果

在java中获取AT命令的意外结果,java,serial-port,at-command,rxtx,Java,Serial Port,At Command,Rxtx,其次,当我运行整个程序时,没有任何注释,我的手机在最后重新启动。有人能帮我解决这个问题吗。您需要更改打印接收字节数组内容的方式: SMS Sending........ SMS Sending....Port Found It seems OK now **AT Comand response: [B@3820e** SMS Sending........ SMS Sending........ SMS Sending........ SMS Sending........ 而不是:buffe

其次,当我运行整个程序时,没有任何注释,我的手机在最后重新启动。有人能帮我解决这个问题吗。

您需要更改打印接收字节数组内容的方式:

SMS Sending........
SMS Sending....Port Found
It seems OK now
**AT Comand response: [B@3820e**
SMS Sending........
SMS Sending........
SMS Sending........
SMS Sending........
而不是:
buffer.toString()
,后者将打印缓冲区数组的哈希代码。这就是您看到的来自设备的响应


至于第二部分,在注释掉的代码中,尝试取消注释:
outputStream.flush(),可能设备仍在等待AT命令,并且该命令尚未刷新到其输入流。

设置SMS模式时,您从设备获得的响应是什么-您是否获得了正常响应?我将其更改为System.out.println(“输出:+str”);输出后没有响应:您期望得到什么响应?您发送消息的代码已被注释掉。实际上,我首先尝试在发送,因此响应应该是正常的。但是我不想在读取输入流之前尝试执行outputStream.flush()。
SMS Sending........
SMS Sending....Port Found
It seems OK now
**AT Comand response: [B@3820e**
SMS Sending........
SMS Sending........
SMS Sending........
SMS Sending........
String str = new String(buffer);
System.out.println(str);