我想找...

搜尋

分享

目錄

EthercatDevice.getODlist()

[Ethercat Device]

描述

Gets a list of objects existing in the object dictionary for such EtherCAT slave device.

語法

int getODlist(uint16_t *  list, uint32_t    list_size, uint32_t *  abortcode = NULL, uint32_t    timeout_us = 100000);

參數

  • [out] uint16_t *list
    The data buffer used to read the list of objects.
  • [in] uint32_t list_size
    The number of objects can be stored in the data buffer.
  • [out] uint32_t *abortcode
    The pointer of the variable used to store the SDO Abort Code.
  • [in] uint32_t timeout_us
    Timeout in microseconds.

回傳值

Return the number of objects in the object list. If the return value is less than 0, it indicates an 錯誤代碼.

備註

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

範例

#include "Ethercat.h"

EthercatMaster master;
EthercatDevice_Generic slave;

uint16_t ODlist[1024];
int rc;

void setup() {
  Serial.begin(115200);

  master.begin();
  slave.attach(0, master);
  master.start(1000000);
}

void loop() {
  rc = sizeof(ODlist) / sizeof(ODlist[0]);
  rc = slave.getODlist(ODlist, rc);
  for (int i = 0; i < rc; i++) {
    Serial.print("Index ");
    Serial.println(ODlist[i]);
  }
}

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

返回頂端