Embedded Java

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.

Java embedded development

Introduction

The Series 150 readers, Series 60 readers and derived systems, support developing custom Java applications. Java applications that are not limited to a small framework or sandbox.

    • 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)

For the RF control we use a modified version of the ThingMagic Mercury API SDK. Modifications include:

      • Access the GPIO capabilities.

      • Access to AdvanMux operation modes

    • The JVM in use is Oracle Java for Embedded devices Headless 1.8.0. This is a full JVM without any limitation.

ThingMagic documentation is the best way to learn how the Mercury API works.

Keonn will provide the required Java libraries along with the samples.

Embedded development requires a Target and a Host device:

  • Target device: a reader or system of the Series 150

  • Host device: any personal computer


Host machine setup

Some scripts exist only for for Unix like operating systems.

The same tasks can be accomplished easily in Windows systems

Setup Eclipse project

An Eclipse project is ready with Java sample code ti run embedded. In order to setup project, follow the steps below:

  • Download Eclipse project from Download chapter.

  • Unzip Eclipse project

  • Open Eclipse and use the 'import existing Java projects' to open it.

Transfer files to target device

The project contains a scripts folder with several shell scripts:

    • deploy.sh: creates a distribution zip file ready to be transferred to the target machine

    • run02.sh: run sample code for Series 150 revision 02 target devices

    • run03.sh: run sample code for Series 150 revision 03 target devices

    • run60.sh: run sample code for Series 60 readers devices

    • run02-debug.sh: run sample in debug mode code for Series 150 revision 02 target devices

    • run03-debug.sh: run sample in debug mode code for Series 150 revision 03 target devices

    • run60-debug.sh: run sample code in debug mode for Series 60 readers devices

The scripts require the following packages: ssh and sshpass

Execute the following:

$cd $ECLIPSE_PROJECT (change $ECLIPSE_PROJECT by the real path of the project)
$scripts/deploy.sh (this will create a release in $ECLIPSE_PROJECT/dist directory)

At this point we have a release file we can transfer to the target device and run it. Read Run embedded Java code to now how to use the release file.

Making changes to the source code

Once you have changed the source code in the Eclipse project, it is time to transfer the new classes into the target device. There are two options to transfer files:

    • Create a complete new distribution file. Use the deploy.sh script as previously seen.

    • Transfer only the .class file. Use the transfer_files.sh script

To transfer .class files, execute the transfer_files.sh script as follows:

$cd $ECLIPSE_PROJECT

$scripts/transfer_files.sh 192.168.1.31 xxxx

  • Change 192.168.1.31 by the real IP of your target machine

  • Change xxxx by the password of the keonn user

Debug embedded code from Eclipse

It is possible to execute the embedded code and debug it from within eclipse.

    • Go to Debug configurations menu

    • Add a new configuration in the Remote Java Application area

    • Make sure the configuration looks similar to:

In the target device, start the embedded code with the *-debug.sh scripts.

$ cd /home/keonn/keonn_embedded

$ sudo ./run03-debug.sh

At this point, go back to Eclipse:

    • At desired breakpoints

    • Start debug configuration

    • Debug!

You may not be able to debug the JVM code properly, as the Target and Host JVM may not be the same version

Run embedded Java 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

$ cd /etc/init.d

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

Load the hardware description

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

Enable shutdown line

$ cd /sys/class/gpio

$ sudo echo 3 > export

$ cd gpio3

$ sudo echo out > direction

$ sudo echo 0 > value (4 port model -M6e-) (AdvanReader-m4-150)

$ sudo echo 1 > value (2 port model -M6e-M or M6e-Micro-) (AdvanReader-m2-150, AdvanReader-m2-60, AdvanReader-m1-60)

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

Define reader model

Remember to define the right model in the start script, by using a parameter like;

-Dcom.keonn.system.model=0091102

-Dcom.keonn.system.model=0091103


Java binaries

Java binaries can be found at

/home/keonn/java/linux_arm_vfp_hflt/jre/bin

Java binary is found at

/home/keonn/java/linux_arm_vfp_hflt/jre/bin/java

Always use sudo to execute java applications. This is required to use the serial port that connects to the RFID module.

Code sample

Code samples may be obtained from:

  • Downloaded directly from Download chapter, sample files follow the pattern yyyyMMdd_keonn_embedded.zip.

  • As the execution of the deploy.sh in the Eclipse project scripts directory.

Once you have the yyyyMMdd_keonn_embedded.zip

    • Transfer the yyyyMMdd_keonn_embedded.zip to target device@/home/keonn

    • Use the scripts/transfer_relase.sh script

$cd $ECLIPSE_PROJECT

$scripts/transfer_release.sh 192.168.1.31 xxxx

        • Change 192.168.1.31 by the real IP of your target machine

        • Change xxxx by the password of the keonn user

    • Use any SFTP client softwate: winscp, FileZilla, etc

    • Use command line scp

    • Login into the target device by using any SSH application

$cd /home/keonn

$unzip yyyyMMdd_keonn_embedded.zip -d keonn_embedded (change yyyyMMdd by the real numbers)

$cd keonn_embedded

$chmod 755 *.sh

Run the sample

Make sure one antenna is connected at port #1. In the command line, type the following:

$ sudo ./run03.sh -d -a 1 -s S0 -t AB

To get additional help

$ sudo ./run03.sh --help

Change run03 by run02 or run60, in case your target device is a 02 revision or an AdvanReader-m-60

Source files

All sources used in the examples can be found at src/comm/keonn/xxx

Source file compilation

Check the Eclipse chapter.

Java REST embedded development

See REST development page

Download files

Find the User Guide and other downloadable content in our GitHub page: https://github.com/Keonn-Technologies/Embedded-Java-examples