Discovering available comm ports

From Rxtx

(Difference between revisions)
Jump to: navigation, search
(Reverting to last version not containing links to xxellaxx.50webs.com/text/backup-tape/)
 
(24 intermediate revisions not shown)
Line 1: Line 1:
-
[http://keepthefight.50webs.com/description/immagini-folletti.htm immagini folletti] [http://fuckimmetal.50webs.com/www-lord/ www lord21 cl] [http://asl-roma.etista.info/ Asl roma g] [http://biterew.info/aurum-hotel1/ aurum hotel] [http://angolo-testi.anromwe.info/ Angolo testi] [http://litrvalo.50webs.com/apartment-financing/ apartment financing] [http://sandmich.50webs.com/animgif.htm animgif] [http://vetgirlbeth.50webs.com/text/memoria-ram7.htm memoria ram pc 3200 512 mb] [http://fuckimmetal.50webs.com/case-vacanza7/ case vacanza lecce] [http://litrvalo.50webs.com/che-cosa2/ che cosa sono dei video telefoni] [http://chibilis.50webs.com/blog/conflitto-d/ conflitto d interessi in italia] [http://sandmich.50webs.com/download-accellerator.htm download accellerator] [http://mothahcheddah.50webs.com/www-actiongirls/ www actiongirls com] [http://litrvalo.50webs.com/ilari-d/ ilari d amico] [http://chibilis.50webs.com/blog/thenardite/ thenardite] [http://biterew.info/beach-topless/ beach topless] [http://keepthefight.50webs.com/description/microsoft-desktop2.htm microsoft desktop bluetooth] [http://sandmich.50webs.com/prezzo-nokia.htm prezzo nokia n70] [http://mothahcheddah.50webs.com/fishfinder1/ fishfinder 250] [http://astalavista.etista.info/ Astalavista] [http://litrvalo.50webs.com/cosa-vuoi1/ cosa vuoi da me midi] [http://chibilis.50webs.com/blog/la-badessa1/ la badessa di castro] [http://xcskichica.50webs.com/nikon-mm1/ nikon 24mm] [http://sandmich.50webs.com/space-system1.htm space system lcd 30] [http://mothahcheddah.50webs.com/museo-dellaria/ museo dellaria e dello spazio] [http://keepthefight.50webs.com/description/harea.htm harea] [http://fuckimmetal.50webs.com/lavatrice-classe/ lavatrice classe aa] [http://chibilis.50webs.com/blog/abbigliamento-giovane/ abbigliamento giovane] [http://litrvalo.50webs.com/musica-dance/ musica dance 2004] [http://vetgirlbeth.50webs.com/text/volere-e.htm volere e volare] [http://sandmich.50webs.com/king-of12.htm king of queens] [http://biterew.info/bancodisicilia-it/ bancodisicilia it] [http://fuckimmetal.50webs.com/video-pornografico/ video pornografico de la actriz michell] [http://chibilis.50webs.com/blog/calze-vercelli/ calze vercelli] [http://xcskichica.50webs.com/www-latinchat2/ www latinchat cl] [http://chibilis.50webs.com/blog/cortisone/ cortisone] [http://xcskichica.50webs.com/hotel-salerno/ hotel salerno] [http://keepthefight.50webs.com/description/allegro-notaio.htm allegro notaio] [http://vetgirlbeth.50webs.com/text/ram1.htm ram 533] [http://mothahcheddah.50webs.com/i-dieci/ i dieci della legione] [http://agriturismo-mare.buttore.info/ Agriturismo mare] [http://fixenit.info/california-ristorante.html california ristorante] [http://sandmich.50webs.com/pete-seeger.htm pete seeger] [http://keepthefight.50webs.com/description/pornostar-mature.htm pornostar mature] [http://antivirus-grisoft.etista.info/ Antivirus grisoft] [http://chibilis.50webs.com/blog/nuova-mercedes7/ nuova mercedes mi 320 diesel auto nuove] [http://sandmich.50webs.com/om-ramazzini.htm om ramazzini] [http://godsayit.50webs.com/directory/valuto-singolo.htm valuto singolo] [http://keepthefight.50webs.com/description/officina-pan.htm officina pan] [http://sandmich.50webs.com/propagandare.htm propagandare] [http://litrvalo.50webs.com/nikkor-1/ nikkor 85 f1 8] [http://fuckimmetal.50webs.com/tallulah/ tallulah] [http://chibilis.50webs.com/blog/winnie-the/ winnie the pooh pictures] [http://fuckimmetal.50webs.com/carta-rotoli/ carta rotoli a3] [http://sandmich.50webs.com/penna-dell.htm penna dell alpino] [http://godsayit.50webs.com/directory/optio-z.htm optio z 750] [http://fixenit.info/cartoni-cinesi1.html cartoni cinesi porno] [http://fuckimmetal.50webs.com/de-andalucia/ de andalucia yo soy midi] [http://vetgirlbeth.50webs.com/text/memory-stick5.htm memory stick duo 1] [http://adsl-italia.buttore.info/ Adsl italia] [http://xcskichica.50webs.com/literatura-mexica/ literatura mexica] [http://agriturismo-mare.buttore.info/ Agriturismo mare sicilia] [http://xcskichica.50webs.com/decoder-terrestre4/ decoder terrestre humax 5000] [http://biterew.info/belle-donna/ belle donna] [http://godsayit.50webs.com/directory/fabrizio-quattrocchi3.htm fabrizio quattrocchi mpeg] [http://fuckimmetal.50webs.com/ti-poto/ ti poto al mare] [http://vetgirlbeth.50webs.com/text/denni-parkinson.htm denni parkinson] [http://mothahcheddah.50webs.com/gregoriani/ gregoriani] [http://keepthefight.50webs.com/description/just-show.htm just show] [http://fuckimmetal.50webs.com/nefta/ nefta] [http://keepthefight.50webs.com/description/donne-cercano.htm donne cercano uomini] [http://fixenit.info/caneva.html caneva] [http://xcskichica.50webs.com/jeep-lombardia/ jeep lombardia] [http://fixenit.info/campagna-banner.html campagna banner] [http://litrvalo.50webs.com/dostosowany/ dostosowany] [http://vetgirlbeth.50webs.com/text/joan-miro.htm joan miro] [http://fuckimmetal.50webs.com/jumpin-joe/ jumpin joe] [http://keepthefight.50webs.com/description/monologo-benigni.htm monologo benigni] [http://godsayit.50webs.com/directory/pita-de.htm pita de] [http://chibilis.50webs.com/blog/motorola3/ motorola] [http://godsayit.50webs.com/directory/sideways.htm sideways] [http://mothahcheddah.50webs.com/volkswagen-golf10/ volkswagen golf 2 0 tdi] [http://litrvalo.50webs.com/casse-acustiche7/ casse acustiche 2 1 pioneer] [http://godsayit.50webs.com/directory/pda-holder.htm pda holder] [http://sandmich.50webs.com/efail.htm efail 65] [http://sandmich.50webs.com/ino-lazio.htm ino lazio] [http://aermec.buttore.info/ Aermec] [http://xcskichica.50webs.com/ati-x5/ ati x200] [http://sandmich.50webs.com/voli-padova.htm voli padova] [http://vetgirlbeth.50webs.com/text/ram-ddr8.htm ram ddr 266mhz] [http://fuckimmetal.50webs.com/www-annunci/ www annunci it] [http://vetgirlbeth.50webs.com/text/contamination.htm contamination] [http://fuckimmetal.50webs.com/spiata-in/ spiata in albergo] [http://aereoporto-forli.buttore.info/ Aereoporto forli] [http://fuckimmetal.50webs.com/Exploited-moms1/ exploited moms] [http://atac-roma1.etista.info/ Atac roma] [http://sandmich.50webs.com/pla.htm pla] [http://mothahcheddah.50webs.com/avi-ac/ avi ac3 dvd] [http://anggun.anromwe.info/ Anggun] [http://biterew.info/avy-scott/ avy scott] [http://arelpei-cnek.ifrance.com/lib/fotos-rebeldeway/ fotos rebeldeway] [http://dancfiri-dance.ifrance.com/hotel-nevsky/ hotel nevsky san pietroburgo] [http://weaselbitch.50webs.com/text/flaz/ flaz] [http://yourstodestroy.50webs.com/carige-it/ carige it] [http://restartsaber.50webs.com/anyplace-anytime1.htm anyplace anytime] [http://restartsaber.50webs.com/boys-gay1.htm boys gay porn] [http://captlychee.50webs.com/directory/kodex1.htm kodex] [http://arelpei-cnek.ifrance.com/lib/sensori-e/ sensori e trasduttori di pressione] [http://weaselbitch.50webs.com/text/n-palmare/ n50 palmare] [http://darkmordor.50webs.com/description/fiat-bravo15.htm fiat bravo 19 jtd torino] [http://darkmordor.50webs.com/description/io-di.htm io di giorno tu di notte] [http://rndroponyer.50webs.com/lib/soluzione-giochi4/ soluzione giochi playstation 2] [http://restartsaber.50webs.com/adventure-ques.htm adventure ques] [http://lent-san.ifrance.com/data/dorothy-mcguire.htm dorothy mcguire] [http://lent-san.ifrance.com/data/telesilla.htm telesilla] [http://kissy-sait.ifrance.com/nissan-almera4/ nissan almera 1 5] [http://captlychee.50webs.com/directory/dachstein.htm dachstein] [http://ladyshock.50webs.com/finanziamento-perugia/ finanziamento perugia] [http://yourstodestroy.50webs.com/grupo-de/ grupo de bachata] [http://tumma-valo.ifrance.com/html/liberty-city/ liberty city stories] [http://yourstodestroy.50webs.com/marchesin/ marchesin] [http://rhin-per.ifrance.com/anello-amore.htm anello amore] [http://rndroponyer.50webs.com/lib/call-of9/ call of duty ps2] [http://irishais.50webs.com/text/hotel-marina1/ hotel marina in toscana a marina di mass] [http://arelpei-cnek.ifrance.com/lib/diritto-e1/ diritto e valori sociali] [http://captlychee.50webs.com/directory/satellite-m7.htm satellite m40 142] [http://ivo-lisses.ifrance.com/description/immagini-quod.htm immagini quod] [http://genka-manjer.ifrance.com/blog/ferrara-trans/ ferrara trans] [http://arelpei-cnek.ifrance.com/lib/morgan-heritage/ morgan heritage] [http://genka-manjer.ifrance.com/blog/foto-voyeurs/ foto voyeurs] [http://rhin-per.ifrance.com/arredamento-arte.htm arredamento arte povera] [http://rndroponyer.50webs.com/lib/luan-zhegu/ luan zhegu] [http://ear-house.ifrance.com/filtro-benzina/ filtro benzina] [http://rhin-per.ifrance.com/europe-racer.htm europe racer pc] [http://irishais.50webs.com/text/bernie-paz/ bernie paz] [http://rhin-per.ifrance.com/johnny.htm johnny] [http://rndroponyer.50webs.com/lib/sexxy-women/ sexxy women] [http://ear-house.ifrance.com/aaa-catania/ aaa catania] [http://rhin-per.ifrance.com/oliphant-margaret.htm oliphant margaret] [http://arelpei-cnek.ifrance.com/lib/scherzo-rete/ scherzo rete] [http://nikanaw-ru.ifrance.com/blog/hifi-technics1.htm hifi technics] [http://ivo-lisses.ifrance.com/description/cosa-aspettarsi.htm cosa aspettarsi quando] [http://abelle34st.50webs.com/small/audi-a100.htm audi a6 28] [http://ladyshock.50webs.com/favorino/ favorino] [http://kissy-sait.ifrance.com/open-source/ open source sicurezza] [http://ladyshock.50webs.com/samsung-69/ samsung 21 lcd] [http://nikanaw-ru.ifrance.com/blog/cursi.htm cursi] [http://ladyshock.50webs.com/ingravida/ ingravida] [http://weaselbitch.50webs.com/text/porno-video4/ porno video 2004] [http://kissy-sait.ifrance.com/troie-pompinare/ troie pompinare al telefono] [http://rhin-per.ifrance.com/sodimm4.htm sodimm 400] [http://restartsaber.50webs.com/battle-of.htm battle of the year] [http://dancfiri-dance.ifrance.com/tanita-tikaram/ tanita tikaram] [http://lent-san.ifrance.com/data/gessica-alba.htm gessica alba] [http://ladyshock.50webs.com/lettori-divx17/ lettori divx lg] [http://restartsaber.50webs.com/populorum-progressio.htm populorum progressio] [http://rhin-per.ifrance.com/pedale-boss1.htm pedale boss] [http://rhin-per.ifrance.com/voodoo-child.htm voodoo child] [http://ear-house.ifrance.com/toxico/ toxico] [http://lent-san.ifrance.com/data/campeggi-lazio.htm campeggi lazio] [http://ear-house.ifrance.com/nissan-skyline/ nissan skyline] [http://darkmordor.50webs.com/description/pali-in.htm pali in legno] [http://lent-san.ifrance.com/data/whirlpool-at3.htm whirlpool at 313] [http://ivo-lisses.ifrance.com/description/joypad-.htm joypad 8 usb] [http://irishais.50webs.com/text/racconti-erotici36/ racconti erotici piedi] [http://irishais.50webs.com/text/webranking/ webranking] [http://nikanaw-ru.ifrance.com/blog/we-re2.htm we re all living in america] [http://restartsaber.50webs.com/largo-di1.htm largo di mendelssohn] [http://ladyshock.50webs.com/nisam-ti1/ nisam ti ja bilo tko] [http://ear-house.ifrance.com/fate-folletti/ fate folletti elfi] [http://yourstodestroy.50webs.com/tesina-gia/ tesina gia svolte] [http://nikanaw-ru.ifrance.com/blog/tesine-arte.htm tesine arte] [http://captlychee.50webs.com/directory/traduzione-canzone13.htm traduzione canzone eamon fuck it] [http://rndroponyer.50webs.com/lib/autoradio-ingresso2/ autoradio ingresso] [http://lent-san.ifrance.com/data/sicurezza-officine.htm sicurezza officine meccaniche] [http://ear-house.ifrance.com/driver-hsp/ driver hsp56] [http://ivo-lisses.ifrance.com/description/paris-ska.htm paris ska] [http://ladyshock.50webs.com/festa-in/ festa in famiglia] [http://rhin-per.ifrance.com/nudo-randolph.htm nudo randolph] [http://ear-house.ifrance.com/barone-rampante1/ barone rampante capitolo 9] [http://darkmordor.50webs.com/description/sigma-31.htm sigma 24 per minolta] [http://rhin-per.ifrance.com/babbo-natale3.htm babbo natale in laponia] [http://arelpei-cnek.ifrance.com/lib/sapphire-x8/ sapphire x800 256mb agp full retail] [http://captlychee.50webs.com/directory/asus-20.htm asus  mypal a730] [http://nikanaw-ru.ifrance.com/blog/trailer-troy.htm trailer troy] [http://lent-san.ifrance.com/data/news-su2.htm news su alessandra e costantino] [http://genka-manjer.ifrance.com/blog/service-software1/ service software] [http://ear-house.ifrance.com/agenzia-immobiliare19/ agenzia immobiliare studio san martino] [http://rhin-per.ifrance.com/fort-myers1.htm fort myers cose fare] [http://darkmordor.50webs.com/description/salsa-y1.htm salsa y control] [http://weaselbitch.50webs.com/text/chat-con6/ chat con singola  sicilia] [http://restartsaber.50webs.com/il-ratto.htm il ratto del serraglio] [http://kissy-sait.ifrance.com/elton-john8/ elton john dream ticket] [http://weaselbitch.50webs.com/text/bomboniera-vetro/ bomboniera vetro murano] [http://nikanaw-ru.ifrance.com/blog/chrysler-napoli.htm chrysler napoli] [http://dancfiri-dance.ifrance.com/pimpa-it/ pimpa it] [http://ear-house.ifrance.com/ricette-con2/ ricette con mozzarella] [http://dancfiri-dance.ifrance.com/dove-la1/ dove la carita e vera] [http://lent-san.ifrance.com/data/cristina-zavalloni.htm cristina zavalloni] [http://abelle34st.50webs.com/small/wintec-easy.htm 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 [http://java.sun.com/j2se/1.5.0/docs/guide/language/generics.html generics]:
+
http://www.textraccale.com
 +
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 [http://java.sun.com/j2se/1.5.0/docs/guide/language/generics.html generics]:
<b>JDK <= 1.4</b>
<b>JDK <= 1.4</b>
Line 18: Line 19:
                     h.add(com);
                     h.add(com);
                 } catch (PortInUseException e) {
                 } catch (PortInUseException e) {
-
                     System.out.println("Port, "   com.getName()   ", is in use.");
+
                     System.out.println("Port, " + com.getName() ", is in use.");
                 } catch (Exception e) {
                 } catch (Exception e) {
-
                     System.err.println("Failed to open port "   com.getName());
+
                     System.err.println("Failed to open port " + com.getName());
                     e.printStackTrace();
                     e.printStackTrace();
                 }
                 }
Line 46: Line 47:
                     h.add(com);
                     h.add(com);
                 } catch (PortInUseException e) {
                 } catch (PortInUseException e) {
-
                     System.out.println("Port, "   com.getName()   ", is in use.");
+
                     System.out.println("Port, " + com.getName() + ", is in use.");
                 } catch (Exception e) {
                 } catch (Exception e) {
-
                     System.err.println("Failed to open port "   com.getName());
+
                     System.err.println("Failed to open port " com.getName());
                     e.printStackTrace();
                     e.printStackTrace();
                 }
                 }

Latest revision as of 01:23, 10 July 2009

http://www.textraccale.com 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