lv代购正品:关于java的串口通信的问题

来源:百度文库 编辑:高考问答 时间:2024/05/08 11:36:20
各位大侠们:
大家好,我现在在用JAVA写一个串口通信程序来控制单片机,现在可以发送,但是不能接受,请各位帮帮我啊。
try{
serialport.addEventListener(this);
}
catch(TooManyListenersException e){
;
}
public void serialEvent(SerialPortEvent evt){
if(evt.getEventType()==SerialPortEvent.DATA_AVAILABLE){
int ch;
try{
input=serialport.getInputStream();
ch=input.read();
text.setText("hello"+ch);
}
catch(IOException ee){
}

}
}
看看有什么问题。