FoeReadFileToBuffer
Reads the servo drive's file and saves it in the user application's memory space.
Syntax
KsCommandStatus FoeReadFileToBuffer(
int SlaveId,
BOOL BootState,
int NameLength,
char* Name,
DWORD Password,
int BufferLength,
BYTE* Buffer,
int* ReadLength
);
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.
BootState: determines whether the EtherCAT slave is to be in the Bootstrap (Boot) state to use FoE. The Boot state can be used to update firmware or configure the slave settings.
TRUE: Boot state.
FALSE: Normal state.
NameLength: the length of the file name to read from the device.
Name: the file name to read from the device.
Password: if the device requires a password to access the file, you need to specify the password here. Zero means there is no password.
BufferLength: the length of the buffer to store the read file.
Buffer: the buffer contains the file to be read.
ReadLength: the length of the file to read from the device.
Return value
Returns the KsCommandStatus structure.
Remarks
- When the EtherCAT link starts properly, the slave's state is Init -> PreOp -> SafeOp -> Op. If the slave is in Op and you use this function with the BootState set to TRUE, the slave's state will become Op -> Init -> Boot. After the task is done, its state becomes Init -> PreOp -> SafeOp -> Op again.
- This function can only be used from RTX64 as pointers. It cannot be shared between RTX64 and Windows.
Usable EtherCAT states
ecatBoot, ecatPreOP, ecatSafeOP, ecatOP
Example
char dataName[32] = "DeviceData.xml";
BYTE* fileBuffer = (BYTE*)malloc(1024);
int byteLength = 0;
Command = FoeReadFileToBuffer(0, TRUE, 32, dataName, 123, 1024, fileBuffer, &byteLength);
Requirements
RT | Win32 | |
---|---|---|
Minimum supported version | 4.0 | 4.0 |
Header | ksapi.h | ksapi.h |
Library | KsApi_Rtss.lib | KsApi.lib |
See also