Decode binary structured data from ExtensionObject|OPC UA Implementation: Stacks, Tools, and Samples|Forum|OPC Foundation

Avatar
Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
Lost password?
sp_Feed sp_PrintTopic sp_TopicIcon
Decode binary structured data from ExtensionObject
Avatar
Sebastian Huebener
New Member
Members
Forum Posts: 2
Member Since:
11/11/2015
sp_UserOfflineSmall Offline
1
03/22/2020 - 12:01
sp_Permalink sp_Print

Hello,

I'm trying to find a way to parse the binary structured data from an ExtensionObject.
I know, how to get the correct DataTypeNode of the received data. But didn't find any way on how to use it to decode the binary data.

Hopefully, anyone can give me a hint how to do this with the .NET SDK.

Thanks!

Avatar
Randy Armstrong
Admin
Forum Posts: 1438
Member Since:
05/30/2017
sp_UserOfflineSmall Offline
2
03/23/2020 - 09:34
sp_Permalink sp_Print

https://github.com/OPCFoundati.....Encoder.cs

public ExtensionObject ReadExtensionObject(string fieldName)

Avatar
Sebastian Huebener
New Member
Members
Forum Posts: 2
Member Since:
11/11/2015
sp_UserOfflineSmall Offline
3
03/23/2020 - 10:39
sp_Permalink sp_Print

Thanks for your reply!
But how do I use the Binary decoder? And whats the fieldName?
Is there a possibility to the the DataTypeNode for the decoder?

The following code does not work...

DataValue Data = GetDataFromServer(...);
var ExtData = GenericData.Value as ExtensionObject;

using var Decoder = new BinaryDecoder(ExtData .Body as byte[], ServiceMessageContext.GlobalContext);
var Result = Decoder.ReadExtensionObject(null);

Avatar
Fabian Franz
New Member
Members
Forum Posts: 1
Member Since:
09/22/2015
sp_UserOfflineSmall Offline
4
05/27/2020 - 01:01
sp_Permalink sp_Print

Hello, a link or a source on this topic would be helpful. Thanks

Avatar
Marco Handl
Member
Members
Forum Posts: 4
Member Since:
01/25/2022
sp_UserOfflineSmall Offline
5
06/05/2022 - 04:24
sp_Permalink sp_Print sp_EditHistory

Hello Sebastian,

did you ever find a solution for this?
I have the same Problem, that I don't know how to decode a ExtentionObject. I found this decoder but I don't know how to use it.

thank you!

Avatar
Randy Armstrong
Admin
Forum Posts: 1438
Member Since:
05/30/2017
sp_UserOfflineSmall Offline
6
06/05/2022 - 15:31
sp_Permalink sp_Print

The binary decoder needs to exact the fields of the custom structure.

i.e.

field1 = Decoder.ReadInt32();
field2 = Decoder.ReadString();

The process is the same as you would expect if you were extracting information from an XML or JSON document.

Some stacks that have helper classes that can parse ExtensionObjects from a schema definition but I am not sure NETStandard has that yet.

Forum Timezone: America/Phoenix
Most Users Ever Online: 510
Currently Online:
Guest(s) 28
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Forum Stats:
Groups: 2
Forums: 10
Topics: 1341
Posts: 4546