嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 2 元微信扫码支付:2 元
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
使用Java语言开发的一个串口调试助手,测试基本没有问题。虽然经过多次修改,但功能还没有完善,可能还存在一些小问题。现在共享给大家,以供想要学习Java串口应用开发的朋友参考。若发现代码有错误之处,还望能够提出改正,大家共同学习,共同进步。有兴趣的朋友也可以在此基础上完善软件的功能。
try {
serialPort.addEventListener(new SerialPortEventListener(){
public void serialEvent(SerialPortEvent event) {
byte[] readBuffer = new byte[1024];
if(autoEmpty.getState() && (singleLineDisplay.getState()&&RxCount1/commRxTxt.getColumns() > 28)||RxCount1 > 1110){
commRxTxt.setText(null);
RxCount1 = 0;
}
int a=0;
try {
while (inputStream.available() > 0) {
a = inputStream.read(readBuffer);
RxCount1 =a;
RxCount =a;
//System.out.println(RxCount);
}
String str=new String(readBuffer).substring(0,a);
/*接收到的数据存放到文本区中*/
if(hexDisplay.getState()){
commRxTxt.append(byteToHex(readBuffer,a));
}
else {
commRxTxt.append(str);
}
if(singleLineDisplay.getState()){
commRxTxt.append("\n\r");
}
} catch (IOException e) { }
RxCountTxt.setText("RX:" RxCount);
}
});
}