HTTP transfer request
This FP instruction sends a request to the HTTP client specified in nTransferID to start the transfer.
Input
Set the HTTP client ID
Values: 0–15
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.
This instruction is not available in interrupt programs.
Before you execute the instruction, you need to specify the transfer settings using FP_HTTP_SET_MODE or the setting dialog of the HTTP client.
Before you execute the instruction, check if the system variable sys_bIsEthernetHTTPClientReady is TRUE. If it is FALSE when executing the instruction, an error occurs.
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 sys_bIsEthernetCableNotConnected is FALSE.
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 you try to execute the instruction under one of the following conditions, a transfer error occurs and the error code is stored as the execution done code.
Status |
Code |
---|---|
Destination server is not set. |
1 |
Transfer setting is not set. |
2 |
Registering a process request failed. |
4 |
Transfer has been disabled |
5 |
Data decompression failed. (When accessing data with PUT) |
8 |
Data decompression failed. (When accessing data with GET) |
9 |
When an error occurs, check the system variable sys_iEthernetConnectionErrorCode for the error code number.
if the area specified using the index modifier exceeds the limit.
if a value specified for a parameter is outside the permissible range.
if the instruction is executed in an interrupt program.
if the system variable sys_bIsEthernetHTTPClientReady is FALSE when the instruction is executed.
if the transfer request flag for the specified transfer setting is "TRUE: Transfer requested" when the instruction is executed.
if a transfer setting that has not been configured with FP_HTTP_SET_MODE or in the setting dialog of the HTTP client is specified.
if the area specified using the index modifier exceeds the limit.
if a value specified for a parameter is outside the permissible range.
if the instruction is executed in an interrupt program.
if the system variable sys_bIsEthernetHTTPClientReady is FALSE when the instruction is executed.
if the transfer request flag for the specified transfer setting is "TRUE: Transfer requested" when the instruction is executed.
if a transfer setting that has not been configured with FP_HTTP_SET_MODE or in the setting dialog of the HTTP client is specified.
if the instruction is executed while the Ethernet cable is disconnected. sys_iEthernetConnectionErrorCode is set to "10: Ethernet cable disconnected".
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
iID10: INT:=10;
bTransferRequestError: BOOL:=FALSE;
bTransferRequest: BOOL:=FALSE;
END_VAR
If bTransferRequest changes from FALSE to TRUE and the system variable sys_bIsEthernetHTTPClientReady is TRUE, the instruction is carried out. The HTTP transfer is requested for the Ethernet unit 5.
BODY
WORKSPACE
NETWORK_LIST_TYPE := NWTYPELD ;
ACTIVE_NETWORK := 0 ;
END_WORKSPACE
NET_WORK
NETWORK_TYPE := NWTYPELD ;
NETWORK_LABEL := ;
NETWORK_TITLE := ;
NETWORK_HEIGHT := 4 ;
NETWORK_BODY
B(B_CONTACT,,bTransferRequest,5,1,7,3,R);
B(B_VAROUT,,bTransferRequestError,40,2,42,4,);
B(B_VARIN,,iID5,23,2,25,4,);
B(B_CONTACT,,sys_bIsEthernetHTTPClientReady,16,1,18,3,);
B(B_F,FP_HTTP_TRANSFER_REQUEST!,,25,0,40,4,,?DEN?DnID?AENO?CbError);
L(1,2,5,2);
L(7,2,16,2);
L(18,2,25,2);
L(1,0,1,4);
END_NETWORK_BODY
END_NET_WORK
END_BODY
if DF(bTransferRequest) AND sys_bIsEthernetHTTPClientReady then
FP_HTTP_TRANSFER_REQUEST(nTransferID := iID10,
bError => bTransferRequestError);
End_if;