use of com.digi.xbee.api.XBeeDevice in project JMRI by JMRI.
the class XBeeTrafficController method connectPort.
/**
* Make connection to existing PortController object.
*/
@Override
@SuppressFBWarnings(value = { "UW_UNCOND_WAIT", "WA_NOT_IN_LOOP" }, justification = "The unconditional wait outside of a loop is used to allow the hardware to react to a reset request.")
public void connectPort(AbstractPortController p) {
// Attach XBee to the port
try {
if (p instanceof XBeeAdapter) {
XBeeAdapter xbp = (XBeeAdapter) p;
xbee = new XBeeDevice(xbp);
xbee.open();
xbee.reset();
try {
synchronized (this) {
wait(2000);
}
} catch (java.lang.InterruptedException e) {
}
xbee.addPacketListener(this);
xbee.addModemStatusListener(this);
xbee.addDataListener(this);
} else {
throw new java.lang.IllegalArgumentException("Wrong adapter type specified when connecting to the port.");
}
} catch (TimeoutException te) {
log.error("Timeout durring communication with Local XBee on communication start up. Error was {} cause {} ", te, te.getCause());
} catch (XBeeException xbe) {
log.error("Exception durring XBee communication start up. Error was {} cause {} ", xbe, xbe.getCause());
}
}
Aggregations