在serialPort轮询程序中,我需要每秒钟回复一次。但是,我在日志中注意到serialPort.close();
方法需要3秒才能完成。因此我需要等待4秒才能再次轮询端口。有什么想法如何加速港口关闭?为什么会这样?使用RXTXcomm.jar rxtx-2.2pre1。
if (readBufferArray[numBytes-1] == ETXinHex ){
one = one.substring(0,numBytes-1); one = one + "]";
logger.info("add ]");
serialPort.close(); //takes 3 seconds !! to close!!
logger.info("port closed ETX correctly received");
portFound = false;
logger.info("port Found false");
}
2013-12-21 11:22:20,227 [Thread-16] INFO - add [
2013-12-21 11:22:20,227 [Thread-16] INFO - add ]
2013-12-21 11:22:23,227 [Thread-16] INFO - port closed ETX correctly received
2013-12-21 11:22:23,227 [Thread-16] INFO - port Found false