FP_FTP_SET_CONNECTION

Server settings for FTP connection

This FP instruction defines the server settings for the connection to the FTP client specified in the CPU according to specified parameters.

Parameters

Input

sServer (STRING)
  • Server address (required parameter)

    Keyword: SV

    Values: SV0–SV3 (Server 0–Server 3)

  • IP address or host name (required parameter).

    • IP address

      For an IP address, specify the keyword IPv4 or IPv6 at the beginning.

      Syntax for IPv4: e.g. 'IPv4=111.122.133.144'

      Syntax for IPv6: e.g. 'IPv6=1111:122:2:1555:0:0:1888'

      Please note that for IPv4 addresses there are range restrictions. When an invalid IP address is specified with an instruction, there will be no operation error but the output bError will be set to TRUE.

    • Host name

      Keyword: HOST

      Syntax: e.g.'HOST=FTP.pidsx.com'

  • Port number (optional parameter)

    Keyword: 'PORT'

    Syntax: 'PORT=xxxxx'

    Values: 1–65535 (default: 21)

  • Open method (optional parameter)

    Keyword: OPEN

    Syntax: 'OPEN=xxxx'

    Values: act (active), pasv (passive) (default: act)

  • SSL3/TSL1 authentication (optional parameter)

    Specify whether or not to use SSL3/TSL1 authentication.

    Keywords:

    • SSL: Use SSL3/TLS1

    • NON: SSL3/TLS1 not used (default)

Examples:
  1. Connect to FTP server number 0 with the IP address 192.255.2.10, port number 21, active open method, using SSL3/TLS1 authentication: 'SV0,IPv4=192.255.2.10,PORT=21,OPEN=act,SSL'

  2. Connect to FTP server number 1 with the IP address 1111:1222::1555:0:0:1888, port number omitted (use default port 21), open method omitted (use default = active) using SSL3/TLS1 authentication: 'SV1,IPv6=1111:1222::1555:0:0:1888,SSL'

  3. Connect to FTP server number 2 with the host name FTP.pidsx.com, port number 28, passive open method, do not use authentication: 'SV2,HOST=FTP.pidsx.com,PORT=28,OPEN=pasv,NON'

sLogin (STRING)

Set the login data

  • User name (max. 32 characters)

    Keyword: USER

    Syntax: 'USER=xxx' (default: root). Use 'USER=' to delete the user name.

  • Password (max. 32 characters, upper and lower case characters are allowed)

    Keyword: PASS

    Syntax: 'PASS=passwd' (default: root). Use 'PASS=' to delete the password.

For this parameter, there are two additional keywords available:
  • INITIAL: Resets user name and password to the default settings "root" and "root".

  • KEEP: Keeps the current login settings.

Examples:

  1. Set user name to "Admin" and password to "Panasonic": 'USER=Admin,PASS=Panasonic'

  2. Set user name to "Supervisor" and delete the password: 'USER=Supervisor,PASS='

  3. Delete user name and password: 'USER=,PASS='

  4. Reset user name and password to the default values: 'INITIAL'

  5. Keep the current user name and password: 'KEEP'

sCommunication (STRING)

Set optional communication parameters as required.

  • Connection timeout

    Keyword: TOUT

    Syntax: 'TOUT=xxx' (default: 60 seconds)

    Values: 30–300 seconds

  • Number of retries

    Keyword: RTRY

    Syntax: 'RTRY=x' (default: 3 times)

    Values: 0–3

  • Retry interval

    Keyword: RTTM

    Syntax: 'RTTM=xxxxx' (default: 600 seconds)

    Values: 10–86400 seconds

    The value can be specified by 10 seconds. It is rounded down to the 10.

    Example: When you specify 38 seconds, 30 seconds are set.

For this parameter, there are two additional keywords available:

  • INITIAL: Resets connection timeout, number of retries, and the retry interval to the default settings.

  • KEEP: Keeps the current communication settings.

Examples:

  1. Set connection timeout: 30 seconds, number of retries: 2, retry interval: 500 seconds: 'TOUT=30,RTRY=2,RTTM=500'

  2. Set connection timeout: 270 seconds, no retries, retry interval: 4900 seconds: 'TOUT=270,RTRY=0,RTTM=4900'

  3. Set connection timeout: 30 seconds, number of retries: 25, retry interval: do not change: 'TOUT=30,RTRY=25'

  4. Set connection timeout: do not change, number of retries: 25, retry interval: 3000 seconds: ',RTRY=25,RTTM=3000'

  5. Reset to default settings (connection timeout: 60 seconds, number of retries: 3, retry interval: 600 seconds): 'INITIAL'

  6. Keep all the current settings: 'KEEP'

Output

bError (BOOL)

Turns to TRUE under the following conditions:

  • if a timeout of the connection is exceeded

  • if an IP address is invalid

When an error occurs, check the system variable sys_iEthernetConnectionErrorCode for the error code number.

Remarks

  • Separate all keyword entries by comma. e.g. 'NAME=abcd,FROM=sender@server.com'

  • The number of characters for string data must not exceed 256.

  • This instruction is not available in interrupt programs.

  • Upper and lower case characters can be used for operands for which a character constant can be specified. "Abcd", "ABCD" and "abcd" are synonymous, however, file names are case-sensitive.

  • Before you execute the instruction, make sure that sys_bIsEthernetInitializing is FALSE. sys_bIsEthernetInitializing turns to TRUE when the instruction is executed. When you execute the instruction while sys_bIsEthernetInitializing is TRUE, an error occurs.

  • The instruction can only be executed when the transfer request flag for the specified transfer setting or the specified nLogID number is FALSE. When the transfer request flag is TRUE, an operation error occurs.

  • When this instruction has been executed successfully, the system variables sys_bIsCarry and sys_iEthernetConnectionErrorCode are reset.

  • When an error occurs, check the system variable sys_iEthernetConnectionErrorCode for the error code number.

