Thread View: borland.public.jbuilder.java.api
1 messages
1 total messages
Started by asystems
Mon, 24 May 2004 03:38
Serial comms
Author: 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
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads