begin()
描述
初始化 ModbusGateway
物件,並指定此物件與 Modbus Master 間的通訊模式。
語法
gateway1.begin(mode, serial)
gateway2.begin(mode)
參數
gateway1/gateway2
: ModbusGateway
物件。
mode
:指定 ModbusGateway
物件與 Modbus Master 間的通訊模式,其引數分別為 MODBUS_RTU
、 MODBUS_ASCII
或 MODBUS_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.