[Modbus]
説明
Set the quotes to the private array writeData in the ModbusMasterNode class and stack the data automatically with beginTransmission and writeMultipleRegisters without parameters.
writeData is the contents of a Modbus packet using the Write function code.
構文
node1.send(value)
媒介変数
node1: ModbusMasterNode object.value: Fill in the writeData array with the value of the Modbus packet content to be sent, either uint8_t, uint16_t or uint32_t.
例
#include <Arduino.h>
#include <Modbus86.h>
ModbusMaster bus1;
ModbusMasterNode node2;
uint8_t reg[2];
uint8_t result;
void setup()
{
while(!Serial);
bus1.begin(MODBUS_RTU,Serial1);
node2.attach(16, bus1);
reg[0] = 0x1234;
reg[1] = 0xabcd;
node2.beginTransmission(5);
node2.send(reg[0]);
node2.send(reg[1]);
result = node2.writeMultipleRegisters();
if (result != MODBUS_SUCCESS) {
Serial.print("ErrorCode: ");
Serial.println(result);
}
}
void loop() {}See Also
ライブラリリファレンスホーム
86Duinoリファレンスのテキストは、Arduinoリファレンスを改変したもので、Creative Commons Attribution-ShareAlike 3.0ライセンスに基づいてライセンスされています。リファレンス内のコードサンプルはパブリックドメインとして公開されています。