Showing results for 
Search instead for 
Did you mean: 

DL_ReadNode / DL_ReadNodeValue in CoDeSys using FUP language.

DL_ReadNode / DL_ReadNodeValue in CoDeSys using FUP language.


Hi, I'm trying to get information from the data layer using the DL_ReadNode or DL_ReadNodeValue fuction blocks. But I am not getting this.

The aim is to get the information via CoDeSys and the FUP language. I am very grateful for tips.

I tried a few things, but never got data at the value port. 



Community Moderator
Community Moderator

In general DL_ReadNode can only read out simple data types (e.g. INT). You are trying to read a datum of the type flatbuffer. Therefore you need to use DL_ReadNodeValue and extract the information out of it.

Especially for the fieldbus there are several function blocks available that implicitly do that. For your case in the CXA_EtherCatMaster library the function block IL_ECATMasterState should be fitting:

CXA_EtherCatMaster IL_ECATMasterStateCXA_EtherCatMaster IL_ECATMasterState

Hi, thank you. 
At least I get the NumOnlineSlave to work. But I have problems with the ConfigInfo. It would be a huge help if you could help me understand the flatbuffer type and how to get information and variables from it. Is the extraction even possible using only FUP language or do I have to switch to ST or Python.
In addition, I don't know the syntax to write my own flatbuffer, is there helpful documentation from the ctrlX or another source.



And one more question about the DL_ReadNodeValue type. If I want to read the runtime information from the PLC, I'm using the DL_ReadNodeValue type. The function block is mostly clear to me, except for the port NodeValue, how do I handle it and get the information. You said "extract the information out of it" but how exactly do I do that and how would I get the information if there is more data inside the flatbuffer. And is the extraction possible using FUP.






Community Moderator
Community Moderator

You should add more information to your screenshots. At least e.g. the whole path you'ld like read/write.

Creating own flatbuffer at the moment is only possible via higher programming languages (e.g. C++, Python)

To read out the information of the path "plc/app/Application/admin/state/runtime" do following steps:

  1. Read out flatbuffer type in the Data Layer (plc_cmp_datalayer_fbs_State)
    Data Layer data type of PLC application stateData Layer data type of PLC application state

  2. Add libraries CXA_DATALAYER (general Data Layer access) and CXA_PLC_fbs (librarie including all flatbuffer of the PLC) to your project.

  3. Implement function in FUP (FBD).
    1. Read out value
    2. Extract flatbuffer
    3. Get value
      PLC Engineering read application statePLC Engineering read application state

See this topic for examples of reading more complex flatbuffer.


I really like the example you made! Thanks. The CXA_PLC Lib was missing in my program.

I see you are also using the CheckFunctions. I have the same program structure as you. In my case, however, the ctrlX core throws an exception error and triggers a pointer error in the checkPointer function. Do you have any idea? 





To give a bit more detail and to describe the problem in more detail.
The getRoot function is the problem for me. I tested some getRoot functions from different readType and always got the same result.

Unfortunately I can't see the precompiled code from the lib and try to solve the problem. Commenting out the CheckFunctions or excluding it from the build doesn't help either, then it crashes somewhere else for which I can't get a reasonable diagnosis

Thats the diagnosis in CoDeSys.


Is the procedure for reading out the flatbuffer always the same? So 1. getRoot Method and 2. getState / (get whatever I want from flatbuffer), is that correct?
So it is not possible to bypass the getRoot function. So the getRoot method is the 'key' to the flatbuffer and the method
forms a path to the data. Can you explain the result of the method a little bit more?

Community Moderator
Community Moderator

Comparing your code to mine I see that your variable "plcruntimenodevalue" is a reference to something with probably a "16#0" in it. The error shown is an access violation could be triggered by a zero pointer access. In my code the type is simply "DL_NodeValue".


Use as datatype only DL_NodeValue. Don't use the suggested declaration REFERENCE TO DL_NodeValue.

Thanks Shepherd