Texas Instruments

MSP430 Java HID Demo App -- Release Notes

Introduction

Welcome to the MSP430 Java HID USB Demo App! This is an example of a host-side HID application. It's designed to use the HID-Datapipe format (see the Programmer's Guide for more information). However, it could also be used for any custom HID device -- that is, an HID device not driven directly by the OS, like a mouse/keyboard.

The project is composed of a Java GUI and C drivers. The communication between Java and the C drivers is Java Native Interface (JNI) based.   This means there is an accompanying SO in the same path as the *.jar file that contains the native calls.   

This document is divided into the following sections:


Prerequisites

To run the app:

To re-build the app:



Running the HID Demo App

The HID Demo App can be run with any of the HID-Datapipe examples included in the USB Developers Package. Please refer to the Examples Guide in the Developers Package for usage information.

The Hid Demo App may be executed from a command line, by navigating to the directory in which the *.jar file is located, and typing  the following command:

    java -jar -Djava.library.path=/<path_to_.so_file>/    HidDemo.jar  

This should bring up the HID Demo App. If it does not, check to ensure that a Java Virtual Machine (JVM) is listed in your PC's path.

Unless you are running the application as root, a one-time setup is required to grant permissions to the HID device mounted by the MSP USB.  Root permissions are required for this setup.


Rebuilding  the HID Demo App

This update can build 32- and 64-bit  libraries. The project contains:

com Top Level Java and Class files
doc Release Notes image files
icons User interface resources
jni C sources and library

There is also a Makefile, at top level, for rebuilding the application (*.jar file and SO).  To rebuild, please see pre-requisites.
The HID Demo App was developed only as an example, so you're encouraged to modify and update it.  In order to do this, you will need the following software installed:

The OpenJDK may be downloaded from:
http://openjdk.java.net/install/

You will need to install development packages for libudev, and libusb. On Debian/Ubuntu systems these can be installed by running:
        sudo apt-get install libudev-dev libusb-1.0-0-dev


Modify the Makefile (in hidDemo-java/Makefile) to add the location of the JDK and libusb you have installed on your system.   If the compilers were installed correctly, the only changes that should be needed is the JDK path. 

ifeq (${Linux},1)
    CC=gcc
    CXX=gcc
    CCFLAGS=-m64 -fPIC
    JDK="/usr/lib/jvm/java-6-sun-1.6.0.26"
    LIB_NAME=libHidCommunicationManagerLinux64.so
    JNICFLAGS=-c -I${JDK}/include -I${JDK}/include/linux -std=gnu99 -D__int64="long long" -fPIC
    JNILDFLAGS=-Wall -D_JNI_IMPLEMENTATION_
    LNXOBJS=${HIDAPI_ROOT}/linux/hid-libusb.c
    LNXLIBS=-lusb-1.0 -ludev -lrt
else
    CC=gcc
    CXX=gcc
    CCFLAGS=-m32 -fPIC
    JDK="/usr/lib/jvm/java-6-sun-1.6.0.26"
    LIB_NAME=libHidCommunicationManagerLinux.so
    JNICFLAGS=-c -I${JDK}/include -I${JDK}/include/linux -std=gnu99 -D__int64="long long"
    JNILDFLAGS=-Wall -D_JNI_IMPLEMENTATION_
    LNXOBJS=${HIDAPI_ROOT}/linux/hid-libusb.c
    LNXLIBS=-lusb-1.0 -ludev -lrt
endif



The JDK paths should point to where your system's JDK is installed (the JDK directory right above bin/ that contains javah.exe).

The final step is to open a terminal window and  run "make" (or "make Linux=1", for 64-bit build) in the HidDemo-linux directory.




Validation

The 32-bit version has been tested on a 32-bit Linux machine and the 64-bit version has been tested on a 64-bit Linux machine.



Known Issues

If the HID port connected to the device does not have read and write permissions, the Java Hid Demo App will disapper upon connection to the device.  



Versioning

This is demo code, and therefore there is no versioning.


Support

First check the Examples Guide and MSP430 USB API Programmer's Guide in the USB Developers Package for more information. If you still need support, please visit the MSP430 E2E forum. or e-mail us directly at msp430ware@list.ti.com.