poll()
描述
接收並解析 Modbus 封包,並根據指令存取暫存器與呼叫回呼函式。
當功能碼為 Read 指令時,會先呼叫回呼函式再讀取暫存器回傳;當功能碼為 Write 指令時,會先寫入暫存器再呼叫回呼函式;當功能碼為 ReadWrite 指令時,會先寫入暫存器再呼叫 Write 回呼函式,之後呼叫 Read 回呼函式,最後讀取暫存器回傳。
語法
node1.poll()
node2.poll(buf, size)
參數
node1/node2
:ModbusSlaveNode物件。
buf
:使用者自定義暫存器空間。
size
:該自定義空間之大小。
回傳
int
:已接收到的 Modbus 封包長度。
範例
請參照 Modbus Slave 範例
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.