I want to find...

Search

Shares

Table of Content

ModbusGateway.setTimeout()

[Modbus]

Description

Set the timeout.

Syntax

gateway.setTimeout(timeout)

Parameters

  • gateway: ModbusGateway object.
  • timeout: Set the timeout time in milliseconds. During the poll phase, if the timeout expires, the EXCEPTION_CODE will be returned to the Modbus Master.

Example

#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


Libraries Reference Home

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.

Leave a Comment

Scroll to Top