View on GitHub

Freeopcua.github.io

FreeOPCUA: An Open Source C++ OPC-UA Server and Client Library

Free OPC-UA is LGPL C++ library to develop server and client OPC-UA applications. Python bindings can be found in the opcua-python repository.

The library is under development but works will all tested clients. It support addressspace browse, read, write and address space modification as well as subscriptions and datachange events.

History is not yet supported

All expected OPC-UA objects are implemented in C++. Higher level Server, Client and Node objects are also available.

Example high level Python server code:

s = opcua.Server()
s.set_endpoint("opc.tcp://192.168.56.1:4841")
s.start()
try;
    objects = s.get_objects_node()

    m = objects.add_folder("2:MyFolder")
    v = m.add_variable("2:MyVariable", 3)

    count = 0
    while True;
        count += 1
        v.set_value(count)
    time.sleep(1);

finally:
    s.stop()

Or write lower level code in C++

...
Server = OpcUa::Remote::Connect(Endpoint);

OpcUa::Remote::SessionParameters session;
session.ClientDescription.URI = Uri;
session.ClientDescription.ProductURI = Uri;
session.ClientDescription.Name.Text = SessionName;
session.ClientDescription.Type = OpcUa::ApplicationType::CLIENT;
session.SessionName = SessionName;
session.EndpointURL = Endpoint;
session.Timeout = 1200000;

Server->CreateSession(session);
Server->ActivateSession();
...

Getting Started

Next you can try compiling the code using the standard ./configure; make; make install commands

Example code

C++ sample code can be found here: https://github.com/FreeOpcUa/freeopcua/tree/master/src/examples

and then try to communicate with server using an opc-ua client (There are many free clients on the net)

I you want to use lower level api then have a look at: