I want to find...

検索

Shares

Table of Content

ModbusMasterNode.beginTransmission()

[Modbus]

説明

Set the starting address of the register of the Slave device you want to write to, and use it with unquoted writeMultipleCoils or writeMultipleRegisters. See the to illustrate.

構文

node1.beginTransmission(write_address)

媒介変数

  • node1: ModbusMasterNode object.
  • write_address: The starting address of the register of the Slave device you want to write to.

#include <Arduino.h>
#include <Modbus86.h>
 
ModbusMaster bus1;
ModbusMasterNode node2;
 
uint8_t reg[2];
uint8_t result;
 
void setup()
{
    while(!Serial);
    Serial1.begin(115200);
    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


Libraries Reference Home

86Duino のリファレンスのテキストは Arduino レファレンス を編集したもので、 Creative Commons Attribution-ShareAlike 3.0 License下でライセンスされています。リファレンス内のコードサンプルはパブリックドメインとして公開されています。

上部へスクロール