Function Block FS_READ

The Function Block FS_READ reads data from a file.

Warning: When reading very large files, the PLC or the entire system may crash and not restart. Use the input LENGTH=0 with caution.

The file system must have been initialized beforehand using FS_INIT. All operations are performed asynchronously per storage medium created.

Input READ

A positive edge triggers the reading of data from the storage medium.

Input DEV

Defines the device from which files should be accessed. The device is used per project and can be managed in the context menu under Project External Storage.

Input PATH

Specifies the path to the file on the storage medium. The path corresponds to a Unix file path in UTF-8 format, if supported. The path is represented as follows:

Folder/Subfolder/File.txt

Input OFFSET

Defines the byte offset from which reading should start. If no offset is defined, reading starts from the beginning of the file.

Input LENGTH

Defines the maximum length until reading is stopped. If the input is not defined, reading continues to the end of the file.

Note: The maximum readable size when LENGTH=0 is 1,024,000 bytes for safety reasons.

Output DONE

The output returns a pulse upon success to perform the next operation. The pulse occurs when the process ends, even if an error has occurred.

Output DATA

Returns the read data. The state is stored for later use.

Output EOF

The input is true if the end of the file has been reached.

Output BOM

The output is true if the UTF-8 Byte Order Mark was found. The BOM is determined with every read operation.

Output ERROR

In case of an error, returns a text with an error message. This is FALSE if no error has occurred. The state is stored for later use.

Possible causes:

  • The service of the storage medium was not started.
  • The memory was not initialized.
  • The login credentials are invalid.
  • The remote server could not be reached.
  • The storage medium does not exist.
  • The specified path is invalid.