长沙同升湖山庄优缺点:关于java的串口通信的问题

来源:百度文库 编辑:神马品牌网 时间:2024/04/30 13:22:49
各位大侠们:
大家好,我现在在用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){
}

}
}
看看有什么问题。