ftpLastResponse (Function)

Top  Previous  Next

Architecture:

X32 / NX32 / NX32L

Device support:

All

Firmware version:

2.10 / 1.00.00


This function will read the last reply from the FTP server.

Using this function may help diagnose general problems like user access rights and missing files.

Only the last line in the response from the server will be returned.

 

Input:

ID : INT

The ID returned from ftpConnect.

 

Output:

Response : STRING

The last reply from server.

 

Returns: INT

0


- Success.

- 1


- No response exists.

- 2


- Invalid ID.

- 4


- Session is busy with another operation.

- 5


- FTP not open, use ftpOpen to open interface.

 

Declaration:

FUNCTION ftpLastResponse : INT;
VAR_INPUT
  ID       : INT;
  Response : ACCESS STRING;
END_VAR;

 

Example:

INCLUDE rtcu.inc
 
PROGRAM example;
VAR
  open : BOOL;
  host : STRING := "ftp.domain.com";
  usr   : STRING := "ftpuser";
  pwd   : STRING := "user pwd";
 
  str   : STRING := "";
  id   : INT;
END_VAR;
 
  gsmPower(power := ON);
  gprsOpen();
 
BEGIN
 open := (ftpOpen() = 0);
IF open THEN
    id := ftpConnect(host := host, username := usr, password := pwd);
    IF id < 0 THEN    
       ftpLastResponse(id := id, response := str);
      DebugMsg(message := "Server reply : " + str);
    END_IF;
    ftpDisconnect(id := id);
END_IF;
ftpClose();
END;
END_PROGRAM;