begin()

描述

初始化 ModbusGateway 物件,並指定此物件與 Modbus Master 間的通訊模式。

語法


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

參數

gateway1/gateway2ModbusGateway 物件。

mode:指定 ModbusGateway 物件與 Modbus Master 間的通訊模式,其引數分別為 MODBUS_RTUMODBUS_ASCIIMODBUS_TCP

serial:指定 Serial 類別做為傳輸通道。

回傳

bool:如果成功回傳 true,反之回傳 false

範例

#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()
{
}


函式庫參考主頁面

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.