Recent Changes - Search:

edit SideBar

Nrjavaserial

nrjavaserial is one of the Java Serial Port Interfaces.

nrjavaserial is a port of RxTx that includes the shared libraries in the jar file.

Debugging

To debug nrjavaserial Java code, set -Dgnu.io.log.mode=PRINT_MODE, for example:

export JAVAFLAGS=-Dgnu.io.log.mode=PRINT_MODE
$PTII/bin/vergil

To debug C code, edit nrjavaserial/src/main/c/src/SerialImp.c and add

#define DEBUG 1
#define DEBUG_VERBOSE 1

and rebuild.

Building

We need to rebuild nrjavaserial because of RxTx Hanging.

1. Check out the repo:

git clone https://github.com/NeuronRobotics/nrjavaserial.git
OR, use the TerraSwarm branch:
git clone https://github.com/terraswarm/nrjavaserial

2. Install gradle For Mac OS X:

  sudo port install gradle

For Ubuntu, a recent version of gradle is needed, otherwise Gradle fails with jcenter missing

  sudo add-apt-repository ppa:cwchien/gradle
  sudo apt-get update
  sudo apt-get install gradle

3. To rebuild the C version, see Building the Native Code Portion below, to rebuild just the Java:

  cd nrjavaserial
  gradle build

If you have trouble, see Problems 4. Running gradle build creates ./build/libs/nrjavaserial-3.11.0.jar, which gets copied to $PTII/lib with a name that includes .devel:

  cp ./build/libs/nrjavaserial-3.11.0.jar $PTII/lib/nrjavaserial-3.11.0.devel.jar

5. Optional: Configure looks for $PTII/lib/nrjavaserial-3.11.0.devel.jar. If you want to change the name of the file, then to update which version of nrjavaserial ptolemy uses, update $PTII/configure.in by searching for the previous nrjavaserial-X.Y.Z.jar file and substituting in the new name:

bash-3.2$ cd $PTII
bash-3.2$ svn diff configure.in
Index: configure.in
===================================================================
--- configure.in        (revision 74002)
+++ configure.in        (working copy)
@@ -3855,7 +3855,7 @@
 #--------------------------------------------------------------------
 # We only need to look for rxtx if $PTII/ptolemy/actor/lib/io/comm is present
 RXTX_USER_DIR="$PTII/ptolemy/actor/lib/io/comm"
-RXTX_JAR_DEFAULT='${PTII}/lib/nrjavaserial-3.11.0.jar'
+RXTX_JAR_DEFAULT='${PTII}/lib/nrjavaserial-3.11.0.7Dec2015jar'
 RXTX_PRESENT=no
 # PTLEGO_DIR is set to lego
 # $PTII/ptolemy/apps/makefile if the Java Communications API was found
@@ -3883,7 +3883,7 @@
     AC_ARG_WITH(rxtx, [  --with-rxtx=DIR       use Java Serial Port Interfacrxtx from DIR,
                           defaults to $RXTX_JAR_DEFAULT],
        RXTX_JAR=$withval,
-       RXTX_JAR=$PTII/lib/nrjavaserial-3.11.0.devel.jar)
+       RXTX_JAR=$PTII/lib/nrjavaserial-3.11.1.jar)

     if test -f "$RXTX_JAR"; then
         PT_MSG_RESULT($RXTX_JAR)
@@ -3931,7 +3931,7 @@
     You need not download rxtx unless you plan the actors in actor.lib.comm.
     The rxtx package can be found at
     https://github.com/NeuronRobotics/nrjavaserial/releases and the jar
-    file placed at $PTII/lib/nrjavaserial-3.11.0.devel.jar and configure rerun.])
+    file placed at $PTII/lib/nrjavaserial-3.11.1.jar and configure rerun.])
     fi
 fi

bash-3.2$

6. Run commit configure.in, run autoconf and commit configure:

bash-3.2$ svn commit -m "Updated the nrjavaserial jar file to the head of the repo to fix a hanging problem, see https://chess.eecs.berkeley.edu/ptexternal/wiki/Main/Nrjavaserial." configure.in
Sending        configure.in
Transmitting file data .
Committed revision 74007.
bash-3.2$ autoconf
bash-3.2$ svn commit -m "configure.in changed" configure
Sending        configure
Transmitting file data .
Committed revision 74008.
bash-3.2$

7. Add the new library, delete the old library (Could be done in one step)

