Package com.serotonin.io.serial

Examples of com.serotonin.io.serial.SerialParameters


   * @throws Exception
   */
  public boolean connect () throws Exception{
    SerialDataSourceVO vo = (SerialDataSourceVO) this.getVo();
   
    SerialParameters params = new SerialParameters();
    params.setCommPortId(vo.getCommPortId());
        params.setPortOwnerName("Mango Serial Data Source");
        params.setBaudRate(vo.getBaudRate());
        params.setFlowControlIn(vo.getFlowControlIn());
        params.setFlowControlOut(vo.getFlowControlOut());
        params.setDataBits(vo.getDataBits());
        params.setStopBits(vo.getStopBits());
        params.setParity(vo.getParity());
        params.setRecieveTimeout(vo.getReadTimeout());
   
        if ( SerialUtils.portOwned(vo.getCommPortId()) ){
      raiseEvent(DATA_SOURCE_EXCEPTION_EVENT, System.currentTimeMillis(), true, new TranslatableMessage("event.serial.portInUse",vo.getCommPortId()));
      return false;
        }else{
View Full Code Here


    } catch (Exception e) {
      // TODO: handle exception
    }

    SerialParameters serialParams = new SerialParameters();

    serialParams.setCommPortId(commPortId);
    serialParams.setBaudRate(baudrate);
    serialParams.setDataBits(dataBits);
    serialParams.setStopBits(stopBits);
    serialParams.setParity(parity);

    // System.out.println("serialParams [commPortId]:: " + commPortId);
    // System.out.println("serialParams [baudrate]:: " + baudrate);
    // System.out.println("serialParams [dataBits]:: " + dataBits);
    // System.out.println("serialParams [stopBits]:: " + stopBits);
View Full Code Here

    }

    private static void configureSerial(Config configuration) {
        ModbusFactory factory = new ModbusFactory();
        SerialParameters params = new SerialParameters();
        String port = configuration.getStringProperty("port", "/dev/ttyUSB10");
        int baudrate = configuration.getIntProperty("baudrate", 19200);
        System.out.println("baudrate: " + baudrate);
        int databits = configuration.getIntProperty("data-bits", SerialPort.DATABITS_8);
        System.out.println("databits: " + databits);
        int parity = configuration.getIntProperty("parity", SerialPort.PARITY_EVEN);
        System.out.println("parity: " + parity);
        int stopbits = configuration.getIntProperty("stop-bits", SerialPort.STOPBITS_1);
        System.out.println("stopbits: " + stopbits);
        params.setCommPortId(port);
        params.setBaudRate(baudrate);
        params.setDataBits(databits);
        params.setParity(parity);
        params.setStopBits(stopbits);
        master = factory.createRtuMaster(params, SerialMaster.SYNC_FUNCTION);
        connectionInfo = "Serial Connection to: " + port;
    }
View Full Code Here

TOP

Related Classes of com.serotonin.io.serial.SerialParameters

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.