FP_SMTP_GET_DATA_FORMAT

Generate data format string for SMTP protocol

This FP instruction generates a string specifying the data format (FP address and length) according to the data type at the input Var. It writes the string into the output variable sDataFormat that is suitable for the input sAttachment of the instruction FP_SMTP_SET_MODE.

When data registers should be transmitted with FP_SMTP_SET_MODE, a .CSV file of the given data values is generated. During transfer, the data is converted to ASCII according to the data type. Therefore, the sAttachment input needs additional information indicating which data should be converted to which ASCII type.

Parameters

Input

Var (BOOL, INT, UINT, WORD, DINT, UDINT, DWORD, REAL, DATE, TOD, DT, STRING)

Simple data type or array of simple data types e.g. BOOL, INT, UINT, STRING, ...

Restriction: ARRAY..OF..STRING is not allowed

nSize (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 sAttachment of FP_SMTP_SET_MODE

Remarks

  • Before you execute the instruction, you need to specify the e-mail transmission settings using FP_SMTP_SET_MODE or the setting dialog of the SMTP client.

  • Before you execute the instruction, you need to specify the group and event e-mail settings using FP_SMTP_SET_GROUP or the setting dialog of the SMTP 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.

  • 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
		arrayValues_UDINT: ARRAY [0..19] OF UDINT;
		bError: BOOL:=FALSE;
		bSetMode: BOOL:=FALSE;
		iID8: INT:=8;
	END_VAR

POU body

If bSetMode 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 := 14 ;
        NETWORK_BODY
B(B_VARIN,,iID8,42,2,44,4,);
B(B_CONTACT,,bSetMode,4,1,6,3,R);
B(B_VAROUT,,bError,57,2,59,4,);
B(B_VARIN,,'GRPNO=0~SUBJECT=Time Notify Mail',42,4,44,6,);
B(B_VARIN,,'Hello~ this is time notify Mail from system. See attachment',42,5,44,7,);
B(B_VARIN,,'INFO=ADD~ATT=DATA;',11,7,13,9,);
B(B_VARIN,,'TRIG=TIME~/day~13:30:00',42,3,44,5,);
B(B_CONTACT,,sys_bIsEthernetInitializing,13,1,15,3,N);
B(B_VARIN,,arrayValues_UDINT,11,9,13,11,);
B(B_F,CONCAT-2!,,37,7,43,10,,?D?D?C);
B(B_F,Size_Of_Var!,,15,10,22,12,,?D?C);
B(B_F,FP_SMTP_GET_DATA_FORMAT!,,22,8,37,12,,?D@'Var'?DnSize?CsDataFormat);
B(B_F,FP_SMTP_SET_MODE!,,44,0,57,8,,?DEN?DnTransferID?DsTrigger?DsGroupNumber_Subject?DsBodyText?DsAttachment?AENO?CbError);
L(1,2,4,2);
L(6,2,13,2);
L(15,2,44,2);
L(37,9,37,10);
L(13,8,37,8);
L(15,10,15,11);
L(13,10,22,10);
L(43,7,43,8);
L(43,7,44,7);
L(1,0,1,14);
        END_NETWORK_BODY
    END_NET_WORK
END_BODY

ST body

If DF(bSetMode) And not sys_bIsEthernetInitializing then
    FP_SMTP_SET_MODE(nTransferID := iID8,
                     sTrigger := 'TRIG=TIME,/day,13:30:00',
                     sGroupNumber_Subject := 'GRPNO=0,SUBJECT=Time Notify Mail', 
                     sBodyText := 'Hello, this is time notify Mail from system. See attachment',
                     sAttachment := CONCAT('INFO=ADD,ATT=DATA;',
                                           FP_SMTP_GET_DATA_FORMAT(arrayValues_UDINT,
                                           Size_Of_Var(arrayValues_UDINT))),
                     bError => bError);
End_If;

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