ftpFileReceive (Function)

Top  Previous  Next

Architecture:

X32 / NX32 / NX32L

Device support:

All

Firmware version:

2.10 / 1.00.00


This function transfers a file from the FTP server to the device.

The file system must already be open with fsMediaOpen or the receive will fail.

 

Note:

The length of the remote name is restricted by the server but the local name must be in 8.3 format.

 

Note:

If the file already exists, it will be replaced without warnings.

 

Input:

ID : INT

The ID returned from ftpConnect.

 

Name : STRING

Name of the file to receive. Both absolute and relative paths are allowed.

 

Local : STRING (Optional)

Alternative name to save file as. Both absolute and relative paths are allowed.

 

Returns: INT

0


- Success.

- 1


- Failed to receive file, see ftpLastResponse.

- 2


- Invalid ID.

- 3


- Invalid local or remote name, e.g. missing remote or local not in 8.3 format.

- 4


- Session is busy with another operation.

- 5


- FTP not open, use ftpOpen to open interface.

- 10


- Communication with server not possible.

 

Declaration:

FUNCTION ftpFileReceive : INT;
VAR_INPUT
  ID   : INT;
  Name : STRING;
  Local : STRING;
END_VAR;

 

Example:

INCLUDE rtcu.inc
 
PROGRAM example;
VAR
  open : BOOL;
  host : STRING := "ftp.domain.com";
  usr   : STRING := "ftpuser";
  pwd   : STRING := "user pwd";
 
  name   : STRING := "test.txt";
 
  id   : INT;
END_VAR;
 
  gsmPower(power := ON);
  gprsOpen();
  fsMediaOpen(media := 0);
 
BEGIN
 open := (ftpOpen() = 0);
IF open THEN
    id := ftpConnect(host := host, username := usr, password := pwd);
    ftpFileReceive(id := id, name := name, local := name);
    ftpDisconnect(id := id);
END_IF;
ftpClose();
END;
END_PROGRAM;