[Modbus]
説明
Send a packet command to the Slave node to write to a single Holding Register register.
構文
node1.writeSingleRegister(write_address, write_size)
媒介変数
node1: ModbusMasterNode Object.write_address: The address of the Holding Register to be written to.write_size: The size of the Holding Register to be written to.
戻り値
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;
uint16_t value = 0x12AB;
void setup()
{
while(!Serial);
Serial1.begin(115200);
bus1.begin(MODBUS_RTU, Serial1);
node1.attach(16, bus1);
result = node1.writeSingleRegister(5, value);
if (result != MODBUS_SUCCESS) {
Serial.print("writeSingleRegister => ErrorCode: ");
Serial.println(result);
}
}
void loop() {}See Also
ライブラリリファレンスホーム
86Duinoリファレンスのテキストは、Arduinoリファレンスを改変したもので、Creative Commons Attribution-ShareAlike 3.0ライセンスに基づいてライセンスされています。リファレンス内のコードサンプルはパブリックドメインとして公開されています。