cancel
Showing results for 
Search instead for 
Did you mean: 
SOLVED

DL_ReadNode / DL_ReadNodeValue in CoDeSys using FUP language.

DL_ReadNode / DL_ReadNodeValue in CoDeSys using FUP language.

NiceGuy
Member

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

7 REPLIES 7

CodeShepherd
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.

NiceGuy_0-1660889534601.png

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

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.

NiceGuy_0-1660890652278.png

NiceGuy_1-1660891239940.png

T.Hanks

 

 

CodeShepherd
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? 

NiceGuy_0-1660918419281.png

NiceGuy_1-1660918677054.png

 

 

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.

tempsnip.png

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?

CodeShepherd
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".

NiceGuy_0-1661760991797.png

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

Thanks Shepherd

 

Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist