Use the library

To work with Digi APIX library, you must:

  1. 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>
  2. 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 to one of the log levels defined in syslog.h:

  • LOG_EMERG: System is unusable

  • LOG_ALERT: Action must be taken immediately

  • LOG_CRIT: Critical conditions

  • LOG_ERR: Error conditions

  • LOG_WARNING: Warning conditions

  • LOG_NOTICE: Normal but significant condition

  • LOG_INFO: Informational

  • LOG_DEBUG: Debug-level messages

Build your application

You can build your own application:

  • Using the pre-compiled toolchain:

  • As part of the Digi Embedded Yocto build, you must create a recipe similar to the 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.

Add your user to the digiapix group to have access privileges to the required interfaces. See Create users and groups.