ANSI C Based OPC UA Client/Server/PubSub SDK  1.9.1.442
Custom PubSub Message Handling

The PubSub Stack and SDK integration allows custom PubSub message handling. Such custom message handling is mainly necessary for real-time communication parts. Since the OPC UA server is typically running with lower priorities than real-time components, also the PubSub communication is executed in the same priority.

OPC UA PubSub has different transport profiles (message mapping and transport protocol mapping). Most of them do not need custom handling and the default SDK implementation can be used. Such an example is UADP over MQTT or UADP over UDP multi-cast.

If transport profile like UADP over Ethernet has stricter timing requirements, the communication needs typically higher priority and optimized processing. Such requirements can be fulfilled by doing the following custom implementations:

  • Custom data integration to encode the data to be sent by a DataSetWriter directly from the data source into the network message or to decode the data received by a DataSetReader directly from the network message to the data target.
  • Custom timing of WriterGroup for sampling and publishing of network message at the configured offsets
  • Custom network integration for optimized buffer management, prioritized sending and receiving of network messages

These three custom handlers are typically implemented together.

For the custom data integration and custom timing, the SDK provides a callback interface where the application is called for every PubSub object during the start-up of the PubSub configuration. For each DataSetWriter, DataSetReader and WriterGroup, the application can decide if it wants to handle the processing instead of the default processing provided by the SDK. The UaServer_PubSub_SetCallback function is used to register the callback interface.

The following sample code can be found in the file demoserver.c in the function ServerMain of the ANSI C SDK Demo Server.

OpcUa_MemSet(&pubSubCbInterface, 0, sizeof(pubSubCbInterface));
pubSubCbInterface.WriterData = PubSub_WriterData;
pubSubCbInterface.ReaderData = PubSub_ReaderData;
pubSubCbInterface.WriterGroupProcessing = PubSub_WriterGroupProcessing;
uStatus = UaServer_PubSub_SetCallback(&g_UaServer, &pubSubCbInterface);
OpcUa_GotoErrorIfBad(uStatus);

The file demoserver.c in the ANSI C SDK Demo Server contains also sample code for the callback implementations.