CoeReadSdoEntryDescription

Reads the description of an entry of an object dictionary from an SDO object through CANopen over EtherCAT (CoE).

Syntax

KsCommandStatus CoeReadSdoEntryDescription(
     int SlaveId,
     SdoEntryDescription* Data
);

Parameters

SlaveId: the index of a slave array. When EtherCAT is started, this index has the same value as the SlaveId, which corresponds to the position of the slave in the network. Please note that after EtherCAT is started in the Operational (Op) state, any addition or removal of slaves from the network will change the position of the slaves in the network (SlaveId). Nevertheless, the index of the slave will remain the same. Newly added devices will be added in the back of the slave array. For all slaves after the change, the index and SlaveId will no longer match. This behavior is only available for physical devices; simulated devices are inapplicable. Please refer to the use cases in EnableHotConnect for more details.

Data: pointer to the SdoEntryDescription structure in which you can indicate a parameter you want to read.

Return value

Returns the KsCommandStatus structure.

Usable EtherCAT states

ecatPreOP, ecatSafeOP, ecatOP

Example

Copy
short length[5] = { 0 }; // For OD list 0
int readLength = 0;
SdoObjectDescription Obj6061 = { 0 }; // For object index 0x6061
Obj6061.Index = 0x6061;
SdoEntryDescription Entry6061_0 = { 0 }; // For object entry 0x6061:0
Entry6061_0.Index = 0X6061;
Entry6061_0.SubIndex = 0;

// Acquire OD list 0
Command = WaitForCommand(5, TRUE, CoeReadSdoODList(0, 0, (BYTE*)length, 10, &readLength));

short* ODList1 = (short*)malloc(length[0] * sizeof(short));
Command = WaitForCommand(5, TRUE, CoeReadSdoODList(0, 1, (BYTE*)ODList1,
                         length[0] * sizeof(short), &readLength)); // Acquire OD list 1

for (int i = 0; i < length[0]; i++)
{
    if (ODList1[i] == 0x6061) {
        Command = WaitForCommand(5, TRUE, CoeReadSdoObjectDescription(0, &Obj6061));
        RtPrintf("SDO Object %x: %s Sub %d, Type %d, Code %d\n", Obj6061.Index, Obj6061.Name,
                 Obj6061.MaxSubIndex, Obj6061.DataType, Obj6061.ObjectCode);
        Command = WaitForCommand(5, TRUE, CoeReadSdoEntryDescription(0, &Entry6061_0));
        RtPrintf("SDO Entry %x:%d Type %d, Length %d, Access %x\n", Entry6061_0.Index,
                 Entry6061_0.SubIndex, Entry6061_0.DataType, Entry6061_0.BitLength,
                 Entry6061_0.ObjectAccess);
    }
}
free(ODList1);

Requirements

  RT Win32
Minimum supported version 4.0 4.0
Header ksapi.h ksapi.h
Library KsApi_Rtss.lib KsApi.lib

See also

CoeReadSdoObject

CoeReadSdoObjectDescription

CoeReadSdoODList

CoeWriteSdoObject