AoeReadCommand
Reads data through ADS over EtherCAT (AoE).
Syntax
KsCommandStatus AoeReadCommand(
int SlaveId,
int Port,
int IndexGroup,
int IndexOffset,
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.
IndexGroup: the index group of the object to read.
IndexOffset: the offset of the object in the group.
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 CANopen devices
// connected to CANopen master and use AoeReadCommand to request
// service data stored in these CANopen devices.
// This code snippet is to be used with Beckhoff EL6751 CANopen
// master/slave terminal.
//
//////////////////////////////////////////////////////////////////
KsError nRet = errNoError;
KsCommandStatus Command = { 0 };
CanOpenSetting CanOpen = { 0 };
BYTE byteRead = 0;
BYTE byteWrite = 1;
CanOpen.RxPdoCount = 4;
CanOpen.RxPdos[0] = { TRUE, 16, 0x1800, 0xFF };
CanOpen.RxPdos[1] = { FALSE, 48, 0x1801, 0xFF };
CanOpen.RxPdos[2] = { FALSE, 48, 0x1802, 0xFF };
CanOpen.RxPdos[3] = { FALSE, 0, 0x1803, 0xFF };
CanOpen.TxPdoCount = 4;
CanOpen.TxPdos[0] = { TRUE, 16, 0x1400, 0xFF };
CanOpen.TxPdos[1] = { FALSE, 48, 0x1401, 0xFF };
CanOpen.TxPdos[2] = { FALSE, 48, 0x1402, 0xFF };
CanOpen.TxPdos[3] = { FALSE, 0, 0x1403, 0xFF };
// Send start-up SDO commands so that some settings can be done after KINGSTAR subsystem is started
CanOpen.SdoCommandCount = 1;
CanOpen.SdoCommands[0].Index = 0x6060;
CanOpen.SdoCommands[0].SubIndex = 0;
CanOpen.SdoCommands[0].Length = 1;
CanOpen.SdoCommands[0].Data[0] = 0x1;
nRet = Create(0, 0);
nRet = AddModuleConfiguration(
1, // EthercatSlaveID
0x70, // LinkedDeviceID, it is CANopen device's node ID for CANopen protocol
configCANopen, // Protocol
&CanOpen // Settings
);
Command = WaitForCommand(60, TRUE, Start());
Command = WaitForCommand(
5,
FALSE,
AoeReadCommand(
1, // SlaveID
0x1070, // Port, it is 0x1000 + LinkedDeviceID used in ConfigLinkedDevice
0x6060, // IndexGroup, enter object index here for SDO reading/writing through EL6751
0, // IndexOffset, enter object subindex here for SDO reading/writing through EL6751
&byteRead, // Value
1 // Length
)
);
Command = WaitForCommand(5, FALSE, AoeWriteCommand(1, 0x1070, 0x6060, 0, &byteWrite, 1));
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