@Override public void enableReceiveTimeout(int timeout) throws UnsupportedCommOperationException { if (timeout < 0) { throw new IllegalArgumentException(String.format("timeout must be non negative (is: %d)", timeout)); } try { sp.enableReceiveTimeout(timeout); } catch (gnu.io.UnsupportedCommOperationException ex) { throw new UnsupportedCommOperationException(); } }
@Override public void enableReceiveTimeout(int timeout) throws UnsupportedCommOperationException { if (timeout < 0) { throw new IllegalArgumentException(String.format("timeout must be non negative (is: %d)", timeout)); } try { sp.enableReceiveTimeout(timeout); } catch (gnu.io.UnsupportedCommOperationException ex) { throw new UnsupportedCommOperationException(); } }
// name comes from config and is "COM1", "COM2", ... SerialPort port=(SerialPort)CommPortIdentifier.getPortIdentifier(name).open("YourPortOwnerIdHere",5000); // owner and ms timeout port.setSerialPortParams(bau,dtb,stb,par); port.setFlowControlMode(SerialPort.FLOWCONTROL_RTSCTS_IN|SerialPort.FLOWCONTROL_RTSCTS_OUT); port.enableReceiveTimeout(1000);
sp.enableReceiveTimeout(1000); sp.enableReceiveThreshold(0);
private void tweakPort() { try { port.enableReceiveThreshold(1); port.enableReceiveTimeout(10); } catch (UnsupportedCommOperationException e) { throw new RuntimeException(e); } log.trace("ReceiveThreshold: " + port.getReceiveThreshold() + " ReceiveTimeout: " + port.getReceiveTimeout() + " enabled: " + port.isReceiveTimeoutEnabled() + " DataBits: " + port.getDataBits() + " StopBits: " + port.getStopBits() + " Parity: " + port.getParity()); }
private void tweakPort() { try { port.enableReceiveThreshold(1); port.enableReceiveTimeout(10); } catch (UnsupportedCommOperationException e) { throw new RuntimeException(e); } log.trace("ReceiveThreshold: " + port.getReceiveThreshold() + " ReceiveTimeout: " + port.getReceiveTimeout() + " enabled: " + port.isReceiveTimeoutEnabled() + " DataBits: " + port.getDataBits() + " StopBits: " + port.getStopBits() + " Parity: " + port.getParity()); }
SerialPort serialPort = (SerialPort) portIdentifier.open("org.openhab.binding.satel", 2000); serialPort.setSerialPortParams(19200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); serialPort.enableReceiveTimeout(this.getTimeout());
serialPort.enableReceiveTimeout(100); serialPort.addEventListener(this); serialPort.notifyOnDataAvailable(true);
@Override protected boolean connect() throws IOException { try { final CommPortIdentifier portIdentifier = CommPortIdentifier.getPortIdentifier(port); if(portIdentifier != null) { serialPort = (SerialPort) portIdentifier.open("org.openhab.binding.ebus", 2000); serialPort.setSerialPortParams(2400, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); // set timeout 10 sec. serialPort.disableReceiveThreshold(); serialPort.enableReceiveTimeout(10000); // use event to let readByte wait until data is available, optimize cpu usage serialPort.addEventListener(this); serialPort.notifyOnDataAvailable(true); outputStream = serialPort.getOutputStream(); inputStream = serialPort.getInputStream(); return super.connect(); } } catch (NoSuchPortException e) { logger.error("Unable to connect to serial port {}", port); } catch (PortInUseException e) { logger.error("Serial port {} is already in use", port); } catch (UnsupportedCommOperationException e) { logger.error(e.toString(), e); } catch (TooManyListenersException e) { logger.error("Too many listeners error!", e); } serialPort = null; return false; }
this.serialPort.setSerialPortParams(115200,SerialPort.DATABITS_8,SerialPort.STOPBITS_1,SerialPort.PARITY_NONE); this.serialPort.enableReceiveThreshold(1); this.serialPort.enableReceiveTimeout(ZWAVE_RECEIVE_TIMEOUT); this.receiveThread = new ZWaveReceiveThread(); this.receiveThread.start();
sPort.enableReceiveTimeout( 30 ); } catch ( UnsupportedCommOperationException e ) {
SerialPort.PARITY_NONE); serialPort.enableReceiveThreshold(1); serialPort.enableReceiveTimeout(SERIAL_RECEIVE_TIMEOUT); logger.debug("Starting receive thread"); receiveThread = new ZWaveReceiveThread();