FP_HTTP_TRANSFER_CONTROL

Control of HTTP transfer to a single Ethernet unit

This FP instruction controls the HTTP transfer to a single Ethernet unit specified by nTransferID (0–15). Valid control words are 'ENABLE', 'DISABLE' and 'CANCEL'.

Parameters

Input

nTransferID (WORD, INT, UINT)

Ethernet unit ID (values: 0–15)

sControl (STRING)

Control string:

  • 'ENABLE': enables HTTP transfer to the Ethernet unit

  • 'DISABLE': disables HTTP transfer to the Ethernet unit

  • 'CANCEL': cancels HTTP transfer to the Ethernet unit

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

  • 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, 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, 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.

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

  • It takes some time to process the transfer cancel request. Check the transfer status with FP_HTTP_GET_STATUS and check if the transfer stops after executing the instruction.

  • 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 any control string other than 'ENABLE', 'DISABLE' or 'CANCEL' is specified for sControl.

  • if the instruction is executed in an interrupt program

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

  • 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.

sys_bIsOperationErrorNonHold (turns to TRUE for one scan)
  • if any control string other than 'ENABLE', 'DISABLE' or 'CANCEL' is specified for sControl.

  • if the instruction is executed in an interrupt program

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

  • 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.

sys_bIsCarry (turns to TRUE for one scan)
  • 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
		bEnable: BOOL:=FALSE;
		bError: BOOL:=FALSE;
		iID5: INT:=5;
	END_VAR

POU body

If bEnable changes from FALSE to TRUE, the instruction is carried out. The control word 'ENABLE' enables the HTTP transfer for the Ethernet unit 5.

LD body

BODY
    WORKSPACE
        NETWORK_LIST_TYPE := NWTYPELD ;
        ACTIVE_NETWORK := 0 ;
    END_WORKSPACE
    NET_WORK
        NETWORK_TYPE := NWTYPELD ;
        NETWORK_LABEL :=  ;
        NETWORK_TITLE :=  ;
        NETWORK_HEIGHT := 5 ;
        NETWORK_BODY
B(B_VARIN,,iID5,15,2,17,4,);
B(B_VARIN,,'ENABLE',15,3,17,5,);
B(B_CONTACT,,bEnable,4,1,6,3,R);
B(B_VAROUT,,bError,32,2,34,4,);
B(B_F,FP_HTTP_TRANSFER_CONTROL!,,17,0,32,5,,?DEN?DnTransferID?DsControl?AENO?CbError);
L(1,2,4,2);
L(6,2,17,2);
L(1,0,1,5);
        END_NETWORK_BODY
    END_NET_WORK
END_BODY

ST body

If DF(bDisable) then   
    FP_HTTP_TRANSFER_CONTROL(nTransferID := iID5,
                             sControl := 'DISABLE',
                             bError => bError);
End_If;

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