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.

In addition an OPC-UA Python Client and Server library, written entirely in python, is available: https://github.com/FreeOpcUa/python-opcua

The C++ library is under development but works will all tested clients and servers. It support addressspace browse, read, write and address space modification as well as subscriptions and datachange events and method calls(the last one only on client).

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:

server = opcua.Server()
server.set_endpoint("opc.tcp://192.168.56.1:4841")
server.start()
try:

    uri = "http://examples.freeopcua.github.io"
    idx = server.register_namespace(uri)

    objects = server.get_objects_node()

    myfolder = objects.add_folder(idx, "MyFolder")
    myvariable = myfolder.add_variable(idx, "MyVariable", 3)

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

finally:
    server.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: