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,14 +88,17 @@ 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;
try { for(String portName : SerialPortList.getPortNames()) {
modem.init(); modem = modemFactory.createModem(this, portName);
return true; try {
} catch(IOException e) { modem.init();
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString()); return true;
running = false; } catch(IOException e) {
return false; if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
}
} }
running = false;
return false;
} }
public boolean shouldPoll() { public boolean shouldPoll() {