AoeWriteSdoObject
Writes data to a slave using the ADS over EtherCAT (AoE) SDO method.
Syntax
KsCommandStatus AoeWriteSdoObject(
int SlaveId,
int Port,
int ObIndex,
int ObSubIndex,
BOOL CompleteAccess,
BYTE* Value,
int Length
);
Parameters
SlaveId: the index of a slave array. When EtherCAT is started, this index has the same value as the SlaveId, which corresponds to the position of the slave in the network. Please note that after EtherCAT is started in the Operational (Op) state, any addition or removal of slaves from the network will change the position of the slaves in the network (SlaveId). Nevertheless, the index of the slave will remain the same. Newly added devices will be added in the back of the slave array. For all slaves after the change, the index and SlaveId will no longer match. This behavior is only available for physical devices; simulated devices are inapplicable. Please refer to the use cases in EnableHotConnect for more details.
Port: the EtherCAT slave port.
ObIndex: the index of the object to read in the object dictionary.
ObSubIndex: the subindex of the object to read in the object dictionary.
CompleteAccess: TRUE: writes all subindexes. FALSE: writes a single subindex.
Value: pointer to the value to be written.
Length: the length in byte of the value to write.
Return value
Returns the KsCommandStatus structure.
Usable EtherCAT states
ecatPreOP, ecatSafeOP, ecatOP
Example
//////////////////////////////////////////////////////////////////
//
// 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());
Requirements
RT | Win32 | |
---|---|---|
Minimum supported version | 4.0 | 4.0 |
Header | ksapi.h | ksapi.h |
Library | KsApi_Rtss.lib | KsApi.lib |
See also