我该怎么做才能读取AT命令的所有响应,我已经创建了一个方法在SendAtCommand.java类中发送AT命令,但它总是给我一些空白结果,这是我的代码:
CommPortIdentifier port = CommPortIdentifier.getPortIdentifier("COM15");
SendAtCommand sendX = new SendAtCommand();
String provMenu= sendX.sendCommand("AT+STGI=0", port);
我尝试使用上面的方法发送AT命令:
AT+STGI=0
AT+STGI=0
+STGI: "i-SEV Menu"
+STGI: 1,3,"Isi Ulang",0
+STGI: 2,3,"Transfer",0
+STGI: 3,3,"Optional",0
sholud的结果(超级终端输出)如下所示:
result
result +STGI: "i-SEV Menu"
result +STGI: 1,3,"Transfer",0
result
result
使用我的代码的结果(java输出)是:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#55000000"
android:orientation="vertical"
>
<uk.ac.kent.sc580.edanews.GridViewItem
android:id="@+id/listImage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop" />
<TextView
android:id="@+id/listTitle"
android:layout_width="match_parent"
android:layout_height="50dp"
android:textColor="@android:color/white"
android:background="#3183b9"
android:ellipsize="end"
android:maxLines="2" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android:id="@+id/listDate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@android:color/white" />
</LinearLayout>
</FrameLayout>
答案 0 :(得分:0)
我认为理由是你做了两次readLine,但只打印了一次。它应该是:
while ((result = is.readLine()) != null) {
try {
(reason
已更改为result
变量)