Discovering available comm ports

From Rxtx

Revision as of 19:01, 29 January 2008 by DarraCzelc (Talk | contribs)
Jump to: navigation, search

sitemap partition magic error 48 foodchannel.com advent child fantasy final movie part baby vagina close continetal airlines bigass southall travels in uk assemble product work from home part school suzuki violin violin sign holders alltheweb video search angelpotion video codecs maxiyoung http soccer pictures import girls wallpaper adult excalibur video lathe guards archive safety video volvo 4 color newsletters my next door neighbor abilene movie texas theater link motorcycle scooter small angelina ballerina videos vintage trailer joint biological point detection system jbpds employee review form arabian night movie animated guide movie open lips ny jets wallpapers adam eve lampoons movie national motor driven timer air filter gas oil water alfee movie efficient britney spears topless drunk mom columbine high picture school shooting cargadores vehiculares para celulares hermione granger xxx checkers auto roadhouse blues original he man medieval times toronto picture cable internet steal circus tent sale insect bite appearance online casino business sitemap queen bee gardens jealousy amethyst crystal home selling a home in scottsdale link sweeping machine add production site video home austrian airlines by fergalicious fergie lyric 1997 ford mustang specs web black like me avi codec video web amateur film movie pornographic teenage natural cures usps palos heights illinois zip code employee give self service state sand box antonio sabato jr movies aol free music video watch 6 bestshack.info showers.html taking teen puggle puppy anal anal ass butthole d.p double double double dp fuck fuck penetration confidentiality agreement activation cell code lg phone programming verizon adult japanese video on demand addicted movie adult free movie rated x protective apparel super mario toys jpmorgan david jewelry replica yurman orange free text messages link norval morrisseau take everything left from me raphael saadiq nelson mandela biography guide local movie theater site eight hundred go adult live web video chat download ringtones web basketball man ncaa tournament bench plan wood work link school bullying prevention pbs kid domain o2 mobile phone teen girl masturbates cherry monroe pet birds nascar 2005 a farewell to arms movie chicago tribune home static control products thirfty car rental puppydog surveyor job descriptions marriage bed forum sitemap usb oscilloscope sitemap kellys kids childrens clothing avi convert dvd movie mold allergy allergies asthma magicien discount books link acts of worship the movie rebecca email marketing campaign sitemap live video chat room adult movie post sex telugu boothu kathalu mcafee virus scan www fast cars and freedom lyrics gooseneck trailers wallpaper dn angel dandelion adidas sale sneaker port of seattle police department peter coppola hair san diego, california audio reliable video 310 566 1063 vh2 online tarot card reading anal first movie painful sex time video family dentistry park rapids www avi ts video asian nurse movies add production url video credit reporting agencies consumer report refrigerator web cam chat dodd darin audie murphy movie play poker jennifer love hewitt wallpaper cool halloween costume atomicbomb video acne treatment mercedes maybach cell katana phone sprint used domain web unforgiven 2003 results free swingers the lifestyle lift procedure conversion chart www buy melatonin natural order source sublingual equipment nation rent rental sterling silver wholesale body jewelry meaning peach rose signs and symptoms of leukemia in children colon cancer symptoms sitemap sbs internet roulette domain banana muffin recipe discount drug plan prescription fighting fish adult adultdvdonlinestore.net gay hot movie sex video hawaii discount realty abi download free titmus video alta dome gay gay movie movie post website 50 cent song award video drivers embroidered hat and cap dental postcards xavier naidoo songtexte mmmm url lorabel rey dronrac 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