Tutorials#
EC Protocol Bridge Example Configurations#
This section provides a set of examples, which exercise the functionality of the EC Protocol Bridge (Plug-in Framework). Each example supplies a different configuration file to the EC Protocol Bridge. The configuration file determines the plug-ins that are loaded and the configuration, thus the overall functionality.
EC Protocol Bridge Prerequisites and Instructions#
Make sure elevated permissions are available for best results, depending on the example being executed.
Make sure you have terminal access to execute the EC Protocol Bridge and view the results.
Adjust the command line for each test case depending upon the file path of the EC Protocol Bridge and the configuration test files. All examples assume the current directory is the location of the EC Protocol Bridge and the ‘config’ directory is a sub-directory.
Allow the application to execute for 10 seconds or so for each test case and then terminate with CTRL + C. This should allow sufficient time for the plug-ins to initialize, connect to resources, and start outputting valid results to the terminal.
Example #1: Data Exchange using all Datatypes#
This example demonstrates the exchange of all supported datatypes between two plug-ins.
Navigate to the EC Protocol Bridge directory on the target system:
$ cd /opt/ec-protocol-bridge
Execute the EC Protocol Bridge and supply the smoke-test.yaml configuration:
$ ./ec-bridge ./config/smoke-test.yaml
Expected Results
Three output data fields: an integer, a float, and a string. Look for lines similar to these (ignoring all others) and make a note of any errors (a char E after the timestamp):
15:12:16.214374 D eci_display_variant fld-int32: 1 15:12:16.215392 D eci_display_variant fld-float: 0.100000 15:12:16.227001 D eci_display_variant fld-string: A random number: "77"
Example #2: OPC UA Publish and Subscribe over ETF#
This example demonstrates OPC UA Publish and Subscribe over ETF using separate OPC UA instances.
Navigate to the EC Protocol Bridge directory on the target system:
$ cd /opt/ec-protocol-bridge
Execute the EC Protocol Bridge and supply the
opc-pubsub-etf-loopback.yaml
configuration:$ ./ec-bridge ./config/opc-pubsub-etf-loopback.yaml
Expected Results
Three output data fields: an integer, a float, and a string. Look for lines similar to these (ignoring all others) and make note of any errors (a char E after the timestamp):
20:38:00.303452 D eci_display_variant fld-int32: 1 20:38:00.303478 D eci_display_variant fld-float: 0.100000 20:38:00.303493 D eci_display_variant fld-string: A random number: "77"
Example #3: OPC UA Client Read and Write#
This example demonstrates OPC UA Client Write and Read.
On terminal 1, run the EC Server Configuration:
$ /opt/ec-protocol-bridge/opcsvr /opt/ec-protocol-bridge/config/opcsvr.yaml
On terminal 2, navigate to the EC Protocol Bridge directory on the target system:
$ cd /opt/ec-protocol-bridge
On terminal 2, execute the EC Protocol Bridge and supply the
opc-cli-rw.yaml
configuration:$ sudo ./ec-bridge ./config/opc-cli-rw.yaml
Expected Results
Three output data fields: an integer, a float, and a string. Look for lines similar to these (ignoring all others) and make note of any errors (a char E after the timestamp):
15:12:16.214374 D eci_display_variant fld-int32: 1 15:12:16.215392 D eci_display_variant fld-float: 0.100000 15:12:16.227001 D eci_display_variant fld-string: A random number: "77"
Example #4: Secure OPC UA Client Read and Write#
This example demonstrates a secure OPC UA client (sign and encrypt).
As a pre-requisite, the server needs a signed certificate that includes its public key, and the client needs a signed certificate that includes its public key. For more details on generating the keys, refer to OPC UA Key Generation.
The example consists of the following:
An OPC UA server application,
opcsvr
, with nodes from which the client plug-in will read. This application is written such that the server requires sign and encrypt security. The configuration for the application isopcsvr-secure.yaml
. This OPC UA server runs on port 53550.The EC Protocol Bridge and OPC UA client plug-in. This is the example being demonstrated. The configuration for the plug-in is
opc-cli-rw-secure.yaml
.The certificate and private key files for the server that runs on port 53550 and the client running as a plug-in. These are
server-certificate.der
,server-private-key.der
,client-certificate.der
, andclient-private-key.enc
.
On terminal 1, run the EC Server Configuration:
$ /opt/ec-protocol-bridge/opcsvr /opt/ec-protocol-bridge/config/opcsvr-secure.yaml
On terminal 2, navigate to the EC Protocol Bridge directory on the target system:
$ cd /opt/ec-protocol-bridge
On terminal 2, execute the EC Protocol Bridge and supply the
opc-cli-rw-secure.yaml
configuration. Note that-E
is used, so that thesudo
user can inherit environment variables needed for the key store:$ sudo -E ./ec-bridge ./config/opc-cli-rw-secure.yaml
Expected Results
Three output data fields: an integer, a float, and a string. Look for lines similar to these (ignoring all others) and make note of any errors (a char E after the timestamp):
15:12:16.214374 D eci_display_variant fld-int32: 1 15:12:16.215392 D eci_display_variant fld-float: 0.100000 15:12:16.227001 D eci_display_variant fld-string: A random number: "77"
Example #5: EII Message Bus Publisher and Subscriber#
This example demonstrates the EII Message Bus (EMB) configuration with an instance of publisher and subscriber.
Navigate to the EC Protocol Bridge directory on the target system:
$ cd /opt/ec-protocol-bridge
Execute the EC Protocol Bridge and supply the
emb-ipc-loopback.yaml
configuration:$ ./ec-bridge ./config/emb-ipc-loopback.yaml
Expected Results
Three output data fields: an integer, a float, and a string. Look for lines similar to these (ignoring all others) and make note of any errors (a char E after the timestamp):
15:26:06.903033 D eci_display_variant fld1: 1 15:26:06.903654 D eci_display_variant fld2: 0.100000 15:26:06.904075 D eci_display_variant fld3: A random number: "90"
Example #6: MQTT Publish and Subscribe#
This example demonstrates MQTT publishing.
Install the mosquitto utility Deb packages:
$ sudo apt install mosquitto mosquitto-clients
On terminal 1, launch the MQTT subscriber that listens for all topics:
$ mosquitto_sub -v -t '#'
On terminal 2, navigate to the EC Protocol Bridge directory on the target system:
$ cd /opt/ec-protocol-bridge
On terminal 2, execute the EC Protocol Bridge and supply the
mqtt-loopback.yaml
configuration:$ ./ec-bridge ./config/mqtt-loopback.yaml
Expected Results
The terminal running the MQTT subscriber should output the content published by the MQTT plug-in. This will consist of a JSON string containing three data fields, one an incrementing counter, one a float, and one string with random number. For example, look for lines similar to these (ignoring all others) and make note of any errors (a char E after the timestamp):
message {"fld-int32":17,"fld-float":1.7000000476837158,"fld-string":"A random number: \"39\""}