Kanzi Connect service template¶
Use the Kanzi Connect service template as a basis for creating custom service plugins for embedded targets.
The template includes a Windows solution which you can use to compile the included test service, but this topic does not cover the compilation on Windows.
Requirements¶
To generate code on Windows you must have the Kanzi Connect for Windows installed.
To compile the service on Linux, you must have the Kanzi Connect for Linux extracted on a Linux host and the environment variables set. You can set these variables with the helper script
<KanziConnectInstallation>/SDK/setup_env.sh
.
The structure of the Kanzi Connect service template¶
The Kanzi Connect service template includes the example service you can create by completing the Create a custom service tutorial. See Tutorial: Create a custom Kanzi Connect service.
The only difference is the directory structure, which allows for more convenient cross-compilation using SCons:
configs
directory contains the SCons build files and the Visual Studio project.interfaces
directory contain the XML service descriptions and thegenerate_interfaces.py
that you can use to generate C++ code from an XML description.sources
directory contains the generated and modified source code.
You can find the Kanzi Connect service template in the <KanziConnectInstallation>/templates/servicetemplate
directory.
Using the Kanzi Connect service template¶
To use the Kanzi Connect service template:
Copy the Kanzi Connect service template directory
<KanziConnectInstallation>/templates/servicetemplate
to a directory where you want to create a Kanzi Connect service.For example, copy the template directory to the
<KanziConnectInstallation>/SDK
directory.Generate the C++ code from custom interface XML.
Place the XML file that describes the services interface to the
interfaces/definitions
directory. This procedure assumes that the file that contains the description is namedmyService_interface.xml
.Execute the
<KanziConnectInstallation>/SDK/interfaces/generate.py
This command generates the sources for a non-core service from the service description in
interfaces/definitions/myService_interface.xml
and stores the generated code of the service to these directories:sources/services/myservice_service
sources/plugins/myservice_service
Compile the service for Linux.
In the
configs/platforms/common/config.py
change the lineto
To build the service for the
linux_x11_glx
target, in theconfigs/platforms/linux_x11_glx
runWhen you want to create static libraries, omit
--dynamic
.When successfully compiled, you can find the service binary in the directory
$KANZI_CONNECT_SDK/servicetemplate/lib/service_myservice/linux_x11_glx/GL_Release
and the binary name contains the name of your service. For example,libservice_myservice.so
.To build the service library for other platforms, replace the platform name
linux_x11_glx
with the platform name for which you want to build the service. For example, to build a service for QNX 7 aarch64, useqnx700_screen_aarch64
and run the service on the target hardware.In the
<KanziConnectInstallation>/configs/connect_server_config.xml
, add your service to the services sectionAdd the directories where the Kanzi Connect Server and libraries are stored, to the Linux library search path, and run the Kanzi Connect Server:
When the Kanzi Connect Server starts successfully, it prints the information to the console log:
You must run the first command only once. It enables the Kanzi Connect Server to find your library. Alternatively, copy the service library to the directory where the connect_server application is.