ModbusMasterNode.attach()

[Modbus]

説明

Initialize the ModbusMasterNode object and specify the mounting channel and corresponding node number.

Syntax

node1.attach(slave_id, bus1)
node2.attach(bus2)

Parameters

  • node1/node2: ModbusMasterNode object.
  • slave_id: Specify the corresponding Slave node number; not specifying the number in TCP mode will make the number default to MODBUS_TCP_SLAVE (0xFF).
  • bus1/bus2: Specify the ModbusMaster object to be mounted.

Returns

bool: return true if successful, return false if not.

Example

#include <Ethernet.h>
#include <Modbus86.h>
 
ModbusMaster bus1;
ModbusMaster bus2;
 
ModbusMasterNode node1;
ModbusMasterNode node2;
 
IPAddress SlaveIP(192,168,3,59);
 
void setup()
{
    Serial1.begin(115200);
    bus1.begin(MODBUS_RTU, Serial1);
    // bus1.begin(MODBUS_ASCII, Serial1);
     
    Ethernet.begin();
    bus2.begin(MODBUS_TCP, SlaveIP);
         
    node1.attach(16, bus1);
    node2.attach(bus2);
    // node2.attach(MODBUS_TCP_SLAVE, bus2);
}
 
void loop() {}

See Also


Libraries Reference Home

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

コメントする

上部へスクロール