Please Note This forum exists for community support for the Mango product family and the Radix IoT Platform. Although Radix IoT employees participate in this forum from time to time, there is no guarantee of a response to anything posted here, nor can Radix IoT, LLC guarantee the accuracy of any information expressed or conveyed. Specific project questions from customers with active support contracts are asked to send requests to

Radix IoT Website Mango 3 Documentation Website Mango 4 Documentation Website

  • Hi All,

    Downloading Modbus4J-src from sourceforge, you get a file, called helping you to set up a Modbus/Tcp master ..

    Is something similar available for Modbus RTU?

    The device I'm having supports only the following instructions:
    03 (0x03) Read Holding Registers
    04 (0x04) Read Input Registers
    06 (0x06) Write Single Register
    16 (0x10) Write Multiple Registers
    17 (0x11) Report Slave ID

    In the Modbus specification, register numbers are documented as "one based", but transmitted as "zero based" -- How are the frames created in Modbus4J for the RS485 bus? 1000 is 1000 (0x03E8) or 1001?

    many thanks

  • Is something similar available for Modbus RTU?

    Yes. Just use the factory to create an RTU master.

    1000 is 1000 (0x03E8) or 1001?

    There are multiple ways of creating locators in Modbus4J, but in all cases registers are specified zero-based. If you provide the register range - e.g. "coil" - your register will be 0. If you don't provide the register range (using a different constructor) it will be 1000.

  • Thank you Matthew.

    I was able to use the factory and create the RTU master. The issue I was having was related with the definition of the serial parameters .. This is the code I came up with. It works .. knowing that the slave I'm reading from has the ID 7, and the connection over RS485 (COM6 here) is of "N81" type, at 9600 baudrate .

    package appliancemb;
    import com.serotonin.modbus4j.ModbusFactory;
    import com.serotonin.modbus4j.ModbusMaster;
    import com.serotonin.modbus4j.code.DataType;
    import com.serotonin.modbus4j.code.RegisterRange;
    import com.serotonin.modbus4j.exception.ModbusInitException;
    // declare variables
    public class appliance {
       public static void main(String[] args) throws Exception {
            ModbusFactory factory = new ModbusFactory();
            SerialParameters params = new SerialParameters();
            ModbusMaster master = factory.createRtuMaster(params);
            // master.setRetries(4);
            long start = System.currentTimeMillis();
            // Don't start if the RTU master can't be initialized.
            try {
            } catch (ModbusInitException e) {
              System.out.println( "Modbus Master Init Error: " + e.getMessage());
            try {
                System.out.println("Reg. 1001 Value:" + master.getValue(7, RegisterRange.HOLDING_REGISTER, 1000, DataType.FOUR_BYTE_FLOAT_SWAPPED));
                // more like the above until all required register values are read.
                // ..
            finally {
            System.out.println("Time elapsed: " + (System.currentTimeMillis() - start) + "ms");

    Thanks again.