Type: |
Function |
Available as of: |
SystemInterface_1.34.1.0 |
Support for: |
- |
Versions: |
Current version |
Load data from a device (FTP directory, USB device, RAM disk) on the flash disk of the controller.
This function copies data (data structure like on the flash disk) from the transferred directory (FTP directory, USB device, RAM disk) on the controller and can restart the controller afterwards.
You can select if the existing data on the flash disk has to be deleted beforehand or if the new data overwrites/supplements the old ones.
This function checks the memory space availability on the flash disk first:
i_xDeleteExistingFiles = true: The image has to be smaller than the overall size of the flash
i_xDeleteExistingFiles = false: The image has to be smaller than the free memory of the flash
Must be observed:
Make sure that a valid directory exists from which the data is copied.
Make sure that during the execution no access on the flash disk is performed, for example through the IEC application, via the network, and so on.
The function performs, as an option, a (i_xResetController) and at the end a cold start (ColdReset).
This is why you have to make sure that the devices are in the corresponding rest position before executing the function.
It also means that the successful execution of this function with reset leads to the end of the IEC application.
So only if an error is detected you have to observe the return values / continue the IEC application.
Files that were created before with the FC_BackupAllFiles function can be recovered with the above function.
Input |
Data type |
Description |
---|---|---|
i_sSourcePath |
STRING[1023] |
Path of the files that have to be copied |
i_xDeleteExistingFiles |
BOOL |
True = Deletes the existing files of the flash disk False = Adds new files / replaces old files |
i_xResetController |
BOOL |
True = Controller reset after copying successful False = No controller reset |
Data type |
Description |
---|---|
DINT |
0: The files were copied successfully and the controller was not restarted -1: Error when copying (USB device disconnected too early?) -316: There is not enough memory space available on the flash, is there unnecessary data in the source directory? -318: Invalid path |
Requirement
The complete content of the flash disk is updated by an image on a USB device (Firmware update)
Program
//The complete controller content is on the USB device in the corresponding directory
//(/FlashDisk/Image)
sSourcePath := '/usb2msd16a/image/';
xDeleteExistingFiles := true;
xRebootController := true;
diStatus := FC_RestoreFiles ( sSourcePath, xDeleteExistingFiles, xRebootController );
IF diStatus <> 0 THEN
//Error when copying
;
END_IF
Result
The flash disk image was transferred from the USB device onto the controller and the controller was restarted. The image takes over the new firmware.
Requirement
Transfer the user data from an FTP directory onto the controller
Program
//The user data is on the FTP directory and it was recognized accordingly
strSourcePath := 'FTP_directory/Controller_Image/';
xDeleteExistingFiles := false;
xRebootController := false;
iStatus := FC_RestoreFiles ( strSourcePath, bDeleteExistingFiles, bRebootController );
IF iStatus <> 0 THEN
//Error when copying
;
END_IF
Result
The user data were transferred from the FTP directory onto the controller. But it is possible that they replaced files on the controller that have the same name.