I've downloaded the RXTXcomm java source and added it to my test application to try and figure out whats wrong...but for the life of me I can't see how its supposed to work.
public static Enumeration getPortIdentifiers() {
//Do not allow anybody get any ports while we are re-initializing
//because the CommPortIndex points to invalid instances during that time
synchronized (Sync) {
//Remember old ports in order to restore them for ownership events later
HashMap oldPorts = new HashMap();
CommPortIdentifier p = CommPortIndex;
while (p != null) {
oldPorts.put(p.portName, p);
p = p.next;
}
//CommPortIndex = null;
//Restore old CommPortIdentifier objects where possible,
//in order to support proper ownership event handling.
//Clients might still have references to old identifiers!
CommPortIdentifier curPort = CommPortIndex;
CommPortIdentifier prevPort = null;
while (curPort != null) {
CommPortIdentifier matchingOldPort =
(CommPortIdentifier) oldPorts.get(curPort.portName);
if ((matchingOldPort != null)
&& (matchingOldPort.portType == curPort.portType)) {
//replace new port by old one
matchingOldPort.driver = curPort.driver;
matchingOldPort.next = curPort.next;
if (prevPort == null) {
CommPortIndex = matchingOldPort;
} else {
prevPort.next = matchingOldPort;
}
prevPort = matchingOldPort;
} else {
prevPort = curPort;
}
curPort = curPort.next;
}
}
return new CommPortEnumerator();
}
I can't see where CommPortIndex gets set-up, its a linked list and declared further up:
static CommPortIdentifier CommPortIndex;
CommPortIdentifier next;
But I don't see anywhere, where CommPortIndex gets assigned to anything.