Error flags

sys_bIsOperationErrorHold (turns to TRUE and remains TRUE)
  • if a value specified for a parameter is outside the permissible range.

  • if the same keyword is specified more than once

  • if the transfer request flag for the specified transfer setting is "TRUE: Transfer requested" when the instruction is executed.

  • if the transfer request flag for a specified nLogID number is TRUE, e.g. if sys_blsLog0DataRecordingActive is TRUE.

  • if server numbers are not specified in ascending order.

  • if the instruction is executed in an interrupt program

  • if the number of characters for string data exceeds 256.

sys_bIsOperationErrorNonHold (turns to TRUE for one scan)
  • if a value specified for a parameter is outside the permissible range.

  • if the same keyword is specified more than once

  • if the transfer request flag for the specified transfer setting is "TRUE: Transfer requested" when the instruction is executed.

  • if the transfer request flag for a specified nLogID number is TRUE, e.g. if sys_blsLog0DataRecordingActive is TRUE.

  • if server numbers are not specified in ascending order.

  • if the instruction is executed in an interrupt program

  • if the number of characters for string data exceeds 256.

sys_bIsCarry (turns to TRUE for one scan)
  • if the instruction is executed with an incorrect IP address, sys_iEthernetConnectionErrorCode is set to "1: Incorrect IP address is specified"

  • if the instruction is executed during the initialization of Ethernet, sys_iEthernetConnectionErrorCode is set to "11: Ethernet is being initialized".

Example

POU header

All input and output variables used for programming this function have been declared in the POU header. The same POU header is used for all programming languages.

	VAR
		bError: BOOL:=FALSE;
		wErrorCode: WORD:=0;
		bSetConnectionOK: BOOL:=FALSE;
		bSetConnectionError: BOOL:=FALSE;
		bSetConnection: BOOL:=FALSE;
	END_VAR

POU body

If bSetConnection changes from FALSE to TRUE and sys_bIsEthernetInitializing is FALSE, the instruction is carried out.

LD body

BODY
    WORKSPACE
        NETWORK_LIST_TYPE := NWTYPELD ;
        ACTIVE_NETWORK := 0 ;
    END_WORKSPACE
    NET_WORK
        NETWORK_TYPE := NWTYPELD ;
        NETWORK_LABEL :=  ;
        NETWORK_TITLE :=  ;
        NETWORK_HEIGHT := 9 ;
        NETWORK_BODY
B(B_CONTACT,,bSetConnection,5,1,7,3,R);
B(B_CONTACT,,sys_bIsEthernetInitializing,16,1,18,3,N);
B(B_VARIN,,'SV0~IPv4=192.168.178.64~PORT=21~OPEN=pasv~NON',21,5,23,7,);
B(B_VARIN,,'USER=user~PASS=user',21,6,23,8,);
B(B_VARIN,,'TOUT=30~RTRY=0~RTTM=120',21,7,23,9,);
B(B_VAROUT,,bSetConnectionError,36,5,38,7,);
B(B_F,FP_FTP_SET_CONNECTION!,,23,3,36,9,,?DEN?DsServer?DsLogin?DsCommunication?AENO?CbError);
L(7,2,16,2);
L(1,2,5,2);
L(18,2,18,5);
L(18,5,23,5);
L(1,0,1,9);
        END_NETWORK_BODY
    END_NET_WORK
    NET_WORK
        NETWORK_TYPE := NWTYPELD ;
        NETWORK_LABEL :=  ;
        NETWORK_TITLE :=  ;
        NETWORK_HEIGHT := 4 ;
        NETWORK_BODY
B(B_CONTACT,,bSetConnectionError,6,1,8,3,);
B(B_F,E_MOVE!,,25,0,31,4,,?DEN?D?AENO?C);
B(B_VARIN,,sys_iEthernetConnectionErrorCode,23,2,25,4,);
B(B_VAROUT,,wErrorCode,31,2,33,4,);
L(8,2,25,2);
L(1,2,6,2);
L(1,0,1,4);
        END_NETWORK_BODY
    END_NET_WORK
    NET_WORK
        NETWORK_TYPE := NWTYPELD ;
        NETWORK_LABEL :=  ;
        NETWORK_TITLE :=  ;
        NETWORK_HEIGHT := 3 ;
        NETWORK_BODY
B(B_CONTACT,,bError,6,1,8,3,N);
B(B_COIL,,bSetConnectionOK,28,1,30,3,);
L(8,2,28,2);
L(1,2,6,2);
L(1,0,1,3);
        END_NETWORK_BODY
    END_NET_WORK
END_BODY

ST body

If DF(bSetConnection) AND NOT sys_bIsEthernetInitializing then
    FP_FTP_SET_CONNECTION(sServer := 'SV0,IPv4=192.168.178.64,PORT=21,OPEN=pasv,NON',
                          sLogin := 'USER=user,PASS=user',
                          sCommunication := 'TOUT=30,RTRY=0,RTTM=120', 
                    bError => bSetConnectionError);
End_if;
If (bSetConnectionError) then
    wErrorCode := sys_iEthernetConnectionErrorCode;
End_if;
If NOT bError then
    bSetConnectionOK := TRUE;
End_if;

Modified on: 2024-03-06Feedback on this pagePanasonic hotline