資源簡介
包含RXTX源代碼,各種環境下的jar包以及例子。
win32,64,linux測試通過。
代碼片段和文件信息
JDK?<=?1.4
???/**
?????*?@return????A?HashSet?containing?the?CommPortIdentifier?for?all?serial?ports?that?are?not?currently?being?used.
?????*/
????public?static?HashSet?getAvailableSerialPorts()?{
????????HashSet?h?=?new?HashSet();
????????Enumeration?thePorts?=?CommPortIdentifier.getPortIdentifiers();
????????while?(thePorts.hasMoreElements())?{
????????????CommPortIdentifier?com?=?(CommPortIdentifier)?thePorts.nextElement();
????????????switch?(com.getPortType())?{
????????????case?CommPortIdentifier.PORT_SERIAL:
????????????????try?{
????????????????????CommPort?thePort?=?com.open(“CommUtil“?50);
????????????????????thePort.close();
????????????????????h.add(com);
????????????????}?catch?(PortInUseException?e)?{
????????????????????System.out.println(“Port?“??+?com.getName()?+??“?is?in?use.“);
????????????????}?catch?(Exception?e)?{
????????????????????System.err.println(“Failed?to?open?port?“?+?com.getName());
????????????????????e.printStackTrace();
????????????????}
????????????}
????????}
????????return?h;
????}
JDK?>=?5.0
???/**
?????*?@return????A?HashSet?containing?the?CommPortIdentifier?for?all?serial?ports?that?are?not?currently?being?used.
?????*/
????public?static?HashSet?getAvailableSerialPorts()?{
????????HashSet?h?=?new?HashSet();
????????Enumeration?thePorts?=?CommPortIdentifier.getPortIdentifiers();
????????while?(thePorts.hasMoreElements())?{
????????????CommPortIdentifier?com?=?(CommPortIdentifier)?thePorts.nextElement();
????????????switch?(com.getPortType())?{
????????????case?CommPortIdentifier.PORT_SERIAL:
????????????????try?{
????????????????????CommPort?thePort?=?com.open(“CommUtil“?50);
????????????????????thePort.close();
????????????????????h.add(com);
????????????????}?catch?(PortInUseException?e)?{
????????????????????System.out.println(“Port?“??+?com.getName()?+?“?is?in?use.“);
????????????????}?catch?(Exception?e)?{
????????????????????System.err.println(“Failed?to?open?port?“?+??com.getName());
????????????????????e.printStackTrace();
????????????????}
????????????}
????????}
????????return?h;
????}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????2186??2018-03-27?12:28??rxtx\examples\Discovering?available?comm?ports.java
?????文件???????1026??2018-03-27?12:28??rxtx\examples\Discovering?comm?ports.java
?????文件???????3782??2018-03-27?12:31??rxtx\examples\Event?ba
?????文件???????3029??2018-03-27?12:27??rxtx\examples\ParallelCommunication.java
?????文件???????3077??2018-03-27?12:30??rxtx\examples\Two?way?communcation?with?the?serial?port.java
?????文件????????166??2018-03-27?12:32??rxtx\readme.txt
?????文件?????610316??2018-03-27?12:19??rxtx\rxtx-2.1-7-bins-r2.zip
?????文件????1345757??2018-03-27?12:20??rxtx\rxtx-2.1-7r2-source.zip
?????目錄??????????0??2018-03-27?12:31??rxtx\examples
?????目錄??????????0??2018-03-27?12:32??rxtx
-----------?---------??----------?-----??----
??????????????1969339????????????????????10
評論
共有 條評論