[Modbus]
描述
Send a packet read command to the Slave node to read the Coils register.
語法
node1.readCoils(read_address, read_size)
參數
node1: ModbusMasterNode object.read_address: The starting address of the Coils register to be read.read_size: Size of the Coils register to be read.
回傳
Int: If it succeeds, send back MODBUS_SUCCESS and vice versa, send back EXCEPTION_CODE.
範例
#include <Modbus86.h>
ModbusMaster bus1;
ModbusMasterNode node1;
uint8_t result;
void setup()
{
while(!Serial);
Serial1.begin(115200);
bus1.begin(MODBUS_RTU, Serial1);
node1.attach(16, bus1);
result = node1.readCoils(5, 2);
if (result != MODBUS_SUCCESS) {
Serial.print("readCoils => ErrorCode: ");
Serial.println(result);
} else {
Serial.print("From Coil Status receiveData: ");
Serial.print(node1.getResponseBuffer(0, MODBUS_DATAMODE_BIT));
Serial.print(", ");
Serial.println(node1.getResponseBuffer(1, MODBUS_DATAMODE_BIT));
}
}
void loop() {}也可以看看
函式庫參考主頁面
86Duino 參考的文本是根據 知識共享署名-相同方式分享 3.0 許可證,部分文本是從 Arduino 參考 修改的。 參考中的代碼示例已發佈到公共領域。