Article View: borland.public.jbuilder.java.api
Article #142Serial comms
From: asystems
Date: Mon, 24 May 2004 03:38
Date: Mon, 24 May 2004 03:38
45 lines
2070 bytes
2070 bytes
Hi,
I'm very new to java and i'm trying to open serial comm ports using the
javax.comm api, when I run the sample programs to print out which com ports
I have, I get nothing. its not getting past the e.hasMoreElements statement.
I can see the "inside port listener" statement print out, then nothing....
any ideas on what i've done wrong.?
ANY help, would be much appreciated.
import javax.comm.*;
import java.util.*;
public class PortLister {
public PortLister() {
Enumeration e = CommPortIdentifier.getPortIdentifiers();
System.out.println("Inside port lister");
while (e.hasMoreElements()) {
CommPortIdentifier com = (CommPortIdentifier) e.nextElement();
System.out.print(com.getName());
switch(com.getPortType()) {
case CommPortIdentifier.PORT_SERIAL:
System.out.print(", a serial port, ");
break;
case CommPortIdentifier.PORT_PARALLEL:
System.out.print(", a parallel port, ");
break;
default:
// Important since other types of ports like USB
// and firewire are expected to be added in the future.
System.out.print(" , a port of unknown type, ");
break;
}
if (com.isCurrentlyOwned()) {
System.out.println("is currently owned by "
+ com.getCurrentOwner() + ".");
}
else {
System.out.println("is not currently owned.");
}
}
}
}
Alan McIntosh
Technical Details
Message-ID:
<40b16e5b@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!controlnews3.google.com!news1.google.com!news.glorb.com!news.linkpendium.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1089d0,cd9bd5a225837edd,start X-Google-Attributes: gid1089d0,public From: "asystems" <asystems@ozemail.com.au> Newsgroups: borland.public.jbuilder.java.api Subject: Serial comms Date: Mon, 24 May 2004 13:38:22 +1000 Lines: 47 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 NNTP-Posting-Host: 203.102.124.163 Message-ID: <40b16e5b@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1085369947 203.102.124.163 (23 May 2004 20:39:07 -0700) Path: arc1-ca.pugleaf.net!controlnews3.google.com!news1.google.com!news.glorb.com!news.linkpendium.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail