I want to find...

Search

Shares

Table of Content

EthercatDevice.getObjectDescription()

[Ethercat Device]

Description

Reads the object description of the specified object addressed by index for such EtherCAT slave device.

Syntax

int getObjectDescription( uint16_t od_index, uint16_t * datatype, uint8_t * max_od_subindex, uint8_t * objcode, char * objname, size_t objname_size, uint32_t * abortcode = NULL, uint32_t  timeout_us = 100000);

int getObjectDescription( uint16_t od_index, uint16_t & datatype, uint8_t & max_od_subindex, uint8_t & objcode, char * objname, size_t objname_size, uint32_t * abortcode = NULL, uint32_t timeout_us = 100000);

Parameters

  • [in] uint16_t od_index
    Index of the object.
  • [out] uint16_t *datatype
    The variable used to store the data type. Please refer to A.6 Data Type.
  • [out] uint8_t *max_od_subindex
    Maximum number of subindexes of the object.
  • [out] uint8_t *objcode
    Object code.
    • 7: Variable
    • 8: Array
    • 9: Record
  • [out] char objname
    Name of the object. The buffer used to store the object name.
  • [in] size_t objname_size
    The size of the buffer for the object name.
  • [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 Value

Return an error code. If the returned value is zero, it indicates a successful execution of this function.

Comment

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

Example

#include "Ethercat.h"

EthercatMaster master;
EthercatDevice_Generic slave;

uint16_t DataType;
uint8_t MaxSubindex, ObjectCode;
char ObjectName[64];

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

  master.begin();
  slave.attach(0, master);
  slave.getObjectDescription(0x1C12, DataType, MaxSubindex, ObjectCode, ObjectName, sizeof(ObjectName));
  Serial.print("Data Type: ");
  Serial.println(DataType);
  Serial.print("Object Code: ");
  Serial.println(ObjectCode);
  Serial.print("Max Subindex: ");
  Serial.println(MaxSubindex);
  Serial.print("Object Name: ");
  Serial.println(ObjectName);
}

void loop() {
  // ...
}

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

Leave a Comment

Scroll to Top