readInputRegisters()

Description

Sends a packet command to the Slave node to read the Input Registers register.

Syntax

node1.readInputRegisters(read_address, read_size)

Parameters

node1: ModbusMasterNode object.

read_address: The starting address of the Input Registers register to be read.

read_size: The size of the Input Registers register to be read.

Return

int: If successful, return MODBUS_SUCCESS, otherwise return EXCEPTION_CODE .

Example

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

#include <Modbus86.h>

  

ModbusMaster bus1;

ModbusMasterNode node1;

 

uint8_t result;

uint32_t receiveData;

     

void setup()

{

    while(!Serial);

    Serial1.begin(115200);

    bus1.begin(MODBUS_RTU, Serial1);

    node1.attach(16, bus1);

 

    result = node1.readInputRegisters(5, 2);

 

    if (result != MODBUS_SUCCESS) {

        Serial.print("readInputRegisters => ErrorCode: ");

        Serial.println(result);

    } else {

        Serial.print("From Input Register receiveData: ");

        receiveData = node1.getResponseBuffer(0)

                 | (node1.getResponseBuffer(1) << 16);

 

        Serial.println(receiveData);

    }

}

 

void loop()

{

}

See Also

getResponseBuffer()


Library Reference

The text in the 86Duino reference is modified from the Arduino reference and is licensed under the Creative Commons Attribution-Share Alike 3.0 License  . The code examples in the reference have been released into the public domain.