ANSI C Based OPC UA Client/Server/PubSub SDK
ANSI C SDK Sample Client

The ANSI C SDK Sample Client is a collection of examples for developing different features of an OPC UA client.

The sample code can be found in the files

The complete Visual Studio project can be found in Examples → UA ANSI C Sample Client Project.

Command Line Arguments

The Sample Client application is able to recognize a set of command line arguments. On Linux systems, the native getopt implementation is used, on Windows, the pthread-win32 compatibility library is used which provides a getopt implementation for Windows.

The following command line arguments are recognized:

Usage: ./uaclientc [-h] [-v] [-c <config file>] [-u <URL>]
  -h: Shows this help
  -v: Shows detailed version information
  -c: Sets the configuration file to use (default=client_settings.conf)
  -u: Sets the URL to use (default is to use the URLs from the configuration file)

Included Examples

The Sample Client provides examples for the most important OPC UA client use cases.

The sample code and the referenced functions in the following list can be found in the file democlient.c.

It provides examples for:

  • Server discovery
  • Certificate and security handling (methods SetupPKIInfrastructure and ClientMain)
  • Connect to server
  • Disconnect from server
  • Read values from server (method Demo_Read)
  • Create subscription and data monitored items
  • Browse the server address space
  • Call methods

The callback handling for data changes and events is implemented in Demo_Subscription_DataChange_CB and Demo_Subscription_NewEvents_CB.

The configuration parameters for the client (DiscoveryUrl, ServerUrl etc.) are loaded from the file client_settings.conf and stored in the appropriate client and session structures.