Package javax.comm

Examples of javax.comm.CommPortIdentifier


     
      // Go through all available ports
      for (Enumeration e = CommPortIdentifier.getPortIdentifiers(); e
            .hasMoreElements();) {

         CommPortIdentifier portIdentifier = (CommPortIdentifier) e
               .nextElement();
         String name = portIdentifier.getName();

         System.out.println("SerialPortConnection.listenForPort() port found: "
               + name);

         // Can only use serial ports
         if (portIdentifier.getPortType() != CommPortIdentifier.PORT_SERIAL) {
            System.out
                  .println("SerialPortConnection.listenForPort() non serial com port, excluding it: "
                        + name);
            continue;
         }
        
         if (portIdentifier.isCurrentlyOwned()) {
            System.out.println("SerialPortConnection.listenForPort() port already owned, excluding it, owner: " + portIdentifier.getCurrentOwner());
            continue;
         }

         SerialPort serialPort = null;

         // Open the port
         try {
            serialPort = (SerialPort) portIdentifier.open(
                  "BTGPSSimulator.listenForPort()", 2000);
         } catch (PortInUseException pe) {
            System.out
                  .println("SerialPortConnection.listenForPort() port is already used by another application, excluding it: "
                        + name);
View Full Code Here

TOP

Related Classes of javax.comm.CommPortIdentifier

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.