open62541: nodeset compiler crashes while processing minimal example xml
Hi,
i wanted to test the nodeset_compiler.py script that ships with open62541 from the latest available master branch and received an the following error when calling python nodeset_compiler.py -x ~/minimal.xml ~/output.c
:
INFO:__main__:Preprocessing /home/user/minimal.xml
Traceback (most recent call last):
File "nodeset_compiler.py", line 138, in <module>
ns.addNodeSet(xmlfile, typesArray=getTypesArray(nsCount))
File "/home/user/open62541_master/tools/nodeset_compiler/nodeset.py", line 252, in addNodeSet
newsource = self.nodes[ref.target]
KeyError: ns=0;i=63
The xml i used has just a single variable node and looks as follows:
<?xml version='1.0' encoding='utf-8'?>
<UANodeSet xmlns="http://opcfoundation.org/UA/2011/03/UANodeSet.xsd" xmlns:uax="http://opcfoundation.org/UA/2008/02/Types.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<NamespaceUris />
<Aliases>
<Alias Alias="UInt64">i=9</Alias>
<Alias Alias="HasTypeDefinition">i=40</Alias>
<Alias Alias="HasComponent">i=47</Alias>
</Aliases>
<UAVariable BrowseName="0:TestVar" DataType="UInt64" NodeId="i=20001" ParentNodeId="i=85">
<DisplayName>TestVar</DisplayName>
<Description>TestVar</Description>
<References>
<Reference IsForward="false" ReferenceType="HasComponent">i=85</Reference>
<Reference ReferenceType="HasTypeDefinition">i=63</Reference>
</References>
<Value>
<uax:UInt64>1000</uax:UInt64>
</Value>
</UAVariable>
</UANodeSet>
What i am doing wrong?
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 15 (14 by maintainers)
To summarize: YES! We definitely need to improve the docs for the nodeset compiler (NSC)! Pull requests are welcome!
@HolgerJeromin the crash from the first post is supposed to happen. It means that somewhere in the xml a node with ID
i=63
is referenced but does not exist in the node set. I agree that there could be a better error message, but for stopping the compilation if NSC fails, I chose to throw exceptions. There are definitely better solutions, but as a quick fix, this works for now. PRs for improving the output and error handling of the NSC are greatly welcome.@bobbthebuilder your last post is also expected behaviour. To print the nodes in the correct order (make sure that referenced nodes are there before referencing them) we need to sort the generated code. To avoid circular dependencies (which can not be solved/ordered), the server code includes a very limited basic set of nodes which are always created and necessary, independent of the used node set. The
-i NodeID_NS0_Base.txt
is exactly for this purpose: it lists the node ids of this basic set of nodes, therefore these nodes must not be generated and ignored by the NSC. If the NSC does not know that these nodes already exist it tries to order the nodes but finds a circular dependency. Therefore you get the error:So the correct call for the minimal nodeset NS0 is (as currently created by CMake):
@bobbthebuilder I will close this issue. Anyways I’m happy to answer any further questions regarding the NSC. Just add them to the issue here and feel free to add a PR.