Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reading Custom Structure with B&R OPC UA client fails with Error 0x80390000 Bad_DataEncodingUnsupported #1524

Open
MaCar37 opened this issue Dec 13, 2023 · 3 comments

Comments

@MaCar37
Copy link

MaCar37 commented Dec 13, 2023

Describe the bug

I can not read custom structures from an opcua-asyncio Server using a B&R PLC with an OPC UA client. Reading always fails with Error 0x80390000 Bad_DataEncodingUnsupported.

I already contacted the B&R Suppport. B&R claims the Error indicates that the Sever uses an old implementation of the OPCUA standard.

I also tried other OPC UA Servers where my B&R client could read custom structures.

The same problem might be already mentioned inside the Discussion of the older librabry python-opcua here: #1527

To Reproduce

I used the example server-custom-structures-and-enums.py from this repository.
For the client I used the OpcUa_Sample from B&R Automation Studio V4.9.6.42.

Version

Python-Version:
Python 3.9.7
opcua-asyncio Version (e.g. master branch, 0.9):
asyncua 1.0.5

@rempAut
Copy link

rempAut commented Feb 11, 2024

Hi, I have the same issue. Did you manage to find anything?

@AndreasHeine
Copy link
Member

what encoding is it?

there where new (1.04) and old (1.03) structures!
have you tried both:

    async def load_type_definitions(self, nodes=None):
        """
        Load custom types (custom structures/extension objects) definition from server
        Generate Python classes for custom structures/extension objects defined in server
        These classes will available in ua module
        WARNING: protocol has changed in 1.04. use load_data_type_definitions()
        """
        _logger.warning("Deprecated since spec 1.04, call load_data_type_definitions")
        return await load_type_definitions(self, nodes)

    async def load_data_type_definitions(self, node: Optional[Node] = None, overwrite_existing: bool = False) -> Dict[str, Type]:
        """
        Load custom types (custom structures/extension objects) definition from server
        Generate Python classes for custom structures/extension objects defined in server
        These classes will be available in ua module
        """
        return await load_data_type_definitions(self, node, overwrite_existing=overwrite_existing)

@rempAut
Copy link

rempAut commented Feb 16, 2024

Allright, so I got it running, but I don't completely understand why.

  • I used the latests Automation Runtime I4.93
  • changed the OPCUA system configuration to use the 1.04 structure structure definitions
    image
  • declared the structures in Automation Studio
  • used server.import_xml() to import the generated nodeset file with stucture definitions from Automation Studio.

Now here is the part where I would like to ask for some clarification. I was investigating whatever I could find about the Bad_DataEncodingUnsupported. I noticed a difference in nodesets exported from opcua-asyncio and Automation Studio in the encoding nodes (UAObject vs UAObjectType) Is this relevant? I am attaching snippets from the nodeset files.

Nodeset snippet - exported from Automation Studio

   <UADataType NodeId="ns=1;i=101"
                BrowseName="1:parentElementType">
        <DisplayName>parentElementType</DisplayName>
        <Description>parentElementType</Description>
        <References>
            <Reference ReferenceType="HasSubtype"
                       IsForward="false">i=22</Reference>
            <Reference ReferenceType="HasEncoding">ns=1;i=102</Reference>
        </References>
        <Definition Name="1:parentElementType">
            <Field DataType="i=12"
                   Name="ID" />
            <Field DataType="i=6"
                   Name="Length" />
            <Field DataType="i=6"
                   Name="Diameter" />
        </Definition>
    </UADataType>
    <UAObject SymbolicName="DefaultBinary"
              NodeId="ns=1;i=102"
              BrowseName="Default Binary">
        <DisplayName>Default Binary</DisplayName>
        <References>
            <Reference ReferenceType="HasTypeDefinition">i=76</Reference>
            <Reference ReferenceType="HasEncoding"
                       IsForward="false">ns=1;i=101</Reference>
        </References>
    </UAObject>

 Nodeset snippet - python-asyncua server.export()

    <UADataType NodeId="ns=1;i=3"
                BrowseName="1:parentElementType">
        <DisplayName>parentElementType</DisplayName>
        <Description>parentElementType</Description>
        <References>
            <Reference ReferenceType="HasSubtype"
                       IsForward="false">i=22</Reference>
            <Reference ReferenceType="HasEncoding">ns=1;i=4</Reference>
        </References>
        <Definition Name="parentElementType">
            <Field DataType="i=12"
                   Name="ID" />
            <Field DataType="i=6"
                   Name="Length" />
            <Field DataType="i=6"
                   Name="Diameter" />
        </Definition>
    </UADataType>
    <UAObjectType NodeId="ns=1;i=4"
                  BrowseName="0:DefaultBinary">
        <DisplayName>DefaultBinary</DisplayName>
        <Description>DefaultBinary</Description>
        <References>
            <Reference ReferenceType="HasEncoding"
                       IsForward="false">ns=1;i=3</Reference>
        </References>
    </UAObjectType>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants