I want to find...

検索

Shares

Table of Content

ModbusMasterNode.setTransmitBuffer()

[Modbus]

説明

Sets the value of the private array writeData in the ModbusMasterNode class.

writeData is the content of the Modbus packet using the Write function code.

構文

node1.setTransmitBuffer(index, value, mode)

媒介変数

  • node1: ModbusMasterNode object.
  • index: the index value of the writeData array.
  • value: the value to be filled in the writeData array, i.e. the content of the Modbus packet to be sent.
  • mode: mode of reading data from writeData array, the citation is MODBUS_DATAMODE_BIT or MODBUS_DATAMODE_UINT16, if no citation is given it will be MODBUS_DATAMODE_UINT16 by default.

戻り値

int: if successful return MODBUS_SUCCESS and vice versa return 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); 
 
    node1.setTransmitBuffer(0, true, MODBUS_DATAMODE_BIT);
    node1.setTransmitBuffer(1, false, MODBUS_DATAMODE_BIT);
    result = node1.writeMultipleCoils(5, 2);   
 
    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下でライセンスされています。リファレンス内のコードサンプルはパブリックドメインとして公開されています。

上部へスクロール