pythonopc-ua

Read ExtensionObject OPC UA - python


I'm trying to read an opc ua extension object in python with the following code:

from opcua import Client
from opcua import ua

connessione= 'opc.tcp://10.1.17.21:4840/'
client = Client(connessione)

try:
    client.connect()
    var = client.get_node('ns=1;s=VARIABLE_OPC_first_coiling_machine_production_list')
    before = var.get_value()
    client.load_type_definitions()
    after = var.get_value()
    print(before, '\n', after)
    client.disconnect()
except Exception as e:
    print(e.__str__())

But in 'after' I get a non-decipherable arraybyte. Example:

ExtensionObject(TypeId:StringNodeId(ns=1;s=ENC_DATATYPE_OPC_coiling_machine_production_list), Encoding:1, 2311 bytes)

I also try with opcua-asyncio library, but nothing change.


Solution

  • Try opcua-asyncio library and call the function load_data_type_definitions.