Server settings for HTTP connection
This FP instruction defines the server settings for the connection to the HTTP client specified in the CPU according to specified parameters.
Input
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=HTTP.pidsx.com'
Port number (optional parameter)
Keyword: 'PORT'
Syntax: 'PORT=xxxxx'
Values: 1–65535 (default: 80)
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)
Connect to HTTP server number 0 with the IP address 192.255.2.10, port number 80, using SSL3/TLS1 authentication: 'SV0,IPv4=192.255.2.10,PORT=80,SSL'
Connect to HTTP server number 1 with the IP address 1111:1222::1555:0:0:1888, port number 8080, using SSL3/TLS1 authentication: 'SV1,IPv6=1111:1222::1555:0:0:1888,PORT=8080,SSL'
Connect to HTTP server number 2 with the host name HTTP.pidsx.com, port number 80, do not use authentication: 'SV2,HOST=HTTP.pidsx.com,PORT=80,NON'
Set the login data
User name (max. 32 characters)
Keyword: USER
'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.
INITIAL
: Resets user name and password to the default settings "root" and "root".
KEEP
: Keeps the current login settings.Examples:
Set user name to "Admin" and password to "Panasonic": 'USER=Admin,PASS=Panasonic'
Set user name to "Supervisor" and delete the password: 'USER=Supervisor,PASS='
Set user name to "Support", do not change the password: 'USER=Support'
'USER=,PASS='
Reset user name and password to the default values: 'INITIAL'
'KEEP'
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:
Set connection timeout: 30 seconds, number of retries: 2, retry interval: 500 seconds: 'TOUT=30,RTRY=2,RTTM=500'
Set connection timeout: 270 seconds, no retries, retry interval: 4900 seconds: 'TOUT=270,RTRY=0,RTTM=4900'
Set connection timeout: 30 seconds, number of retries: 25, retry interval: do not change: 'TOUT=30,RTRY=25'
Set connection timeout: do not change, number of retries: 25, retry interval: 3000 seconds: ',RTRY=25,RTTM=3000'
Reset to default settings (connection timeout: 60 seconds, number of retries: 3, retry interval: 600 seconds): 'INITIAL'
Keep all the current settings: 'KEEP'
Output
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.
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.
Do not change the order of keywords. Specify the keywords and their setting parameters in the order they are listed here.
A part of the parameter syntax can be omitted. The settings are not changed when parameters are omitted partially.
When omitting the part before a specified keyword, omit only the keyword, but not the comma "," separating the keywords: ',RTRY=25,RTTM=3000'
.
When omitting the part after a specified keyword, omit both the comma "," and the keyword: 'TOUT=30,RTRY=25'
.
Do not specify the same keyword more than once. If the same keyword is specified more than once, an error occurs.
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 is "FALSE: No transfer request". When the transfer request flag is "TRUE: Transfer requested", 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.
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 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.
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 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.
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".
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
bSetConnectionError: BOOL:=FALSE;
bSetConnection: BOOL:=FALSE;
wErrorCode: WORD:=0;
bSetConnectionOK: BOOL:=FALSE;
END_VAR
If bSetConnection changes from FALSE to TRUE and sys_bIsEthernetInitializing is FALSE, the instruction is carried out.
BODY
WORKSPACE
NETWORK_LIST_TYPE := NWTYPELD ;
ACTIVE_NETWORK := 0 ;
END_WORKSPACE
NET_WORK
NETWORK_TYPE := NWTYPELD ;
NETWORK_LABEL := ;
NETWORK_TITLE := ;
NETWORK_HEIGHT := 10 ;
NETWORK_BODY
B(B_VARIN,,'SV1~IPv4=192.255.2.10~PORT=21~OPEN=act~SSL',20,6,22,8,);
B(B_VARIN,,'USER=root~PASS=passwd',20,7,22,9,);
B(B_VARIN,,'TOUT=30~RTRY=2~RTTM=500',20,8,22,10,);
B(B_CONTACT,,bSetConnection,4,1,6,3,R);
B(B_VAROUT,,bSetConnectionError,36,6,38,8,);
B(B_CONTACT,,sys_bIsEthernetInitializing,17,1,19,3,N);
B(B_F,FP_HTTP_SET_CONNECTION!,,22,4,36,10,,?DEN?DsServer?DsLogin?DsCommunication?AENO?CbError);
L(1,2,4,2);
L(6,2,17,2);
L(19,2,19,6);
L(19,6,22,6);
L(1,0,1,10);
END_NETWORK_BODY
END_NET_WORK
NET_WORK
NETWORK_TYPE := NWTYPELD ;
NETWORK_LABEL := ;
NETWORK_TITLE := ;
NETWORK_HEIGHT := 4 ;
NETWORK_BODY
B(B_CONTACT,,bSetConnectionError,4,1,6,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(6,2,25,2);
L(1,2,4,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,,bSetConnectionError,4,1,6,3,N);
B(B_COIL,,bSetConnectionOK,28,1,30,3,);
L(6,2,28,2);
L(1,2,4,2);
L(1,0,1,3);
END_NETWORK_BODY
END_NET_WORK
END_BODY
If DF(bSetConnection) AND NOT sys_bIsEthernetInitializing then
FP_HTTP_SET_CONNECTION(sServer := 'SV1,IPv4=192.255.2.10,PORT=21,OPEN=act,SSL',
sLogin := 'USER=root,PASS=passwd',
sCommunication := 'TOUT=30,RTRY=2,RTTM=500',
bError => bSetConnectionError);
End_if;
If (bSetConnectionError) then
wErrorCode := sys_iEthernetConnectionErrorCode;
Else
bSetConnectionOK := True;
End_if;