Beispiel #1
0
  private void createSerialPort(Dictionary<String, ?> config) {
    serialPort = new NRSerialPortAdapter((String) config.get("port"), 9600);

    if (serialPort == null) {
      logger.error("No Serialport config in openhab.cfg found");
    }

    try {
      serialPort.open();
    } catch (SerialPortException e) {
      logger.error("Failed to open Serialport: %s", e.getMessage());
    }
  }
Beispiel #2
0
  public void deactivate(ComponentContext componentContext) {
    for (PLCBusBindingProvider provider : providers) {
      provider.removeBindingChangeListener(this);
    }
    providers.clear();

    if (serialPort != null) {
      try {
        serialPort.close();
      } catch (SerialPortException e) {
        logger.error(e.getMessage());
      }
    }
  }