BACnet Configuration in the Runtime
CODESYS BACnet2 SL uses the CmpBACnet or CmpBACnet2 component for communication. This component has to be entered and configured in the configuration file of the runtime as follows.
[ComponentManager] Component.1=CmpBACnet2 [CmpBACnet2] ; IniFile=$PlcLogic$/bacstac2.ini ; The configuration of the BACnet stack is generated by the CODESYS BACnetServer durign startup, ; if the BACnetServer device parameter g is set to TRUE (which is the default). ; Most likely IniFile= needs to be configured only, if there is a need to manually create a configuration file of the BACnet stack, ; or if another path in the PLC filesystem is required. ; IniFile=$PlcLogic$/bacstac2.ini ; Task priority of the BACstack process task - this is an optional configuration, default is TASKPRIO_NORMAL_END (159). ; The task priority only needs to be configured, if there is a real need to work with IEC task priorities and runtime component task priorities, ; on some very specific PLC's. ; TaskPrio=128 ; Name of the named pipe for the communication with the BACstack - this is an optional configuration. ; By default this named pipe is generated at "\\\\.\\pipeCODESYSBACnetServer" on Windows PLCs or "/dev/CODESYSBACnetServer" on Linux (or any other) PLCs. ; Just in case the PLC filesystem is configured such, that there is no create/write permission for this specific path, ; there is e need to configure AppName=. ; AppName=/tmp/BACnetServer
In general, CODESYS separates access to the file system within the IEC application and access from the program code of the runtime components. Different root directories can be specified in the configuration file of the runtime.
[SysFile] ; root file path for runtime components FilePath=D:/Temp/Default ; root file path for IEC applications IecFilePath=D:/Temp/IEC
When AutoGenerateBACstackConfig is set to TRUE, an IEC application with CODESYS BACnet2 SL writes the configuration file of the BACnet stack (using information from BACnet.BACnetIPdatalink) when starting the BACnet Server.
Later during the start routine, code within the runtime system component CmpBACnet reads the configuration file. Therefore, shared read and write access of the IEC application and the runtime component have to be enabled for this configuration file. This is done either by using an absolute path or by using placeholders (for CODESYS Control V3.5.16.0 and higher).
Absolute path:
... [CmpBACnet2] IniFile=D:/Temp/bacstac.ini ; Windows ; Linux -> IniFile=/tmp/bacstac.ini ...
Placeholder (example: $BACnet$):
... [SysFile] PlcLogicPrefix=1 PlaceholderFilePath=, $Firmware$ PlaceholderFilePath.1=$PlcLogic$/bacnet, $BACnet$ [CmpBACnet] IniFile=$BACnet$/bacstac.ini ...
Furthermore, CODESYS allows for the "sandboxing" of various aspects of the runtime, including access to the file system. In this case, access to the file system within the IEC application and access from the program code of the runtime components are restricted to the configured paths. For more information, see the configuration of SysFile:
... [SysFile] ; ForceFilePath=1 ; ForceIecFilePath=1 ...
For more information about this, see the help for CODESYS Control V3 Runtime System, "CODESYS Control FilePath & Placeholders". This help is available in the CODESYS GmbH Customer Portal.
When configuring the "sandboxing" of the file system, you should note that it is possible to access the configuration file of the BACnet stack as described above. Therefore, the alternative using placeholders is required in this case when the path to bacstac.ini is not already configured elsewhere.
For more information, see the following: Architecture, Components, and their Tasks