CoeReadSdoEntryDescription

透过 EtherCAT CANopen (CoE) 从 SDO 读取物件字典分录的描述。

语法

KsCommandStatus CoeReadSdoEntryDescription(
     int SlaveId,
     SdoEntryDescription* Data
);

参数

SlaveId:从站阵列的索引。当 EtherCAT 从站装置启动时,此索引具有与 SlaveId 相同的值,该值对应于从站装置在网路中的位置。请注意,在 EtherCAT 进入运行 (Op) 状态后,加入或移除网路上的任何从站装置将改变各装置在网路中的位置 (SlaveId)。尽管如此,从站的索引将保持不变。新增的装置将排列在阵列的末端。对于更改后的所有从站,索引和 SlaveId 将不再匹配。上述行为模式仅适用于实体装置;不适用于模拟装置。详细资讯请参阅 EnableHotConnect 中的使用案例。

Data:可指示欲读取参数的 SdoEntryDescription 结构指标。

回传值

返回 KsCommandStatus 结构。

可用的 EtherCAT 状态

ecatPreOP, ecatSafeOP, ecatOP

范例

复制
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);

使用需求

  RT Win32
最低支援版本 4.0 4.0
标头档 ksapi.h ksapi.h
程式库 KsApi_Rtss.lib KsApi.lib

参见

CoeReadSdoObject

CoeReadSdoObjectDescription

CoeReadSdoODList

CoeWriteSdoObject