OPC UA Pub Sub Parsing NodeId|OPC UA Standard|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
OPC UA Pub Sub Parsing NodeId
Avatar
Jothi Sankarraj
Member
Members
Forum Posts: 29
Member Since:
04/09/2019
sp_UserOfflineSmall Offline
1
08/05/2019 - 05:11
sp_Permalink sp_Print

I’m now parsing / decoding the byte array that I get from a OPC UA Pub / Sub server and I’m about to write a parser that should parse the dataTypeId field as described in Table A.3 – DataTypeDescription Structure of the Part 14 specification! It says that the dataTypeId is of type NodeId which means I should look into the Part 6 spec where the NodeId Encoding is described. 

So from Part 6 of the specification Table 5 – NodeId components describes NodeId components, but I could not understand how I could get it parsed from the sample data that I have. For example., here is the set of Bytes that I have which I believe should be parsed as dataTypeId:

1 1 1 0

Can someone please give me a hint as to how I should go about extracting the NodeId from this set of Bytes? I’m pretty sure that it is just these 4 bytes as the ones that come after this, I have already figured out that it is going to be part of the name in the DataTypeDescription structure! 

Help please!

Avatar
Randy Armstrong
Admin
Forum Posts: 1579
Member Since:
05/30/2017
sp_UserOfflineSmall Offline
2
08/05/2019 - 11:39
sp_Permalink sp_Print

Part 6 specifies the rules for encoding and tells you exactly the meaning of each byte on the wire.

If you prefer code you can look at the BinaryEncoder and BinaryDecoder classes which are part of the .NET code base:

https://github.com/OPCFoundati…..Decoder.cs

Avatar
Jothi Sankarraj
Member
Members
Forum Posts: 29
Member Since:
04/09/2019
sp_UserOfflineSmall Offline
3
08/05/2019 - 12:13
sp_Permalink sp_Print

I can take a look at the .NET codebase, but I would prefer to understand it first hand! I seriously hate working with a .NET codebase!

So for my example.,

1 1 1 0

Here is how I would understand it!

The first byte 1 identifies the Encoding, which in this case is a 4 byte representation as per the Table 6 given in the Part 6 of the specification. 

I then have to refer to Table 9 of the Part 6 specification where the Four Byte NodeId Binary DataEncoding is defined! It says that the Namespace is a Byte long and the Identifier is a UInt16. So applying this to my example., would mean that my namespace is 1 and the identifier is 1 0. Is this correct?

Avatar
Jothi Sankarraj
Member
Members
Forum Posts: 29
Member Since:
04/09/2019
sp_UserOfflineSmall Offline
4
08/05/2019 - 12:31
sp_Permalink sp_Print

@Randy You’ve been of great help so far! Would you please post me the location of this NodeIdEncodingBits.cs file in the .NET codebase? Otherwise I have to check out the whole thing and look it up for myself! 

Avatar
Jothi Sankarraj
Member
Members
Forum Posts: 29
Member Since:
04/09/2019
sp_UserOfflineSmall Offline
5
08/05/2019 - 12:35
sp_Permalink sp_Print

Ok I figured it out! It is an enum to be found in this file here!

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

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