RXTX.wmv
a problem that happened to some who tried the RXTX Java library instead of the old Javax.comm: the program would hang at the SerialPort.close() method or it would continue running without really closing the port and would throw the "port in use exception" when trying to reopen the same port. Next is the solution for this problem but be careful to observe that the public void closePort() is not a method of the CloseThread class. The CloseThread class is an inner class in the class where I implemented the seria port communication. class CloseThread extends Thread { public void run() { serialPort.removeEventListener(); serialPort.close(); } } public void closePort() { try { if (serialPort != null) { serialPort.getInputStream().close(); serialPort.getOutputStream().close(); new CloseThread().start(); } } catch (Exception e) {} }
Похожие видео
Показать еще