Discovering available comm ports

From Rxtx

Revision as of 18:43, 25 September 2007 by IesIpw (Talk | contribs)
Jump to: navigation, search

film porno teen casse 2 1 air zoom vapor furgone noleggio volo hotel in tunisia se mi lasci non vale diventare ricco pierelli casse creative 2200 encounter 2 1 ghost buster brown eyes inside of me bravo club it lultima tappa prole gellar homepage compo com schermi tv yamaha dvd s550 bosch 29609 canon 25 ppm casio exilim exz50 guardia forestale chiamami aquila toner minolta 2400w salvador de bahia la mia banda mio padre che eroe primavera estate autunno inverno baladas midi decapitazione kenneth bigley aloisio giampiero candid camera a luci rosse site batteria panasonic gd93 site the fast and furies cartina stradali italia chicas sexuales homepage bolitas ml 400 mercedes goldfinger acer sempron 2800 512 60 simbolo elettrici hp officejet r65 l uomo volante masini dammela it liquido pulisci monete rack server case ragazze forli travel mate 8101 adsl bbb mele immagini lesbiche icecream pan kimono album foto digitale petit floure nuovo trailer per el matador docking station notebook universale megane cc canon 10x tom tom 5 6630 monitor lcd 17 pollici vyborg laserjet 2100 c4096a url mofa jvc videocamera gzmg30 gran vitara suzuki rei giovanna les cloches frasi di invito a compleanno olympus camedia vi8deos porno crodo decoder sky box mia stone citroen 2 c 6 sharons baby donne in perizoma famiglia simpson trio medusa uomo perfetto stokke thatsit karen inza mouse e tastiere cartomanzia telefonica claude chabrol monitor 20 holly valance kiss kiss cassetto per hard disk de canciones de los altos cumbieros lavoro a domicilio arte della bigiotteria a roma industrial equipment radio di santo domingo map stuv fip seat pagina gialle num pridz michelangelo gregori cyclette kettler corsa sharp traduttore borgo pio roma marna samsung 19 pollici lcd cartuccia magico forca nelly furtado fabri fibra la mia vita firenze parcheggi dans la peau de ma mere i cori rossoneri mante asrock 754 anatomia umana l testut catomania titolatrice palmare supporto auto ragazzi nude sandisk sandisk pompea intimo non ho ciao nemico epson 9500 gli amori toto cotugno odone nicolini trans mestre nogare amstrad dc300 panasonic 300 negrini spade the sims xbox videogiochi racconti di guardoni cialde krups scaletta concerto vasco 2004 rape in iraq frigorifero whirlpool 4170 notebook 6600 torbidita del vino cyber shot dsc t5 nera hotel colombo roma apple 1 pod brockhaus hermann nexus nx 4090 p4c800 edeluxe ram 128 mb gli impianti elettrici libri lavoro oslo tutti i portali hard disk 120 candela maria stella grudg software pdf con frigo salvador dali venezia civico fabri fibra non fare la puttana peugeot 206 14 xs limpero dei sensi n2 nvidia quadro 4500 treadmill tapis roulant embassy hp r3430ea supporto cellulari per auto exilim z57 fotografie con epson cerca albergo imitazione di galeazzi torta dolce hotel micalosu la sfinge doro tosatrice oster amplifier 2 tetraciclina passat km 0 boccaccio 70 registratore digitale vocale microfono je suis malade de lara fabian peugeot 206 ragazzo praha bmw roma traccia itinerario polar s 725 tps new keys washingtonia seggiolino per auto mezzogiorno vittoria prestito belluno hard disk 400 gb video decapitato in diretta iraq indian found love cucina online xerox pe 16 nuova mercedes classe This code snippet shows how to iretrive the available comms ports on your computer. A CommPort is available if it is not being used by another application. Note the differrence between the two examples is that the version for JDK 5.0 up uses generics:

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<CommPortIdentifier> getAvailableSerialPorts() {
        HashSet<CommPortIdentifier> h = new HashSet<CommPortIdentifier>();
        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;
    }
Personal tools