FP_HTTP_SET_MODE

Set HTTP transfer mode

This FP instruction stores the HTTP client transfer settings of sOperation, sPLCDataFormat and sHTTPServerURL in the transfer setting area specified by nTransferID.

Parameters

Input

nTransferID (WORD, INT, UINT)

Set the transfer setting ID.

Values: 0–15 (values must be entered in ascending order)

sOperation (STRING)

Set the transfer method parameters.

  • Server address

    Keyword: SV

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

  • Specify the memory area and the type of transfer (sending or getting data)

    • Use the keyword UPLOAD for sending data.

    • Use the keyword DOWNLOAD for getting data.

    • Use the keyword UPDOWN for sending and getting data.

    Specify the command to be used for transfer.

    • Use the keyword POST for sending data (only available for the transfer types UPLOAD and UPDOWN).

    • Use the keyword GET for getting data.

    Example: Upload data from memory area to HTTP server 3: 'SV3,UPDOWN,POST'

sPLCDataFormat (STRING)

Specify the data to be transferred. Alternatively, use the instruction FP_HTTP_GET_DATA_FORMAT.

Example: Memory area: DT100000, number of bytes: 250 bytes, maximum number of acquisitions: 250 bytes: 'DT100000,250,250'

sHTTPServerURL (STRING)

Specify the server URL.

Example: '\data.csv'

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.

  • Before you execute the instruction, you need to specify the HTTP server using FP_HTTP_SET_CONNECTION 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.

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

  • The number of bytes that can be simultaneously transferred is 1MB for all 16 transfer IDs.

  • 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 transfer IDs 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 an HTTP server that has not been specified with the instruction FP_HTTP_SET_CONNECTION or the setting dialog of the HTTP client is specified.

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

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

  • if transfer IDs 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 an HTTP server that has not been specified with the instruction FP_HTTP_SET_CONNECTION or the setting dialog of the HTTP client is specified.

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

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
		sDestURL: STRING[32]:='\data.csv';
		sStringData: STRING[32767]:='';
		iID5: INT:=5;
		bSetModeAsciiDataArea: BOOL:=FALSE;
		bSetModeStringData: BOOL:=FALSE;
		bErrorModeStringData: BOOL:=FALSE;
		bErrorModeAsciiDataArea: BOOL:=FALSE;
	END_VAR

POU body

The first example uses a source string containing a maximum of 32767 characters, the second example uses a DT address to store the source string with more than 32767 characters.

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_COMMENT,, ^Set mode to transfer HTTP data stored in string variable (strings can only contain max. of 32767 characters),4,1,45,4,);
L(1,0,1,5);
        END_NETWORK_BODY
    END_NET_WORK
    NET_WORK
        NETWORK_TYPE := NWTYPELD ;
        NETWORK_LABEL :=  ;
        NETWORK_TITLE :=  ;
        NETWORK_HEIGHT := 7 ;
        NETWORK_BODY
B(B_VARIN,,iID5,40,2,42,4,);
B(B_VARIN,,'SV0~DOWNLOAD,GET',40,3,42,5,);
B(B_CONTACT,,bSetModeStringData,5,1,7,3,R);
B(B_VARIN,,'/data.csv',40,5,42,7,);
B(B_VAROUT,,bErrorModeStringData,53,2,55,4,);
B(B_VARIN,,sStringData,8,4,10,6,);
B(B_CONTACT,,sys_bIsEthernetInitializing,16,1,18,3,N);
B(B_F,MAX_LEN!,,10,5,16,7,,?D?C);
B(B_F,FP_HTTP_GET_DATA_FORMAT!,,16,3,31,7,,?D@'Var'?DnNumberOfCharacters?CsDataFormat);
B(B_F,FP_HTTP_SET_MODE!,,42,0,53,7,,?DEN?DnTransferID?DsOperation?DsPLCDataFormat?DsHTTPServerURL?AENO?CbError);
L(1,2,5,2);
L(7,2,16,2);
L(10,5,10,6);
L(10,5,16,5);
L(31,5,42,5);
L(18,2,42,2);
L(1,0,1,7);
        END_NETWORK_BODY
    END_NET_WORK
    NET_WORK
        NETWORK_TYPE := NWTYPELD ;
        NETWORK_LABEL :=  ;
        NETWORK_TITLE :=  ;
        NETWORK_HEIGHT := 5 ;
        NETWORK_BODY
B(B_COMMENT,, ^Set mode to transfer HTTP data stored in memory area > 32767 characters,4,1,34,4,);
L(1,0,1,5);
        END_NETWORK_BODY
    END_NET_WORK
    NET_WORK
        NETWORK_TYPE := NWTYPELD ;
        NETWORK_LABEL :=  ;
        NETWORK_TITLE :=  ;
        NETWORK_HEIGHT := 8 ;
        NETWORK_BODY
B(B_VARIN,,iID5,39,3,41,5,);
B(B_VARIN,,'SV0~UPDOWN,POST',39,4,41,6,);
B(B_VARIN,,'DT100000~102345~12345',39,5,41,7,);
B(B_CONTACT,,bSetModeAsciiDataArea,5,2,7,4,R);
B(B_VARIN,,sDestURL,39,6,41,8,);
B(B_VAROUT,,bErrorModeAsciiDataArea,52,3,54,5,);
B(B_CONTACT,,sys_bIsEthernetInitializing,16,2,18,4,N);
B(B_F,FP_HTTP_SET_MODE!,,41,1,52,8,,?DEN?DnTransferID?DsOperation?DsPLCDataFormat?DsHTTPServerURL?AENO?CbError);
L(1,3,5,3);
L(7,3,16,3);
L(18,3,41,3);
L(1,0,1,8);
        END_NETWORK_BODY
    END_NET_WORK
END_BODY

ST body

(* Set mode to transfer HTTP data stored in string variable (strings can only contain max. of 32767 characters) *)
If DF(bSetModeStringData) And not sys_bIsEthernetInitializing then
    FP_HTTP_SET_MODE(nTransferID := iID5,
                     sOperation := 'SV0,DOWNLOAD,GET',
                     sPLCDataFormat := FP_HTTP_GET_DATA_FORMAT(sStringData, LEN(sStringData)), 
                     sHTTPServerURL := '/data.csv',
                     bError => bErrorModeStringData);
End_if;
(* Set mode to transfer HTTP data stored in memory area > 32767 characters  *)
If DF(bSetModeAsciiDataArea) And not sys_bIsEthernetInitializing then
        FP_HTTP_SET_MODE(nTransferID := iID5,
                         sOperation := 'SV0,UPDOWN,POST',
                         sPLCDataFormat := 'DT100000,102345,12345', 
                         sHTTPServerURL := sDestURL,
                         bError => bErrorModeAsciiDataArea);
End_if;

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