We have upgraded the community system as part of the upgrade a password reset is required for all users before login in.

Java wrapper and code for GPIO Access (with Interrupts)



  • Based on the code I have previously supplied for C/C++ access to GPIO (see: https://community.onion.io/topic/143/alternative-c-code-for-gpio-access-now-with-interrupts and https://community.onion.io/topic/431/access-to-gpio-including-interrupts-using-new-gpio-test-program-and-library) I have now produced Java wrappers and a Java test program for access to GPIO pins that directly parallels the C/C++ code.

    In this post I just provide the basic details and necessary files for people to try it out. I will be providing a fully documented package later.

    To use the supplied code, your Omega must first fulfill some requirements:

    • Your Omega must be on release 0.0.6-b265 or later
    • Must have the kmod-gpio-irq package installed by running:
      opkg update
      opkg install kmod-gpio-irq
    • Must have sufficient disk space to install jamvm (a lightweight implementation of a full Java Virtual Machine) as in next point. Because jamvm needs more disk space to install than the Omega standardly has, you must extend the disk space using a USB drive as described in: https://wiki.onion.io/Tutorials/Using-USB-Storage-as-Rootfs
    • Must have the jamvm package installed. This is a lightweight implementation of a full Java Virtual Machine
      This may be installed by running:
      opkg install jamvm
    • Optionally, it is useful (but not absolutely necessary) to extend the Omega's working memory with swap space as described in: https://community.onion.io/topic/9/how-to-install-gcc/46

    There are 4 software components that make up the supplied code as in the following attached files:

    1. libnew-gpio.so
      The C/C++ dynamic library for GPIO access as previously supplied
      This must be placed in your /lib directory or in a directory on any defined LD_LIBRARY_PATH
    2. libNew-GpioJava.so
      This is a JNI C/C++ dynamic library that links between the Java code and the C/C++ code in libnew-gpio.so
    3. JavaNew-GPIOTest.jar
      A Java .jar file containing the a Java program being the equivalent of the previously supplied C/C++ new-gpiotest program
      This may be placed anywhere suitable (I just use /root)
    4. JavaNew_Gpio.jar
      A Java .jar file containing the Java code that calls on to libNew-GpioJava.so providing the wrapper classes for the GPIO access
      Currently this must be placed in a ./lib sub-directory relative to the directory of JavaNew-GPIOTest.jar (I use /root/lib) - however this may be changed later.

    To run the JavaNew-GPIOTest.jar Java program, from its directory, run the command:

    • jamvm -jar JavaNew-GPIOTest.jar <parameters>

    The <parameters> are exactly the same as for the C/C++ new-gpiotest program but can be displayed using the command:

    • jamvm -jar JavaNew-GPIOTest.jar help

    While this is all as yet undocumented (I will do so later), the C/C++ code was compiled on a KUbuntu machine using the Omega cross-compilation toolchain and the Java code was built on the same machine using Java JDK 8 (version 1.8.0_65-b17).
    For those of you who might be interested, the following 3 attached archive files contain the sources:
    a. libNew-GpioJava-src.tar.bz2
    b. JavaNew-GPIOTest-src.tar.bz2
    c. JavaNew_Gpio-src.tar.bz2



  • Great work!


Log in to reply
 

Looks like your connection to Community was lost, please wait while we try to reconnect.