Replace the modem instance if an exception occurs.

This commit is contained in:
akwizgran
2012-11-27 00:05:25 +00:00
parent 14f2fd1995
commit 116e194185

View File

@@ -88,15 +88,18 @@ class ModemPlugin implements DuplexPlugin, Modem.Callback {
// Synchronized to avoid a race condition with stop() // Synchronized to avoid a race condition with stop()
private synchronized boolean resetModem() { private synchronized boolean resetModem() {
if(!running) return false; if(!running) return false;
for(String portName : SerialPortList.getPortNames()) {
modem = modemFactory.createModem(this, portName);
try { try {
modem.init(); modem.init();
return true; return true;
} catch(IOException e) { } catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString()); if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
}
}
running = false; running = false;
return false; return false;
} }
}
public boolean shouldPoll() { public boolean shouldPoll() {
return true; return true;