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