begin()
描述
初始化 ModbusSlave
物件,並指定模式與通道。
語法
bus1.begin(mode, serial)
bus2.begin(mode)
參數
bus1/bus2
: ModbusSlave
物件。
mode
:指定 ModbusSlave
物件的通訊模式,其引數分別為 MODBUS_RTU
、 MODBUS_ASCII
或 MODBUS_TCP
。
serial
:當 mode 指定為 MODBUS_RTU
或 MODBUS_ASCII
時必須指定 Serial 類別做為傳輸通道。
回傳
bool
:如果成功回傳 true
,反之回傳 false
範例
#include <Ethernet.h> #include <Modbus86.h> ModbusSlave bus1; ModbusSlave bus2; void setup() { Serial1.begin(115200); bus1.begin(MODBUS_RTU, Serial1); // bus1.begin(MODBUS_ASCII, Serial1); Ethernet.begin(); bus2.begin(MODBUS_TCP); } void loop() { }
See Also
- ModbusSlaveNode::attach()
- ModbusMaster::begin()
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.