ANSI C UA Server SDK  1.5.2.328
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Modules Pages
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>] [-d]
  -h: Shows this help
  -v: Shows detailed version information
  -c: Sets the configuration file to use (default=client_settings.conf)
  -d: For each 'd' argument, the trace level is increased by one (e.g. '-ddd' for INFO)

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

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.