Structure of the data blocks (file DBs) for FTP services - FTP server mode - STEP 7

Communications modules and network components

ft:publication_title
Communications modules and network components
Product
STEP 7
Version
V20
Publication date
11/2024
Language
en-US
Structure of the data blocks (file DBs) for FTP services - FTP server mode

How it works

To transfer data with FTP, create data blocks (file DBs) on the CPU of your S7 station. These data blocks must have certain structure to allow them to be handled as transferable files by the FTP services. They consist of the following sections:

  • Section 1: File DB header (has a fixed length (20 bytes) and structure)

  • Section 2: User data (has a variable length and structure) data type "FILE_DB_HEADER

Data type "FILE_DB_HEADER"

Using the "Add new block" function, you assign the type "FILE_DB_HEADER" to a data block directly.

File DB header for FTP server mode

Note: The file DB header described here is largely identical to the file DB header for client mode. The differences relate to the following parameters:

  • WRITE_ACCESS

  • FTP_REPLY_CODE

Parameter

Type

Value / meaning

Supply

EXIST

BOOL

The EXIST bit indicates whether the user data area contains valid data.

The retrieve FTP command executes the job only when EXIST=1.

  • 0:
    The file DB does not contain valid user data ("file does not exist").

  • 1:
    The file DB contains valid user data ("file exists").

The dele FTP command sets EXIST=0;

The store FTP command sets EXIST=1;

LOCKED

BOOL

The LOCKED bit is used to restrict access to the file DB.

  • 0:
    The file DB can be accessed.

  • 1:
    The file DB is locked.

The stor and retr FTP commands set LOCKED=1 when they are executed.

The following function is also possible when writing from the user program:

The user program on the S7 CPU can set or reset LOCKED during write access to achieve data consistency.

Recommended sequence in the user program:

  1. Check LOCKED bit;
    if = 0

  2. Set WRITEACCESS bit = 0

  3. Check LOCKED bit;
    if = 0

  4. Set LOCKED bit = 1

  5. Write data

  6. Set LOCKED bit = 0

NEW

BOOL

The NEW bit indicates whether data has been modified since the last read access.

  • 0:
    The content of the file DB is unchanged since the last write access. The user program of the S7 CPU has registered the last modification.

  • 1:
    The user program of the S7 CPU has not yet registered the last write access.

After execution, the stor FTP command sets NEW=1

After reading the data, the user program on the S7-CPU must set NEW=0 to allow store to be used again or to be able to delete the file with the dele FTP command.

WRITE_ACCESS

BOOL

0:
The FTP client on the PG/PC has no write access right for the file DBs on the S7 CPU.

1:
The FTP client the PG/PC has the write access right for the file DBs on the S7 CPU.

During the configuration of the DB, the bit is set to an initialization value.

Recommendation:

Whenever possible, the bit should remain unchanged! In special situations, adaptation during operation is possible.

ACT_LENGTH

DINT

Current length of the user data area.
The content of this field is only valid when EXIST = 1.

The current length is updated following write access.

MAX_LENGTH

DINT

Maximum length of the user data area (length of the entire DB less 20 bytes header).

The maximum length should be specified during configuration of the DB.
The value can also be modified by the user program during operation.

FTP_REPLY_CODE

INT

This parameter is irrelevant in FTP server mode.

Is set to "0" by the FTP server.

DATE_TIME

DATE_AND_TIME

Date and time of the last modification to the file.
The content of this field is only valid when EXIST = 1.

The current date is updated following a write access.
If the function for forwarding the time of day is used, the entry corresponds to the time that was passed on.
If the function for forwarding the time of day is not used, a relative time is entered. This time relates to the startup of the IT-CP (the initialization value is 1.1.1994 0.0 (midnight)).