FP_HTTP_GET_DATA_FORMAT

Generate data format string for HTTP protocol

This FP instruction generates a string specifying the data format (FP address and length). It writes the string into the output variable sDataFormat that is suitable for the input sPLCDataFormat of the instruction FP_HTTP_SET_MODE.

Parameters

Input

Var (STRING)

String containing ASCII data

nNumberOfCharacters (WORD, INT, UINT)

Size of data in word or for strings in byte units.

Output

sDataFormat (STRING)

String specifying the data format for the input sPLCDataFormat of FP_HTTP_SET_MODE

Remarks

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

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

  • This instruction does not overwrite the Ethernet configuration data stored in the PLC permanently. When the PLC has been switched off and on again, the Ethernet configuration data stored in the PLC are used again.

  • After the HTTP client transfer settings have been configured, data is actually sent or acquired when the instruction FP_HTTP_TRANSFER_REQUEST is executed.

  • 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 timeout of the connection is exceeded

  • if an IP address is invalid

sys_bIsOperationErrorNonHold (turns to TRUE for one scan)
  • if a timeout of the connection is exceeded

  • if an IP address is invalid

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
		sStringData: STRING[31767]:='';
		iID5: INT:=5;
		bSetModeStringData: BOOL:=FALSE;
		bErrorModeStringData: BOOL:=FALSE;
	END_VAR

POU body

If bSetModeStringData 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 := 7 ;
        NETWORK_BODY
B(B_VARIN,,iID5,39,2,41,4,);
B(B_VARIN,,'SV0~UPLOAD;POST',39,3,41,5,);
B(B_CONTACT,,bSetModeStringData,5,1,7,3,R);
B(B_VARIN,,'/PLC?ment',39,5,41,7,);
B(B_VAROUT,,bErrorModeStringData,52,2,54,4,);
B(B_VARIN,,sStringData,8,4,10,6,);
B(B_CONTACT,,sys_bIsEthernetInitializing,16,1,18,3,N);
B(B_F,LEN!,,11,4,16,7,,?DIN?C);
B(B_F,FP_HTTP_GET_DATA_FORMAT!,,16,3,31,7,,?D@'Var'?DnNumberOfCharacters?CsDataFormat);
B(B_F,FP_HTTP_SET_MODE!,,41,0,52,7,,?DEN?DnTransferID?DsOperation?DsPLCDataFormat?DsHTTPServerURL?AENO?CbError);
L(1,2,5,2);
L(7,2,16,2);
L(11,5,11,6);
L(18,2,41,2);
L(10,5,16,5);
L(31,5,41,5);
L(1,0,1,7);
        END_NETWORK_BODY
    END_NET_WORK
END_BODY

ST body

If DF(bSetModeStringData) AND not sys_bIsEthernetInitializing Then
    FP_HTTP_SET_MODE(nTransferID := iID5,
                     sOperation := 'SV0,UPLOAD;POST',
                     sPLCDataFormat := FP_HTTP_GET_DATA_FORMAT(sStringData,
                                                               LEN(sStringData)), 
                     sHTTPServerURL := '/PLC?ment',
                     bError => bErrorModeStringData);
End_if;

Modified on: 2022-02-17Feedback on this pagePanasonic hotline