bash-3.2$ svn add lib/nrjavaserial-3.11.1.jar
A  (bin)  lib/nrjavaserial-3.11.1.jar
bash-3.2$ svn delete --force lib/nrjavaserial-3.11.0.devel.jar
D         lib/nrjavaserial-3.11.0.devel.jar
bash-3.2$ svn commit -m "Updated the nrjavaserial jar file to the head of the repo to fix a hanging problem, see https://chess.eecs.berkeley.edu/ptexternal/wiki/Main/Nrjavaserial." lib/nrjavaserial-3.11.0.devel.jar lib/nrjavaserial-3.11.1.jar
11.0.7Dec2015.jar
Adding  (bin)  lib/nrjavaserial-3.11.0.1.jar
Deleting       lib/nrjavaserial-3.11.0.develjar
Transmitting file data .
Committed revision 74009.
bash-3.2$

Building the Native Code Portion of nrserialjava

See https://github.com/NeuronRobotics/nrjavaserial, which says to run make target where the target is one of arm, linux64, osx. Other platforms are supported as well, see nrjavaserial/Makefile.

Building the Native Code Under OS X

https://github.com/NeuronRobotics/nrjavaserial says:

"We're pretty big on maintaining backwards compatibility as far as reasonable. Our OS X natives target OS X 10.5, so to build them, you'll need an appropriate SDK installed. This StackOverflow answer provides pointers for getting the appropriate SDK installed."

To do this, we download an old version of Xcode and install the MacOSX10.5.pkg.

  1. Download Xcode 3.2.6. 4.1Gig, use a fast connection.. An Apple Developer ID is necessary. Follow the link, log in and then follow the link again to get to the right page.
  2. The installer will open. Don't install it
  3. In a terminal, run
    open /Volumes/Xcode\ and\ iOS\ SDK/Packages/
    Or, if you don't want to run the terminal, then go to the window with the Xcode installer and click on Go -> Go to Folder and enter packages
  4. In the finder, browse to the MacOSX10.5.pkg, double click on it and install it.
  5. Create links:
     sudo mkdir /Developer
     sudo ln -s /SDKs /Developer/
  6. Make nrjavaserial:
    make osx
  7. Update the ptII library:
    cp ./build/libs/nrjavaserial-3.11.0.jar $PTII/lib/nrjavaserial-3.11.0.devel.jar

Building the Native Code Under Ubuntu

Run

  make linux64

Update the PTII Jar File

Update the PTII Jar File ''note that the actual name of the file in $PTII/lib may change over time.

 cp ./build/libs/nrjavaserial-3.11.0.jar $PTII/lib/nrjavaserial-3.11.0.devel.jar 

Problems

Gradle fails with jcenter missing

Under Ubuntu 14.04.3 LTS, running gradle build fails with Could not find method jcenter() for arguments []

sbuser@swarmnuc001:~/src/nrjavaserial$ gradle build

FAILURE: Build failed with an exception.

* Where:
Build file '/home/sbuser/src/nrjavaserial/build.gradle' line: 41

* What went wrong:
A problem occurred evaluating root project 'nrjavaserial'.
> Could not find method jcenter() for arguments [] on root project 'nrjavaserial'.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug op\
tion to get more log output.

BUILD FAILED

Total time: 4.238 secs

The problem is that gradle is old, see http://stackoverflow.com/questions/27470443/could-not-find-method-jcenter-for-arguments-on-repository-container

sbuser@swarmnuc001:~/src/nrjavaserial$ gradle --version

------------------------------------------------------------
Gradle 1.4
------------------------------------------------------------

Gradle build time: Monday, September 9, 2013 8:44:25 PM UTC
Groovy: 1.8.6
Ant: Apache Ant(TM) version 1.9.3 compiled on April 8 2014
Ivy: non official version
JVM: 1.7.0_85 (Oracle Corporation 24.85-b03)
OS: Linux 3.13.0-66-lowlatency amd64

The solution is at http://askubuntu.com/questions/328178/gradle-in-ubuntu

  sudo add-apt-repository ppa:cwchien/gradle
  sudo apt-get update
  sudo apt-get install gradle

After the install, the version is updated:

sbuser@swarmnuc001:~/src/nrjavaserial$ gradle --version

------------------------------------------------------------
Gradle 2.9
------------------------------------------------------------

Build time:   2015-11-17 07:02:17 UTC
Build number: none
Revision:     b463d7980c40d44c4657dc80025275b84a29e31f

Groovy:       2.4.4
Ant:          Apache Ant(TM) version 1.9.3 compiled on December 23 2013
JVM:          1.8.0_65 (Oracle Corporation 25.65-b01)
OS:           Linux 3.13.0-66-lowlatency amd64

sbuser@swarmnuc001:~/src/nrjavaserial$

See Also

Edit - History - Print - Recent Changes - Search
Page last modified on February 24, 2017, at 08:14 PM