Function Block FS_READLINE

The Function Block FS_READLINE reads data line by line from a file.

Warning: When reading very large files, the PLC or the entire system may crash and not start again.

Note: The maximum readable size of a line is 1024'000 bytes for safety reasons.

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 reads the 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 this is supported. The path is represented as follows:

Folder/Subfolder/File.txt

Input LINE

Defines the line that should be read. The first line starts with the number 0.

Input ENDING

Defines the line break. This is specified with escapes: "\r\n". If the input is not defined, "\n" is assumed.

The following characters respect the escape:

  • "\t" (ASCII 9 (0x09)), a tab character.
  • "\n" (ASCII 10 (0x0A)), a line feed (Line Feed).
  • "\r" (ASCII 13 (0x0D)), a carriage return character (Carriage Return).
  • "\0" (ASCII 0 (0x00)), the NUL byte.
  • '\xEF' Notation for bytes.

Note: To also define binary characters, such as '\xEF', they must be defined in single quotes.

Output DONE

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

Output DATA

Returns the read line, including the line end. The state is stored for later use.

Output EOF

If the end of the file has been reached, the input is true.

Output BOM

If the UTF-8 Byte Order Mark was found, the output is true. The BOM is determined with each 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 data is invalid.
  • The remote server could not be reached.
  • The storage medium does not exist.
  • The specified path is invalid.