Embedded C/C++

DISCLAIMER OF LIABILITY

THE PROCEDURES AND SAMPLES IN THIS PAGE ARE PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND (EITHER EXPRESS OR IMPLIED), INCLUDING BUT NOT LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A SPECIFIC OR GENERAL PURPOSE AND THOSE ARISING BY STATUTE OR BY LAW, OR FROM A CAUSE OF DEALING OR USAGE OF TRADE.

THIS ALSO APPLIES TO THE CONSEQUENCES OF ANY ACTIONS TAKEN ON THE BASIS OF THE INFORMATION PROVIDED.

C/C++ embedded development

Introduction

The Series 150 readers, Series 60 readers and derived systems, support developing custom C/C++ applications.

C/C++ applications that are not constrained by a reduced SDK, they can make use of any library a Linux system may have.

    • The RF operations are backed up by

      • ThingMagic M6e (adrd-m4-150)

      • ThingMagic M6e-M (adrd-m2-150)

      • ThingMagic M6e-Micro (adrd-m2-60)

      • ThingMagic M6e-Nano (adrd-m1-60)

C/C++ development is based on ThingMagic Mercury API SDK.

Target devices for C/C++ embedded applications are the devices and systems listed above.

    • Keonn provides compiled versions of all ThingMagic samples (see Download chapter)

    • Keonn provides a Makefile to compile all sample source code into executables.

Setting up C/C++ devel environment

In order to set up a development environment:

    • Request permission to log into the target device

    • Install required packages (type commands)

sudo apt-get update

sudo apt-get install libreadline-dev build-essential

Downloads

You can find our examples in our GitHub page: https://github.com/Keonn-Technologies/Embedded-C-examples

Building C/C++ samples

Follow the steps

    • Check whether the directory /home/keonn/embedded-c exists. In case it doesn't exist:

    • Check whether the file /home/keonn/lib/libmercuryapi.so.1 exists. In case it doesn't exist

      • Download LIBMERCURYAPI.SO.1 file from the Download files chapter

      • Transfer to /home/keonn/lib directory

      • Rename to /home/keonn/lib/libmercuryapi.so.1

mv LIBMERCURYAPI.SO.1 libmercuryapi.so.1

    • Cd into the /home/keonn/embedded-c directory

cd embedded-c

The directory /home/keonn/embedded-c should already contain the sample executables.

Compile samples is strictly required if changes have been done to the source code.

    • Compile samples

make clean && make

If the development environment is not in the target machine itself, it may be required to cross compile to ARM v7 little endian 32 bits.

Running embedded C/C++ code

Prevent AdvanNet software from starting by default

AdvanNet is started by default whenever the system boots up. In the command line, type the following:

sudo killall java

In case we want to prevent AdvanNet from starting automatically upon system reboot, execute:

cd /etc/init.d

sudo /usr/sbin/update-rc.d keonn-startup.sh remove

This is required just once.

In order to revert back to the original state:

cd /etc/init.d

sudo /usr/sbin/update-rc.d keonn-startup.sh defaults

Load the hardware description

This is required to configure the internal pin muxing options.

$ sudo /home/keonn/bin/generate_capes.sh

Enable shutdown line

This is required to enable the RF module shutdown line.

Follow the instructions for your system:

AdvanReader-m2-150.03

$ cd /sys/class/gpio

$ sudo sh -c 'echo 3 > export'

$ cd gpio3

$ sudo sh -c 'echo out > direction'

$ sudo sh -c 'echo 0 > value'

AdvanReader-m4-150.03

$ cd /sys/class/gpio

$ sudo sh -c 'echo 3 > export'

$ cd gpio3

$ sudo sh -c 'echo out > direction'

$ sudo sh -c 'echo 1 > value'

AdvanReader-m1-60 and AdvanReader-m2-60

$ cd /sys/class/gpio

$ sudo sh -c 'echo 68 > export'

$ cd gpio68

$ sudo sh -c 'echo out > direction'

$ sudo sh -c 'echo 0 > value'

Only required in AdvanReader-m-150.03 and AdvanReader-m-60

Executing C/C++ applications

Build process creates .o object and executable files with the right permissions to be executed.

In order to execute the readasync sample, do the following:

keonn@AdvanXXXX:/home/keonn# cd embedded-c

keonn@AdvanXXXX:/home/keonn/embedded-c#./readasync tmr:///dev/ttyO1 --ant 1,2

Make sure to connect at least antennas 1 and 2 to 50 ohm RFID antennas or 50 ohm terminators.

The required shared object required to build the samples is found at

/home/keonn/lib/libmercuryapi.so.1