begin()

Description

Initializes a ModbusGateway object and specifies the communication mode between this object and the Modbus master.

Syntax

gateway1.begin(mode, serial) gateway2.begin(mode)

Parameters

gateway1/gateway2: ModbusGateway object.

mode: Specifies the communication mode between the ModbusGateway object and the Modbus master. Arguments are MODBUS_RTU, MODBUS_ASCII, or MODBUS_TCP.

serial: Specifies the Serial class as the transmission channel.

Return Value

bool: Returns true on success, false otherwise.

Example

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

#include <Modbus86.h>

#include <Ethernet.h>

 

ModbusGateway gateway1;

ModbusGateway gateway2;

 

void setup()

{

    Serial485.begin(115200);

    gateway1.begin(MODBUS_RTU, Serial485);

     

    Ethernet.begin();

    gateway2.begin(MODBUS_TCP);

}

 

void loop()

{

}

Library Reference Homepage

The text in the 86Duino reference material is licensed under the Creative Commons Attribution-ShareAlike 3.0 License. Code examples in the reference material are released into the public domain.