setTimeout()

描述

设定逾时时间。

语法

gateway.setTimeout(timeout)

参数

gatewayModbusGateway 物件。

timeout: 以毫秒为单位设定逾时时间,在 poll 阶段时若逾时将会回传 EXCEPTION_CODEModbus Master

范例

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

#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);

    gateway.setTimeout(500);

}

 

void loop()

{

    gateway.poll();

}

See Also

poll()


函式库参考主页面

86Duino 参考资料的文本遵循 知识共享署名-相同方式共享 3.0 许可证。参考资料中的程式码范例已发布到公共领域。