What do the library files SysFile and SysDir in TwinCAT3 do?
They serve the same purpose as the file management function blocks inside Tc2_System.
Although the functionality is the same, SysFile and SysDir offer more flexibility because all their functions are implemented asynchronously through functions. Functions occupy less space compared to function blocks. They contain only temporary variables and do not occupy an instance like function blocks. Moreover, there is no limitation on the length of content that can be written at once.
However, the testing threshold for this library is quite high, and improper usage may lead to system crashes, program failures, or even blue screens.
In the example routines, a unified interface is used to implement different function blocks or functions from the two library files.
Ignoring I_Base
, I_FileHandlingReadAccess
allows for read-only operations on files, while I_FileHandling
extends the former by enabling read, write, copy, and other operations on files. As for I_FolderHandling
, it manages folders.
The function blocks are divided into "Ex" and non-"Ex" versions. The "Ex" versions represent the functions in SysFile and SysDir, while the non-"Ex" versions represent the function blocks in Tc2_System. You can switch between them freely. Since the methods are specified by interfaces, their functionality is identical.
The maximum buffer size and maximum character length for reading a file at once in the library files can be modified through the Params of the library files.
Link to the attachment routine code and the library files required for the routine