@@ -0,0 +1,3103 @@
+package com.invertor.examples.modbus;%0A%0Aimport com.invertor.modbus.*;%0Aimport com.invertor.modbus.data.ModbusHoldingRegisters;%0Aimport com.invertor.modbus.exception.ModbusIOException;%0Aimport com.invertor.modbus.exception.ModbusNumberException;%0Aimport com.invertor.modbus.exception.ModbusProtocolException;%0Aimport com.invertor.modbus.msg.request.ReadHoldingRegistersRequest;%0Aimport com.invertor.modbus.msg.response.ReadHoldingRegistersResponse;%0Aimport com.invertor.modbus.serial.SerialParameters;%0Aimport com.invertor.modbus.serial.SerialPortException;%0Aimport com.invertor.modbus.serial.SerialPortFactoryLoopback;%0Aimport com.invertor.modbus.serial.SerialUtils;%0A%0Aimport java.net.UnknownHostException;%0A%0Apublic class ExampleRTU %7B%0A%0A    final static private int slaveId = 1;%0A%0A    public static void main(String%5B%5D argv) %7B%0A        try %7B%0A            SerialParameters serialParameters = new SerialParameters();%0A            /*%0A             Use a virtual serial port SerialPortLoopback%0A             */%0A            SerialUtils.setSerialPortFactory(new SerialPortFactoryLoopback(false));%0A            ModbusSlave slave = ModbusSlaveFactory.createModbusSlaveRTU(serialParameters);%0A            %0A            SerialUtils.setSerialPortFactory(new SerialPortFactoryLoopback(true));%0A            ModbusMaster master = ModbusMasterFactory.createModbusMasterRTU(serialParameters);%0A%0A            master.setResponseTimeout(1000);%0A            slave.setServerAddress(slaveId);%0A            slave.setBroadcastEnabled(true);%0A            slave.setReadTimeout(10000);%0A%0A            ModbusHoldingRegisters holdingRegisters = new ModbusHoldingRegisters(1000);%0A%0A            for (int i = 0; i %3C holdingRegisters.getQuantity(); i++) %7B%0A                //fill%0A                holdingRegisters.set(i, i + 1);%0A            %7D%0A%0A            //place the number PI at offset 0%0A            holdingRegisters.setFloat64At(0, Math.PI);%0A%0A            slave.getDataHolder().setHoldingRegisters(holdingRegisters);%0A%0A            slave.listen();%0A%0A            master.connect();%0A%0A            //prepare request%0A            ReadHoldingRegistersRequest request = new ReadHoldingRegistersRequest();%0A            request.setServerAddress(1);%0A            request.setStartAddress(0);%0A            request.setQuantity(10);%0A            ReadHoldingRegistersResponse response = (ReadHoldingRegistersResponse) request.getResponse();%0A%0A            master.processRequest(request);%0A            ModbusHoldingRegisters registers = response.getHoldingRegisters();%0A            for (int r : registers) %7B%0A                System.out.println(r);%0A            %7D%0A            //get float%0A            System.out.println(%22PI is approximately equal to %22 + registers.getFloat64At(0));%0A            System.out.println();%0A%0A            master.disconnect();%0A            slave.shutdown();%0A        %7D catch (ModbusProtocolException e) %7B%0A            e.printStackTrace();%0A        %7D catch (ModbusIOException e) %7B%0A            e.printStackTrace();%0A        %7D catch (ModbusNumberException e) %7B%0A            e.printStackTrace();%0A        %7D catch (SerialPortException e) %7B%0A            e.printStackTrace();%0A        %7D%0A    %7D%0A%7D%0A

Add a new example.