I've written a simple test program which makes calls to the native libary:
for( File objFile : aryFiles ) {
Enumeration ePorts = CommPortIdentifier.getPortIdentifiers();
String strName = objFile.getName();
if ( strName.startsWith(strPrefix) != true ) {
continue;
}
if ( marylstDevices == null ) {
marylstDevices = new ArrayList<CommPortIdentifier>();
}
String strAbsPath = objFile.getAbsolutePath();
System.out.println(strAbsPath);
System.out.println("More elements: " + ePorts.hasMoreElements() );
while ( ePorts.hasMoreElements() ) {
CommPortIdentifier portId = (CommPortIdentifier)ePorts.nextElement();
System.out.println("Port Type: " + portId.getPortType() + ", " + CommPortIdentifier.PORT_SERIAL);
if ( portId.getPortType() == CommPortIdentifier.PORT_SERIAL ) {
System.out.println(strAbsPath);
if ( portId.getName().compareToIgnoreCase(strAbsPath) == 0 ) {
marylstDevices.add(portId);
}
}
}
}
Although the loop displays the following:
/dev/ttyS13
/dev/ttyATH0
/dev/ttyS15
/dev/ttyS14
/dev/ttyS12
/dev/ttyS11
/dev/ttyS10
/dev/ttyS9
/dev/ttyS8
/dev/ttyS7
/dev/ttyS6
/dev/ttyS5
/dev/ttyS4
/dev/ttyS3
/dev/ttyS2
/dev/ttyS1
/dev/ttyS0
/dev/tty
When I examine the enumerator for the ports, there are no elements. Should I be able to detect a serial device?