connect()
描述
建立此閘道器與 ModbusMasterNode
物件間的連結,其物件會對應一個通道與節點編號。
語法
gateway.connect(node)
參數
gateway
: ModbusGateway
物件。
node
: ModbusMasterNode
物件,其物件會對應一個通道與節點編號。
回傳
bool
:如果成功回傳 true
,反之回傳 false
範例
#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); } void loop() { gateway.poll(); }
See Also
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.