Discovering available comm ports

From Rxtx

Revision as of 21:03, 30 September 2007 by MediaWiki spam cleanup (Talk | contribs)
Jump to: navigation, search

immagini folletti www lord21 cl Asl roma g aurum hotel Angolo testi apartment financing animgif memoria ram pc 3200 512 mb case vacanza lecce che cosa sono dei video telefoni conflitto d interessi in italia download accellerator www actiongirls com ilari d amico thenardite beach topless microsoft desktop bluetooth prezzo nokia n70 fishfinder 250 Astalavista cosa vuoi da me midi la badessa di castro nikon 24mm space system lcd 30 museo dellaria e dello spazio harea lavatrice classe aa abbigliamento giovane musica dance 2004 volere e volare king of queens bancodisicilia it video pornografico de la actriz michell calze vercelli www latinchat cl cortisone hotel salerno allegro notaio ram 533 i dieci della legione Agriturismo mare california ristorante pete seeger pornostar mature Antivirus grisoft nuova mercedes mi 320 diesel auto nuove om ramazzini valuto singolo officina pan propagandare nikkor 85 f1 8 tallulah winnie the pooh pictures carta rotoli a3 penna dell alpino optio z 750 cartoni cinesi porno de andalucia yo soy midi memory stick duo 1 Adsl italia literatura mexica Agriturismo mare sicilia decoder terrestre humax 5000 belle donna fabrizio quattrocchi mpeg ti poto al mare denni parkinson gregoriani just show nefta donne cercano uomini caneva jeep lombardia campagna banner dostosowany joan miro jumpin joe monologo benigni pita de motorola sideways volkswagen golf 2 0 tdi casse acustiche 2 1 pioneer pda holder efail 65 ino lazio Aermec ati x200 voli padova ram ddr 266mhz www annunci it contamination spiata in albergo Aereoporto forli exploited moms Atac roma pla avi ac3 dvd Anggun avy scott fotos rebeldeway hotel nevsky san pietroburgo flaz carige it anyplace anytime boys gay porn kodex sensori e trasduttori di pressione n50 palmare fiat bravo 19 jtd torino io di giorno tu di notte soluzione giochi playstation 2 adventure ques dorothy mcguire telesilla nissan almera 1 5 dachstein finanziamento perugia grupo de bachata liberty city stories marchesin anello amore call of duty ps2 hotel marina in toscana a marina di mass diritto e valori sociali satellite m40 142 immagini quod ferrara trans morgan heritage foto voyeurs arredamento arte povera luan zhegu filtro benzina europe racer pc bernie paz johnny sexxy women aaa catania oliphant margaret scherzo rete hifi technics cosa aspettarsi quando audi a6 28 favorino open source sicurezza samsung 21 lcd cursi ingravida porno video 2004 troie pompinare al telefono sodimm 400 battle of the year tanita tikaram gessica alba lettori divx lg populorum progressio pedale boss voodoo child toxico campeggi lazio nissan skyline pali in legno whirlpool at 313 joypad 8 usb racconti erotici piedi webranking we re all living in america largo di mendelssohn nisam ti ja bilo tko fate folletti elfi tesina gia svolte tesine arte traduzione canzone eamon fuck it autoradio ingresso sicurezza officine meccaniche driver hsp56 paris ska festa in famiglia nudo randolph barone rampante capitolo 9 sigma 24 per minolta babbo natale in laponia sapphire x800 256mb agp full retail asus mypal a730 trailer troy news su alessandra e costantino service software agenzia immobiliare studio san martino fort myers cose fare salsa y control chat con singola sicilia il ratto del serraglio elton john dream ticket bomboniera vetro murano chrysler napoli pimpa it ricette con mozzarella dove la carita e vera cristina zavalloni wintec easy palm This code snippet shows how to retrieve the available comms ports on your computer. A CommPort is available if it is not being used by another application. Note the difference 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