poll()

Description

Receive and parse Modbus packets, and send them to the corresponding node according to the packet address.

Syntax

gateway.poll()

Parameters

gateway: ModbusGateway object.

Return

int: Length of the received Modbus packet.

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

#include <Modbus86.h>

#include <Ethernet.h>

 

ModbusMaster bus;

ModbusMasterNode node1;

ModbusMasterNode node2;

 

ModbusGateway gateway;

 

void setup()

{

    Ethernet.begin();

    Serial485.begin(115200);

 

    gateway.begin(MODBUS_TCP);

 

    bus.begin(MODBUS_RTU, Serial485);

     

    node1.attach(11, bus);

    node2.attach(12, bus);

     

    gateway.connect(node1);

    gateway.connect(node2);

}

 

void loop()

{

    gateway.poll();

}


Library reference

The text of the 86Duino reference is a modification of the Arduino reference, and is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.