CoeReadSdoObjectDescription

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

Syntax

KsCommandStatus CoeReadSdoObjectDescription(
     int SlaveId,
     SdoObjectDescription* Data
);

Parameters

SlaveId: the slave index. This index value is automatically assigned by the KINGSTAR master when the EtherCAT network starts, based on the physical connection order. The first device connected directly to the master is assigned Index 0, followed by Index 1, Index 2, and so on. These indexes remain consistent within the slave array even if devices are added, removed, or reconnected. Please refer to the use cases in HotConnect, Repair, and Restart for more details.

Data: pointer to the SdoObjectDescription 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

CoeReadSdoEntryDescription

CoeReadSdoObject

CoeReadSdoODList

CoeWriteSdoObject