|
Comm API Usage
I am trying to write a JavaSE application using Swing to access the virtual COM port created when connecting a Modem aware device to the USB.
I can see data coming across the COM port via Hyperterminal and I want to write a hyperterminal like application to react to and filter this messaging.
I have tried using the Comm API and followed the API instructions to the letter.
I am using the following code in my JavaSE app:
{
...
private void initCommPorts() {
CommPortIdentifier portId;
Enumeration portList = CommPortIdentifier.getPortIdentifiers();
if (portList == null) {
System.out.println("portList is null");
}
else {
System.out.println(portList.toString());
}
String comPort = "";
while (portList.hasMoreElements()) {
portId = (CommPortIdentifier) portList.nextElement();
System.out.print("Port found");
comPort = portId.getName();
System.out.println("Found port: " + comPort);
// Add COM port to visual object selection list
comChoice.addItem(comPort);
}
}
...
}
The issue is that this code never finds the virtual COM ports. The Enumeration is always empty.
Am I using the right API here. Can the Comm API be used to create a connection to the virtual COM ports in Windows XP?
Thanks guys - and sorry for my ignorance on this matter!
|