Does opcua-asyncio support structures with optional fields? #630
Replies: 12 comments
-
where does this came from? |
Beta Was this translation helpful? Give feedback.
-
what version are you using? I tried implementing 1.04 structure stuff, at least in client code a few months ago. it is in master, maybe not released yet. importing xml files should also work.. might be some bugs though.... I did not tested that specific spec and I am quite busy currently |
Beta Was this translation helpful? Give feedback.
-
Server: import asyncio, random
from asyncua import ua, Server
async def main():
server = Server()
await server.init()
server.set_endpoint("opc.tcp://127.0.0.1:4840/test")
obj = server.get_objects_node()
"""
setup test namespace
"""
await server.import_xml("Opc.Ua.Di.NodeSet2.xml")
await server.import_xml("Opc.Ua.AutoID.NodeSet2.xml")
async with server:
print("started!")
while 1:
await asyncio.sleep(1)
if __name__ == "__main__":
asyncio.run(main()) Client: import asyncio
from asyncua import Client, Node, ua
async def main():
client = Client(url='opc.tcp://127.0.0.1:4840/test')
async with client:
result = await client.load_type_definitions()
print(str(result))
while 1:
await asyncio.sleep(0)
if __name__ == "__main__":
asyncio.run(main()) 0.8.4: no error... |
Beta Was this translation helpful? Give feedback.
-
@AndreasHeine use load_data_type_definition() to load structs using the 1.04 definitions (code is much simpler, but both should work) |
Beta Was this translation helpful? Give feedback.
-
@oroulet ah thats new there was something you changed but i did not looked at it yet 😉 |
Beta Was this translation helpful? Give feedback.
-
@oroulet Thank you for your quick response. When reading them, I noticed that I was a bit unprecise when describing the problem. The error does not occur when calling load_type_definitions(). I happens when reading a structured datatype value. Regarding the used version: I'm using opcua-asyncio 0.8.4 at client side and a non- opcua-asyncio server with autoid datatypes as defined in AutoID Nodeset version 1.00. |
Beta Was this translation helpful? Give feedback.
-
@AndreasHeine : Code is generated in general at structures.py@302:
whereas the code for structures is generated in structures.py@87. |
Beta Was this translation helpful? Give feedback.
-
@jfischer1 yes. So use the new method: load_data_type_definutiin() and use asyncua client from master |
Beta Was this translation helpful? Give feedback.
-
I want to know it there are still issues before releasing |
Beta Was this translation helpful? Give feedback.
-
@oroulet I tried using master branch (f3de377) and the following code:
Results:
|
Beta Was this translation helpful? Give feedback.
-
that error + the fact that you only get ExtensionObject after calling load_data_type_definitions() means that your server in reality does not implement 1.04 structures... then you have to use the old method load_type_definition() and yes in the old method, optional field may not be supported, I think there was a bug there... |
Beta Was this translation helpful? Give feedback.
-
OK now I see that your said that your server does not implement 1.04. so yes thre might be a bug there... I do not have time to look at it |
Beta Was this translation helpful? Give feedback.
-
I'm trying to connect to a server (< OPC UA 1.04) with AutoID companion spec structures via UA binary protocol with opcua-async 0.8.4. These structures contain optional fields. Seem like opc:Bits datatype somehow causes an error. Are optional structure fields supported by asyncua? If yes, perhaps you can give me a hint what I'm doing wrong? Thank you!
Here come the details of the error message:
When calling load_type_definition(), method fails with the following message
It looks like generated code is trying to use an non-existent type:
Beta Was this translation helpful? Give feedback.
All reactions