Package com.serotonin.modbus4j

Examples of com.serotonin.modbus4j.ModbusFactory


        return connectionInfo;

    }

    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


        master = factory.createRtuMaster(params, SerialMaster.SYNC_FUNCTION);
        connectionInfo = "Serial Connection to: " + port;
    }

    private static void configureTCP(Config configuration) {
        ModbusFactory factory = new ModbusFactory();
        IpParameters params = new IpParameters();
        String host = configuration.getStringProperty("host", "localhost");
        System.out.println("host: " + host);
        int tcpport = configuration.getIntProperty("tcpport", 502);
        System.out.println("tcpport: " + tcpport);
        params.setHost(host);
        params.setPort(tcpport);
        master = factory.createTcpMaster(params, true);
        connectionInfo = "TCP Connection to: " + host + ":" + tcpport;
    }
View Full Code Here

TOP

Related Classes of com.serotonin.modbus4j.ModbusFactory

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.