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.
|
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.
|
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:
|
|
NEW |
BOOL |
The NEW bit indicates whether data has been modified since the last read 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: 1: |
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 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. |
|
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 current date is updated following a write access. |