FoeReadFileToFile

Reads the servo drive's file and saves it on the local machine.

Syntax

KsCommandStatus FoeReadFileToFile(
     int SlaveId,
     BOOL BootState,
     int NameLength,
     char* Name,
     DWORD Password,
     char* File
);

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.

File: a string containing the path to the file you want to read on the disk.

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.

Usable EtherCAT states

ecatBoot, ecatPreOP, ecatSafeOP, ecatOP

Example

Copy
char requestName[32] = "Requested.xml";
char retrievePath[64] = "C:\\Users\\Administrator\\Desktop\\Retrieved.xml";

Command = FoeReadFileToFile(0, TRUE, 32, requestName, 123, retrievePath);

Requirements

  RT Win32
Minimum supported version 4.0 4.0
Header ksapi.h ksapi.h
Library KsApi_Rtss.lib KsApi.lib

See also

FoeReadFileToBuffer

FoeWriteFileFromBuffer

FoeWriteFileFromFile