Dear Community User! We are updating our platform to a new system.
Read more: Important information on the platform change.

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

Read system data layer object from PLC

Read system data layer object from PLC

nova
New Poster

Hi,
I try to read some system data layer.

nova_0-1705503181696.png

If I try to read a type STRING or BOOL, I can read data in PLC with function DL_ReadNode without problem.
For exampIe: if declare Value as type Bool and I can read:
system/resources/network/interfaces/XF10/ipForwarding

if I declare Value as type STRING, I canb read:
system/resources/network/interfaces/XF10/mode

But If I try to read OBJECT:
system/resources/network/interfaces/XF10/addresses
DL_ReadNode return me always ACCES_ERROR(4).

In this example how I must declare Value to read:
system/resources/network/interfaces/XF10/addresses
with DL_ReadNode function?

Thanks.

4 REPLIES 4

CodeShepherd
Community Moderator
Community Moderator

For your question the answer is no, as you cannot read objects with this function. 

You Will have to use the function DL_ReadNodeValue. Please check the example in CXA_DataLayer library or refer to to e.g. to topic "Read/Write DataLayer Structure for OPC UA Client from PLC" or "DL_ReadNode / DL_ReadNodeValue in CoDeSys using FUP language".

Thank you for the resoponse.
I understand your example but I have another question about.
For OPC Client I have CXA_OPCUAClient library, for Ethercat CXA_EtherCatMaster library.
For my case (system/resources/network/interfaces/XF10/addresses) which library CXA_XXXXXXX I must use?

Thank you.

Sgilk
Frequent Contributor

Hi @nova ,

I looked into this for awhile and I think we might be lacking the functionality or at least documentation to do this. First of all, it took me awhile to find the PLC library associated with the datalayer type definition "networkmanager_Address".

Sgilk_0-1705521804896.png

I only found it by browsing the documentation of each ctrlX library. I found some POUs in the CXA_DEVICEADMIN_FBS library that look like they are intended to handle these types of operations. There are not associated DUTs in the library.

Sgilk_1-1705521907097.png

There are not examples in the documentation on using the POUs. I haven't been successful in reading out the addresses. Here is my code for reference. I think this is close as the address string returns "<" when I have addresses configured and an empty string when I do not.

Declaration

 

 

PROGRAM PLC_PRG
VAR
  m_fbReadNodeValue: DL_ReadNodeValue;
  m_ExecuteReadNodeValue : BOOL;;
  m_DataNodeValue : CXA_Datalayer.DL_NodeValue;
  m_Type : CXA_Datalayer.DL_DATA_TYPE;

  AddressData : CXA_DEVICEADMIN_FBS.networkmanager_Address;
  AddressString : STRING;
END_VAR

 

 

Implementation

 

 

m_ExecuteReadNodeValue := TRUE;

m_fbReadNodeValue(Execute:=m_ExecuteReadNodeValue, NodeName:= 'system/resources/network/interfaces/XF50/addresses', NodeValue:= m_DataNodeValue);
IF (m_fbReadNodeValue.Done = TRUE) THEN
	m_Type := m_DataNodeValue.GetType();
	AddressData.getRootAsAddress(data := m_DataNodeValue.GetData(), size := m_DataNodeValue.GetSize());
	AddressString := AddressData.getAddress();
END_IF

IF (m_fbReadNodeValue.Done = TRUE) OR (m_fbReadNodeValue.Error = TRUE) THEN
    m_ExecuteReadNodeValue := FALSE;
	m_fbReadNodeValue(Execute:=m_ExecuteReadNodeValue, NodeName:= 'system/resources/network/interfaces/XF50/addresses', NodeValue:= m_DataNodeValue);
END_IF

 

 

 

CodeShepherd
Community Moderator
Community Moderator

In general there is no library providing easy to use function blocks for the Network information currently, like CXA_OPCUAClient or CXA_EtherCatMaster. So you will have to directly use the CXA_DataLayer.DL_Read_NodeValue and read out the object (flatbuffer) and extract the information like in the examples mentioned above.

To get to know which flatbuffer you need to use check the ctrlX Data Layer viewer on your ctrlX CORE:

ctrlX Data Layer - system interfacesctrlX Data Layer - system interfaces

By clicking on reference you will be redirected to the corresponding reference area:

ctrlX Data Layer - interface referencectrlX Data Layer - interface reference

In the ctrlX PLC Engineering then use add library and insert the flatbuffer to find the library where it is included:

ctrlX PLC Engineering - add library of flatbufferctrlX PLC Engineering - add library of flatbuffer

I will create an example how to read the complete object. Easy to use workaround would be to read all single nodes.

Beware that it seems only to available from version 2.02 on not in 1.20.

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