AoeReadSdoObject
Reads data from a slave using the ADS over EtherCAT (AoE) SDO method.
Syntax
KsCommandStatus AoeReadSdoObject(
int SlaveId,
int Port,
int ObIndex,
int ObSubIndex,
BOOL CompleteAccess,
BYTE* Value,
int Length
);
Parameters
SlaveId: the slave index. This index value is automatically assigned by the KINGSTAR master when the EtherCAT network starts, based on the physical connection order. The first device connected directly to the master is assigned Index 0, followed by Index 1, Index 2, and so on. These indexes remain consistent within the slave array even if devices are added, removed, or reconnected. Please refer to the use cases in HotConnect, Repair, and Restart 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: reads all subindexes. FALSE: reads a single subindex.
Value: pointer to the value to be read.
Length: the length in byte of the value to read.
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