Syntax for attaching PLC data to an email

It is possible to generate a file with PLC data and attach it to an email or store it in the device memory.

The PLC can send data as user-defined text (TXT) or in a Microsoft Excel compatible file format (CSV). The range of the PLC data registers and the file name are defined in a tag with a special syntax. This tag is placed as a string in the PLC program and is read when the start of the operation has been recognized.

The maximum number of characters for the command tag (including the brackets) is 128.

The following commands are executed by the user-friendly function blocks of the FP-I4C Library.

Commands

The syntax examples show the command letters in bold print:

No data will be written to the PLC if the number of PLC registers is set to 0.

Parameters

Start code (character offset: +0)

The tag must start with {A_

Example: {A_

PLC register type (character offset: +3)

Values:

  • D: DT
  • F: FL
  • L: LD

Example: D_

Pointer to start of data 1 (character offset: +5)

Values:

  • CSV: First PLC register address to read

  • TXT: Start of Control FPWIN Pro7 string header

Example: 00200_

Number of registers or pointer to start of data 2 (character offset: +11)

Values:

  • CSV: Number of PLC registers to read

    Example: 00066_

  • TXT: Start of Control FPWIN Pro7 string header to read or to replace text with r or m; 00001_ to transmit data or 00000_ for a test command with P

    Example: 00001_

Operation mode (character offset: +17)

Values:

  • CSV:

    • K,k: Cell terminator ',' (comma)

    • S,s: Cell terminator ';' (semicolon)

    • P: Restore an existing CSV file data from the data storage location back to the PLC.

    • F: Send a file from the data storage location via email.

    • D: Delete a file from the data storage location.

  • TXT:
    • T,t: Write and forward a TXT file via email.

    • a: Append a string to an existing TXT file. If the file does not exist, a new file is created.

    • r: Search for a line that contains the text specified by Pointer to start of data 1.

      Each line must be terminated with LF (line feed control code). If the text of data 1 begins with * (asterisk), the search text can be at any position within the line. The read result or error information is stored in data 2.

    • m*: Replace a line that contains the text specified by Pointer to start of data 1.

      Each line must be terminated with LF (line feed control code). If the text of data 1 begins with * (asterisk), the search text can be at any position within the line. The replaced data or error information is stored in data 2. If data 1 is empty, a new line with data 2 is inserted at the line specified by Number.

Lowercase characters store the data without sending them via email.

Example: S

Number (character offset: +18)

Values:

  • CSV: Number of CSV columns

  • TXT:
    • r and m: Number of lines to search for
    • All other functions: Always 01_

Example: 04_

File name (character offset: +21)

Attachment file name up to the }

You can use file names with all characters that are typically allowed in file systems (including the blank). You may choose a different extension than TXT or CSV.

The delete operation allows using wildcards (*, ? but not the combination *.*) to remove a set of files.

Example: filename.csv