poll()

描述

接收並解析 Modbus 封包,並根據封包位址將其封包發送至對應節點。

語法


gateway.poll()

參數

gatewayModbusGateway 物件。

回傳

int:已接收到的 Modbus 封包長度。

範例

#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.begin(11, bus);
    node2.begin(12, bus);
    
    gateway.connect(node1);
    gateway.connect(node2);
}

void loop()
{
	gateway.poll();
}


函式庫參考主頁面

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.