Keeping NodeIds of OPC UA Nodeset XML file during automatic build process?

Skip to first unread message

Thomas Nittel

Jul 29, 2022, 1:03:05 PMJul 29
to open62541
I take the build steps recommended at to build an OPC UA Server by means of open62541 v1.3.2 on Raspberry Pi.

I utilize an OPC UA Modeler tool including companion standards to create an OPC UA Nodeset XML file. It contains  numeric NodeIds, e.g. NodeId="ns=6;i=6018". Using this XML file cmake and the Python compiler of open62541 generate h and c files. Then cmake and gcc compiles and links the c and h files to an executable file. This OPC UA Server runs and is accessible by OPC UA viewers. So far, so good.

Now the OPC UA variables need to be connected with physical variables residing in other processes. For this I want to set a callback function like in my main function and establish some interprocess communication when the OPC UA server starts up. I like to write only this c file with my main function and use the automatically generated h and c files as they are. Otherwise I would have to do the same modifications at every new open62541 version causing additional maintenance efforts.

So, I like to call UA_Server_setVariableNode_valueCallback which has parameter nodeId. However, the function  UA_Server_addNode_begin in the generated c files has parameters requestedNewNodeId and outNewNodeId. It seems open62541 can automatically change the NodeId. Hence, when calling UA_Server_setVariableNode_valueCallback I cannot rely on the NodeId of the XML file. Keeping track of the modifications by implementing a translation table requestedNewNodeId <-> outNewNodeId would be possible but UA_Server_addNode_begin in the generated c files is called with value NULL for parameter outNewNodeId, and as mentioned above I don't like to intervene the automatic build process.
  • Is there a cmake option to prevent open62541 changing the NodeId when adding a node?
  • Is there a cmake option to allow open62541 only adding the NodeId unchanged?
  • How can I find out the NodeId which open62541 really assigns to the OPC UA variables without modifying the automatically created h and c files?
  • How can I access the OPC UA variables without altering the automatic build process if their NodeId is not guaranteed to be kept?

Julius Pfrommer

Jul 29, 2022, 7:16:27 PMJul 29
to open62541
The SDK methods will only create a new NodeId if the null-NodeId is specified.
Otherwise the specified NodeId is taken as-is, or an error is returned if that NodeId is taken.

That said, the namespace-index part of the NodeId is not hard-coded in the generated code.
The index refers to an array of strings with the namespace names. The name is the important part, irrespective of the index.
The Nodeset compiler cannot know which namespaces have already been assigned.
Hence the namespace-index only becomes known when running the generated code.

Regards, Julius
Reply all
Reply to author
0 new messages