0
我要用RXTX庫讀取java中的COM端口。 我想識別AT命令中的字符流。Java用RXTX庫識別AT命令
我的閱讀函數循環一個緩衝區,並將所有內容保存在String var上。
InputStream in; //var sent to function
byte[] buffer = new byte[1024];
int len = -1;
try{
while ((len = in.read(buffer)>-1){
String s = new String(buffer,0,len);
// I've think to save all string into a global var and ciclically
// read after delay che global string and analyze it for bring the
// AT commands
Global.__GLstring += s;
System.out.print(s);
/* Example sout:
AT
OK
BLABLABLA
ERROR
*/
}
} catch (IOException e){
syserr("Exception"+e);
}
如何在後臺創建計時器? 已經有更好的解決方案或功能?
我希望能夠解釋我自己。謝謝大家!