Discovering comm ports

From Rxtx

(Difference between revisions)
Jump to: navigation, search
(revert vandalism)
Line 1: Line 1:
-
Hi guys,
+
This code snippet shows how to find out the available comms ports on your computer.:
-
I found so much useful things here.
+
-
Thank you.  
+
-
[http://tylka.extra.hu/mature-sluts.html mature british sluts] |
+
<pre>
-
[http://tylka.extra.hu/mature-galleries.html adult galleries mature women] |
+
    static void listPorts()
-
[http://tylka.extra.hu/mature-boobs.html busty mature fucking] |
+
    {
-
[http://tylka.extra.hu/mature-ladies.html classy mature ladies]
+
        Enumeration portEnum = CommPortIdentifier.getPortIdentifiers();
 +
        while ( portEnum.hasMoreElements() )
 +
        {
 +
            CommPortIdentifier portIdentifier = (CommPortIdentifier) portEnum.nextElement();
 +
            System.out.println(portIdentifier.getName()  " - "  getPortTypeName(portIdentifier.getPortType()) );
 +
        }       
 +
    }
 +
   
 +
    static String getPortTypeName ( int portType )
 +
    {
 +
        switch ( portType )
 +
        {
 +
            case CommPortIdentifier.PORT_I2C:
 +
                return "I2C";
 +
            case CommPortIdentifier.PORT_PARALLEL:
 +
                return "Parallel";
 +
            case CommPortIdentifier.PORT_RAW:
 +
                return "Raw";
 +
            case CommPortIdentifier.PORT_RS485:
 +
                return "RS485";
 +
            case CommPortIdentifier.PORT_SERIAL:
 +
                return "Serial";
 +
            default:
 +
                return "unknown type";
 +
        }
 +
    }
 +
</pre>

Revision as of 20:36, 19 September 2007

This code snippet shows how to find out the available comms ports on your computer.:

    static void listPorts()
    {
        Enumeration portEnum = CommPortIdentifier.getPortIdentifiers();
        while ( portEnum.hasMoreElements() ) 
        {
            CommPortIdentifier portIdentifier = (CommPortIdentifier) portEnum.nextElement();
            System.out.println(portIdentifier.getName()   " - "   getPortTypeName(portIdentifier.getPortType()) );
        }        
    }
    
    static String getPortTypeName ( int portType )
    {
        switch ( portType )
        {
            case CommPortIdentifier.PORT_I2C:
                return "I2C";
            case CommPortIdentifier.PORT_PARALLEL:
                return "Parallel";
            case CommPortIdentifier.PORT_RAW:
                return "Raw";
            case CommPortIdentifier.PORT_RS485:
                return "RS485";
            case CommPortIdentifier.PORT_SERIAL:
                return "Serial";
            default:
                return "unknown type";
        }
    }
Personal tools