AoeWriteSdoObject
使用 EtherCAT ADS (AoE) SDO 法写入数据至从站。
语法
KsCommandStatus AoeWriteSdoObject(
int SlaveId,
int Port,
int ObIndex,
int ObSubIndex,
BOOL CompleteAccess,
BYTE* Value,
int Length
);
参数
SlaveId:即从站索引 (Slave Index)。此索引是 KINGSTAR 主站于 EtherCAT 网路启动时,根据实体连接顺序自动指派的。直接连线到主站的第一个装置会被指派为索引 0 (Index 0),接著是索引 1、索引 2,依此类推。即使新增、移除或重新连线装置,这些索引在从站阵列中也会保持一致。请参阅 热插拔 (HotConnect)、修复与重启 中的使用案例以了解更多详细资讯。
Port:EtherCAT 从站连接埠。
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 |
参见