偶写了一个线程用串口事件SerialPortEvent来监听串口,如果有数据则进行相应的操作。
不过我只要监听用串口连接电脑的硬件发上来的数据,而我的上层软件通过串口向下发给硬件的数据不要触发事件怎么实现啊???
public void serialEvent(SerialPortEvent event) {
switch (event.getEventType()) {
case SerialPortEvent.BI:
case SerialPortEvent.OE:
case SerialPortEvent.FE:
case SerialPortEvent.PE:
case SerialPortEvent.CD:
case SerialPortEvent.CTS:
case SerialPortEvent.DSR:
case SerialPortEvent.RI:
case SerialPortEvent.OUTPUT_BUFFER_EMPTY:
break;
//if have data from serialPort
case SerialPortEvent.DATA_AVAILABLE:
-------进行相应的操作。
不过我只要监听用串口连接电脑的硬件发上来的数据,而我的上层软件通过串口向下发给硬件的数据不要触发事件怎么实现啊???
public void serialEvent(SerialPortEvent event) {
switch (event.getEventType()) {
case SerialPortEvent.BI:
case SerialPortEvent.OE:
case SerialPortEvent.FE:
case SerialPortEvent.PE:
case SerialPortEvent.CD:
case SerialPortEvent.CTS:
case SerialPortEvent.DSR:
case SerialPortEvent.RI:
case SerialPortEvent.OUTPUT_BUFFER_EMPTY:
break;
//if have data from serialPort
case SerialPortEvent.DATA_AVAILABLE:
-------进行相应的操作。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货