AoeReadSdoObject

使用 EtherCAT ADS (AoE) SDO 法读取从站数据。

语法

KsCommandStatus AoeReadSdoObject(
     int SlaveId,
     int Port,
     int ObIndex,
     int ObSubIndex,
     BOOL CompleteAccess,
     BYTE* Value,
     int Length
);

参数

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

PortEtherCAT 从站连接埠。

ObIndex:欲在物件字典中读取的物件索引。

ObSubIndex:欲在物件字典中读取的物件子索引。

CompleteAccess:TRUE:读取所有子索引;FALSE:读取一个子索引。

Value:欲读取值的指标。

Length:欲读取值的长度(位元)。

回传值

返回 KsCommandStatus 结构。

可用的 EtherCAT 状态

ecatPreOP, ecatSafeOP, ecatOP

范例

复制
//////////////////////////////////////////////////////////////////
//
// This code snippet demonstrates how to configure IO-Link sensors
// connected to IO-Link master and use AoeReadSdoObject to request
// service data stored in these IO-Link devices.
//
//////////////////////////////////////////////////////////////////

KsError nRet = errNoError;
KsCommandStatus Command = { 0 };
char readResult[64] = { 0 };
IoLinkSetting IoLink = {
    17, // IO-Link specification: Version 1.1
    0,  // SPDU
    3,  // Control
    32, // Input length
    0   // Output length
};

nRet = Create(0, 0);

nRet = AddModuleConfiguration(
           1,               // EthercatSlaveID
           0,               // LinkedDeviceID
           configIoLink,    // Protocol
           &IoLink          // Settings
       );

Command = WaitForCommand(30, TRUE, Start());

Command = WaitForCommand(
              5,
              FALSE,
              AoeReadSdoObject(
                  0,                    // SlaveID
                  0x1001,               // Port
                  0x13,                 // ObIndex
                  0,                    // ObSubIndex
                  FALSE,                // CompleteAccess
                  (BYTE*)readResult,    // Value
                  64                    // Length
              )
          );
// Write the 0x13 "Product ID" data to 0x18 "Application Specific Name"
Command = WaitForCommand(5, FALSE, AoeWriteSdoObject(0, 0x1001, 0x18, 0,
                         FALSE, (BYTE*)readResult, 64));

Command = WaitForCommand(5, FALSE, Stop());

使用需求

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

参见

AoeReadCommand

AoeReadWriteCommand

AoeWriteCommand

AoeWriteControlCommand

AoeWriteSdoObject