Set up your project for Digi APIX
Use the library
To work with Digi APIX library, you must:
- Include the required header files in your application source code. This depends on the interfaces you are going to use. For example, to use GPIO and PWM APIs:
#include <libdigiapix/gpio.h> #include <libdigiapix/pwm.h>
- Link against the dynamic library already included in the precompiled toolchain. See Application development for more information.
The library provides a pkg-config file, libdigiapix.pc. To configure the proper compilation flags and linked libraries, add the following lines in your makefile:
[...] CFLAGS += $(shell pkg-config --cflags libdigiapix) LDLIBS += $(shell pkg-config --libs --static libdigiapix) [...]
Set library logging
The library uses syslog for logging. By default, the log level is error (LOG_ERR).
You can establish the logging level of the library by calling ldx_set_log_level():
Function |
Description |
---|---|
ldx_set_log_level(level) |
Set the log level of the Digi APIX library. level can be one of the log levels defined in syslog.h:
|
Build your application
You can build your own application:
- Using the pre-compiled toolchain:
- In command line, follow the steps in Application development.
- In Eclipse with Digi Embedded Yocto plug-in, follow the steps in Create a C/C++ project from scratch.
- As part of the Digi Embedded Yocto build.
You must create a recipe similar to dey-examples-digiapix.bb recipe. Make sure your recipe:- Adds a build-time dependency on libdigiapix
- Adds a runtime dependency on libdigiapix
SUMMARY = "My Digi APIX application" [...] DEPENDS = "libdigiapix" [...] RDEPENDS_${PN} = "libdigiapix" [...]
Security recommendations
Digi recommends to run your applications as a standard user and not as root. For that purpose, Digi embedded API extensions creates the group called digiapix with permissions to access the API interfaces.
You only need to add your user to the digiapix group to have privileges to access the required interfaces. See Create users and groups.