How to read / Write UDT From PLC SIEMENS (UA_EXTENSIONOBJECT_ENCODED_BYTESTRING)

176 views
Skip to first unread message

Mattia Guerra

unread,
Feb 1, 2019, 5:42:36 AM2/1/19
to open62541
Hi everyone,

I'm trying to read an UDT from a Siemens PLC but I'm not able to do this. So I need your help.

Below is the code I wrote and the contents of the variable after reading.

UA_Variant *val = UA_Variant_new();
UA_Variant_init(val);
UA_Client_readValueAttribute(client, UA_NODEID_STRING(3, "\"DB_OPC_UA\".\"UDT\""), val);
UA_ExtensionObject * UA_UDT = (UA_ExtensionObject *)val->data;


The UDT is made up of the following data

How can I get the value of INTEGER_VALUE and FLOAT_VALUE from the ExtensionObject?

Thanks for your precious help!!

Best regards,
Mattia


Matthias Konnerth

unread,
Feb 3, 2019, 5:36:10 AM2/3/19
to open62541
Hi Mattia,

There a "PointType" is registered at the client for correctly decoding the extension object.

Best regards,
Matthias.

Mattia Guerra

unread,
Feb 6, 2019, 7:21:56 AM2/6/19
to open62541
Hi Matthias,

I tried to modify the example but it does not work .I have attached the files modified by me. I think there's something wrong but I do not understand what.

May you help me?

Thanks so mouch

custom_datatype.c
main.c
CPU_Office.xml

András Penk

unread,
Jul 17, 2023, 8:17:32 AM7/17/23
to open62541
I have the same problem. I was trying to do the same as in the example but i only got zeros back. I am trying to read from a Siemens PLC Simulator running in TIA Portal.
Reply all
Reply to author
Forward
0 new messages