GetSlaveById
使用 ID 从指定的从站取得详细讯息。
语法
KsError GetSlaveById(
int SlaveId,
SlaveStatus* Details
);
参数
SlaveId:从站阵列的索引。当 EtherCAT 从站装置启动时,此索引具有与 SlaveId 相同的值,该值对应于从站装置在网路中的位置。请注意,在 EtherCAT 进入运行 (Op) 状态后,加入或移除网路上的任何从站装置将改变各装置在网路中的位置 (SlaveId)。尽管如此,从站的索引将保持不变。新增的装置将排列在阵列的末端。对于更改后的所有从站,索引和 SlaveId 将不再匹配。上述行为模式仅适用于实体装置;不适用于模拟装置。详细资讯请参阅 EnableHotConnect 中的使用案例。
Details:SlaveStatus 结构指标,用以接收从暂状态的详细资讯。
回传值
若此函式执行成功,会回传 errNoError
,否则会传回错误码。更多关于错误码的资讯,请参阅 KsError 清单。
备注
使用 EtherCAT 回路中的从站位置检索指定从站的详细资讯,由于使用的是从站 ID,因此不使用别名资讯。此仅适用于不区分轴或 I/O 的实际从站模组,请在 KINGSTAR 子系统启动后使用
可用的 EtherCAT 状态
ecatInit, ecatBoot, ecatPreOP, ecatSafeOP, ecatOP
范例
复制
SlaveStatus slaveStatus = { 0 };
nRet = GetSlaveById(0, &slaveStatus);
if (nRet == errNoError)
{
// Check the slave information in the SlaveStatus structure.
RtPrintf("Device 0 %s: Vendor 0x%x, Product 0x%x, Revision 0x%x, Serial 0x%x\n",
slaveStatus.Name, slaveStatus.VendorId, slaveStatus.ProductCode,
slaveStatus.RevisionNumber, slaveStatus.SerialNumber);
RtPrintf("Address: Auto %d, Fixed %d, Alias %d\n",
slaveStatus.SlaveId, slaveStatus.PhysAddress, slaveStatus.AliasAddress);
RtPrintf("PDO: Input len %d, Output len %d, Index offset 0x%x\n",
slaveStatus.InputLength, slaveStatus.OutputLength, slaveStatus.VariableIndexOffset);
RtPrintf("State %d, Cycle time %d\n", slaveStatus.State, slaveStatus.CycleTime);
}
使用需求
RT | Win32 | |
---|---|---|
最低支援版本 | 4.0 | 4.0 |
标头档 | ksapi.h | ksapi.h |
程式库 | KsApi_Rtss.lib | KsApi.lib |
参见