SSCP to MySQL Bridge

This daemon-based service allows bi-directional data transfer between an Unipi unit running Mervis and a MySQL database through an SSCP protocol (the proprietary protocol used by Mervis). The daemon can run on any Linux machine (database server or another remote machine) or directly on the unit.

Installation scenarios

Supported operations

  1. SELECT - This action will read a row from the specified table and force the values to the relevant Mervis variables within the unit. The row can be specified using the “where” parameter, which will be directly used as a “WHERE” clause in the SQL query. (Set Mervis variable according to the DB)
  2. UPDATE - This action will update a row in the specified table with the variable values in the unit. The row can be specified using the “where” parameter, which will be directly used as a “WHERE” clause in the SQL query. (Set DB row according to the Mervis variable)
  3. INSERT - This action will insert a row with current unit values into the specified table each time the variable state is read from the unit. (Log Mervis variable to the DB)

Currently it is not supported to send long data types (LREAL, LINT, ULINT, etc.), or STRING and DT.

Supported platforms

*Currently arm64 and armhf are supported

QUICK START GUIDE

Installation

  1. Add the Unipi Debian repostiory into your apt-sources list (skip this step if you are working with an Unipi unit). Replace the <distro> placeholder with your Debian distribution name – stretch or buster.
    sudo su
    echo "deb https://repo.unipi.technology/debian <distro> main" >> /etc/apt/sources.list.d/unipi.list
    wget https://repo.unipi.technology/debian/unipi_pub.gpg -O - | apt-key add apt-get update 
  2. Install the application package.
    apt-get install sscp-sql-bridge

Packages with external libraries (libyaml, libmysqlcppconn, libboost-system, libssl) are installed automatically if necessary. By default, binary executable is installed into /opt/unipi/tools directory.

Configuration

All configuration consists of these two files:

  1. /etc/unipi/sscp-sql-bridge.d/mapping.yaml is the main configuration file containing IP addresses and credentials for both database server(s) and mervis-running machine(s) as well as all settings related to the variables transferred. By default, the file contains a commented example configuration that must be replaced by the right values according to the application.
  2. One or more .vlist file(s) containing a list of all variables in the Mervis project(s). These files are generated automatically by the Mervis IDE and are located in the main Mervis project folder in your Windows PC. These files should be copied (eg. using SCP) from the PC to the unit/server where this toll will run. Default path within the unit/server is /opt/unipi/data/ and can be changed in the mapping.yaml file. This .vlist file should not be edited manually.

Make sure the configuration files follow the valid YAML format. An online YAML validator (such as this one https://codebeautify.org/yaml-validator) can be used to ensure this. Do not add any extra fields that are not listed in the example.

The structure of the mapping.yaml file is described below.

Service enable

Right after the configuration is done, it is recommended to verify function by executing the binary on the terminal foreground:

cd /opt/unipi/tools/
./sscp-sql-bridge

If no error message appears in the output, the service can be enabled and started in the background (ie in daemon mode):

systemctl enable sscp-sql-bridge
systemctl start sscp-sql-bridge

Configuration file structure

Respect YAML structure of the file. The best way is to edit the example installed by default.