FORUM CTRLX AUTOMATION
ctrlX World Partner Apps for ctrlX AUTOMATION
08-18-2022 04:11 PM
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.
T.Hanks
Solved! Go to Solution.
08-18-2022 04:22 PM - edited 08-18-2022 04:23 PM
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:
08-19-2022 08:55 AM
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.
T.Hanks
08-19-2022 10:17 AM - edited 08-19-2022 10:19 AM
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:
Add libraries CXA_DATALAYER (general Data Layer access) and CXA_PLC_fbs (librarie including all flatbuffer of the PLC) to your project.
See this topic for examples of reading more complex flatbuffer.
08-19-2022 04:19 PM
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?
08-22-2022 11:06 AM
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?
08-26-2022 04:21 PM
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".
08-29-2022 10:20 AM
Use as datatype only DL_NodeValue. Don't use the suggested declaration REFERENCE TO DL_NodeValue.
Thanks Shepherd