-

Y_CO_FTP_SendFile

Image
This function block uses the FTP (File Transfer Protocol) to write a file to a specified FTP server. The File must already exist on the iC922x Controller's Flash or ramdisk for this function block to read and transfer data to the Destination FTP server. The File must be created by some other method, or refer to ReName_FTP_SendData which doesn’t require a pre existing file.

Parameters

* Parameter Data Type Description Default
VAR_INPUT
B Execute BOOL Upon the rising edge, all other function block inputs are read and the function is initiated. To modify an input, change the value and re-trigger the execute input. FALSE
V Append BOOL To select whether an existing the file on the server should be deleted and rewritten or the new data should be appended to the existing data. FALSE
V Destination Yt_String64 The full file name and destination on the FTP server, e.g. 'metrics/example.csv'. STRING#''
V FTPData Yt_CO_FTP_Data The input structure that configures the FTP transfer such as FTP server address, port, etc. All zeros in structure
V File Yt_String128 The full file name on the controller, see path example in Memory area available for user files in ic92xx STRING#''
VAR_OUTPUT
B Done BOOL Set high when the commanded action has completed successfully. If another block takes control before the action is completed, the Done output will not be set. This output is reset when Execute goes low.
B Busy BOOL Set high upon the rising edge of the Execute input, and reset when Done, CommandAborted, or Error is true. In the case of a function block with an Enable input, a Busy output indicates the function is operating, but not ready to provide Valid information. (No Error)
B Error BOOL Set high if an error has occurred during the execution of the function block. This output is cleared when 'Execute' or 'Enable' goes low.
B ErrorID UINT If Error is true, this output provides the Error ID. This output is reset when 'Execute' or 'Enable' goes low.
V ErrorString Yt_String256 If 'Error' is true and it is an FTP response code related error then this output contains the response string from the FTP server.

Notes

Error Description

See the Function Block ErrorID List.

Basic Functionality Example - Transferring a File

Setting up the FTP Server

In order to use this function block, a FTP server must exist. In this example a local FileZilla FTP Server will be used. Start by connecting to the server on the PC.

Image

Click OK to connect.
Image

Begin by configuring the FTP server settings as shown below:

Image

The settings shown below are the default settings for a locally hosted FTP server.


Create a user 'admin' with the password 'password'. Give the user Read + Write permissions. Create a folder on the desktop of the PC called 'FTP' and copy the path. Add the 'FTP' folder path as a mount point shown below, the corresponding virtual path should be set to '/'. This is the folder that will be used for the FTP server. The destination folder is empty to begin with and the FTP server log has been cleared prior to connection so that the results will be obvious.

Save the changes and start the FileZilla server.

iCube Engineer

This examples demonstrates how to configure the function using the data structure, create a file to send, and execute the Y_CO_FTP_SendFile block.

Here is the code in the "Initialize" ST program which configures the file data and the FTP structure. The FTP server is hosted on a local computer and does not have a domain name. Therefore, FTPIP was used and FTPPort was left blank as the local FTP server is configured to use the default port of 21. The LocalIP is set to the controllers IP and the username/password combination are set.

This program creates a file via the FILE_OPEN, STRING_TO_BUF, FILE_WRITE and FILE_CLOSE functions. The contents of the file in "sample_file_data" is converted from a YC_STRING128 to YC_BYTE128 via the "SAMPLE_TO_BUF" block.


Once the file is created and closed using the FILE_CLOSE function block, the file can be sent to the FTP server using Y_CO_FTP_SendFile.



The results of this block can be seen in the destination file explorer and the FTP server log:




The contents of the file match the "sample_file_data" string and the file can be seen in the explorer. In the FTP server log all of the commands sent can be viewed and it can be seen that the file was transferred properly and successfully.

 


This help information is valid for iCube Engineer Online Help 2025.6

Copyright © 2025 YASKAWA EUROPE GmbH and © 2025 YASKAWA America, Inc.