我想找...

搜尋

分享

目錄

EthercatMaster.getSlaveCount()

[Ethercat Master]

描述

獲取 EtherCAT 總線上的 EtherCAT 從站計數。

語法

uint16_t getSlaveCount();

回傳值

Return the number of slaves on the network. If an error occurs, it will return 0.

備註

This function must be called after a successful execution of EthercatMaster::begin(). This function is non-blocking and can be called within the Cyclic Callback.

範例

#include "Ethercat.h"

EthercatMaster master;

void setup() {
  uint16_t slavecount, i;
  
  Serial.begin(115200);
  master.begin();
  slavecount = master.getSlaveCount();
  
  for (i = 0; i < slavecount; i++)
  {
    Serial.print("Slave");
    Serial.print(i);
  }
}

void loop() {
  // ...
}

Please see the EtherCAT Library User Manual for more QEC EtherCAT instructions and API usage.

返回頂端