use of gnu.io.NRSerialPort in project openhab1-addons by openhab.
the class BenqProjectorSerialTransport method serialConnect.
private boolean serialConnect() {
logger.debug("Running connection setup");
try {
logger.debug("Setting up socket connection to " + this.serialDevice);
this.serialPort = new NRSerialPort(this.serialDevice, this.serialSpeed);
this.serialPort.connect();
this.projectorReader = new BufferedReader(new InputStreamReader(this.serialPort.getInputStream()));
this.projectorWriter = new PrintWriter(this.serialPort.getOutputStream(), true);
logger.debug("Serial connection setup successfully!");
return true;
} catch (Exception e) {
logger.error("Unable to connect to device: " + this.serialDevice, e);
}
return false;
}
use of gnu.io.NRSerialPort in project openremote by openremote.
the class NrJavaSerialChannel method doConnect.
@Override
protected void doConnect(SocketAddress remoteAddress, SocketAddress localAddress) throws Exception {
NrJavaSerialAddress remote = (NrJavaSerialAddress) remoteAddress;
final NRSerialPort serial = new NRSerialPort(remote.value(), remote.getBaudRate());
serial.connect();
serialPort = serial.getSerialPortInstance();
if (serialPort == null) {
// No exception is thrown on connect failure so throw one
throw new ConnectTimeoutException("Failed to establish connection to COM port: " + remote.value());
}
serialPort.enableReceiveTimeout(config().getOption(io.netty.channel.rxtx.RxtxChannelOption.READ_TIMEOUT));
deviceAddress = remote;
}
Aggregations