Setting up to use the HIL C API in Windows End of trail navigation bar

Setting up to use the HIL C API on Linux

The user needs to follow a set of steps to setup the C/C++ application to use the HIL C API. For Linux platforms, we assume that gcc will be used and is already installed on the Linux platform. Note that a 64-bit Linux platform is currently required. The only platform that is currently officially supported is Ubuntu 16.04 LTS. Please perform the following procedure to setup your application. These instructions assume that the HIL SDK has already been installed on the Linux platform.

  1. The primary HIL C API header file on Linux is /opt/quanser/hil_sdk/include/hil.h. This header file must be included in your source in order to use the HIL API. Since it references other header files, the /opt/quanser/hil_sdk/include directory must be added to your include file path. Adding this directory to your include path may be done in a makefile by adding the line:

    CFLAGS += -I/opt/quanser/hil_sdk/include

    which adds the include path to the standard C compiler flags.

  2. The primary HIL C API library on Linux is /opt/quanser/hil_sdk/lib/libhil.a, which is a static link library. Applications built using the HIL C API must link with this library. However, the functions in the HIL C API depend on other libraries as well, such as libquanser_runtime.a and libquanser_common.a. These libraries are all contained in the /opt/quanser/hil_sdk/lib folder. Hence, this directory must be added to your library search path. Add the following two lines to a makefile to link with the HIL C API:

    LDFLAGS += -L/opt/quanser/hil_sdk/lib

    LIBS += -lhil -lquanser_runtime -lquanser_common -lrt -lpthread -ldl -lm -lc

    which add the /opt/quanser/hil_sdk/lib folder to the library search path, and define the requisite libraries for linking with the HIL C API. The LIBS macro will have to be added at the end of the link command.

For example, suppose you are building myhilapp from the source file myhilapp.c. Then the final makefile might look something like this:

            
CFLAGS  += -I/opt/quanser/hil_sdk/include
LDFLAGS += -L/opt/quanser/hil_sdk/lib
LIBS    += -lhil -lquanser_runtime -lquanser_common -lrt -lpthread -ldl -lm -lc

myhilapp: myhilapp.o
	cc $(LDFLAGS) $< -o $@ $(LIBS)

myhilapp.o: myhilapp.c
                    
        

Documentation

The documentation for the HIL C API is installed under the /opt/quanser/hil_sdk/help directory. The top-level help file is index.html. However, the best way to open the documentation is to use the convenient HIL SDK "application" set up by the installer. Simply search for "HIL SDK" and run the HIL SDK "application" (the icon looks like the letter 'Q'). This will open FireFox with the primary help page and a table of contents.

Examples

Examples for the HIL C API are installed to the /opt/quanser/hil_sdk/examples folder. Copy this folder to your desktop or another convenient directory to use the examples.

Before building an example, open the source file for the example and make sure the board_type variable is set to the board that you have plugged in to your system. Also make sure that the board supports the different analog, encoder, PWM, digital or other channels used in the example. If not, modify the example to reflect your hardware's capabilities.

Each example folder contains a Makefile that may be used to build the example. Simply open a Terminal window in the particular example's folder and type:

make

to build the example. The example may then be run in the terminal window simply by typing the name of the executable preceded by "./". For instance, to run the analog_loopback_example, type:

./analog_loopback_example

 

navigation bar