Source:
private boolean open() { synchronized (portLock) { if (portState != PortState.CLOSED) { return true; } try { if (!portExists(portName)) { addPortToSystemProperty(portName); } logger.debug("Creating CommPortIdentifier"); CommPortIdentifier portIdentifier = CommPortIdentifier.getPortIdentifier(portName); logger.debug("Opening CommPortIdentifier"); CommPort commPort = portIdentifier.open("org.openhab.binding.dsmr", readTimeoutMSec); logger.debug("Configure serial port"); serialPort = (SerialPort) commPort; serialPort.enableReceiveThreshold(1); serialPort.enableReceiveTimeout(readTimeoutMSec); logger.debug("Configure serial port parameters:" + portSettings); if (portSettings != null) { serialPort.setSerialPortParams(portSettings.getBaudrate(), portSettings.getDataBits(), portSettings.getStopbits(), portSettings.getParity()); if (portSettings == DSMRPortSettings.LOW_SPEED_SETTINGS) { serialPort.setDTR(false); serialPort.setRTS(true); } } else { logger.error("Invalid port parameters, closing port:" + portSettings); return false; } } catch (NoSuchPortException nspe) { logger.error("Could not open port: " + portName, nspe); return false; } catch (PortInUseException piue) { logger.error("Port already in use: " + portName, piue); return false; } catch (UnsupportedCommOperationException ucoe) { logger.error("Port does not support requested port settings " + "(invalid portsettings in openhab.cfg?): " + portName, ucoe); return false; } logger.info("SerialPort opened successful"); try { bis = new BufferedInputStream(serialPort.getInputStream()); } catch (IOException ioe) { logger.error("Failed to get inputstream for serialPort. Closing port", ioe); return false; } logger.info("DSMR Port opened successful"); return true; } }

Target:
private boolean open() { synchronized (portLock) { if (portState != PortState.CLOSED) { return true; } try { if (!portExists(portName)) { logger.warn("Port does not exists according to the system, we will still try to open it", portName); } logger.debug("Creating CommPortIdentifier"); CommPortIdentifier portIdentifier = CommPortIdentifier.getPortIdentifier(portName); logger.debug("Opening CommPortIdentifier"); CommPort commPort = portIdentifier.open("org.openhab.binding.dsmr", readTimeoutMSec); logger.debug("Configure serial port"); serialPort = (SerialPort) commPort; serialPort.enableReceiveThreshold(1); serialPort.enableReceiveTimeout(readTimeoutMSec); logger.debug("Configure serial port parameters: {}", portSettings); if (portSettings != null) { serialPort.setSerialPortParams(portSettings.getBaudrate(), portSettings.getDataBits(), portSettings.getStopbits(), portSettings.getParity()); if (portSettings == DSMRPortSettings.LOW_SPEED_SETTINGS) { serialPort.setDTR(false); serialPort.setRTS(true); } } else { logger.error("Invalid port parameters, closing port:{}", portSettings); return false; } } catch (NoSuchPortException nspe) { logger.error("Could not open port: {}", portName, nspe); return false; } catch (PortInUseException piue) { logger.error("Port already in use: {}", portName, piue); return false; } catch (UnsupportedCommOperationException ucoe) { logger.error( "Port does not support requested port settings " + "(invalid dsmr:portsettings parameter?): {}", portName, ucoe); return false; } logger.info("SerialPort opened successful"); try { bis = new BufferedInputStream(serialPort.getInputStream()); } catch (IOException ioe) { logger.error("Failed to get inputstream for serialPort. Closing port", ioe); return false; } logger.info("DSMR Port opened successful"); return true; } }