Back to the main page.
Bug 2944 - add java implementation for openbci and realtime buffer server
Status | CLOSED WORKSFORME |
Reported | 2015-08-17 08:29:00 +0200 |
Modified | 2019-08-10 12:36:49 +0200 |
Product: | FieldTrip |
Component: | realtime |
Version: | unspecified |
Hardware: | PC |
Operating System: | Mac OS |
Importance: | P5 normal |
Assigned to: | Robert Oostenveld |
URL: | |
Tags: | |
Depends on: | |
Blocks: | |
See also: |
Robert Oostenveld - 2015-08-17 08:29:18 +0200
Robert Oostenveld - 2015-08-17 08:29:54 +0200
On 10 Jul 2015, at 16:42, Jason Farquhar wrote by email: Attached is the jar (openBCI2ft.jar.txt -- remove the .txt to use) and a zip of the code for the java implementation of the acquisition connector. Note: 1) you will also need to put as copy of jSSC.jar in the lib directory to make it work. (i'ts attached with the name jSSC.jar.txt as gmail blocks it otherwise) 2) it is built with ant 3) I have also attached the startup scripts to call it, startOpenBCI.bat and startOpenBCI.sh Also FYI: I have attached a zip of the code for a java based implementation of a fieldtrip buffer server. We use this for cross-platform independence -- particularly because it runs directly on android (and we have some extra android wrapper applications etc. if you are interested.)
Robert Oostenveld - 2015-08-17 08:45:12 +0200
mac011> svn commit . Adding . Adding 01-OpenBCI_SDK.md Adding 90-dongle.rules Adding COPYING Adding README.md Adding build.xml Adding lib Adding (bin) lib/jssc.jar Adding (bin) lib/openBCI2ft.jar Adding src Adding src/DataPacket_ADS1299.java Adding src/OpenBCI_ADS1299.java Adding src/OpenBCI_ADS1299.pde Adding src/OpenBCI_GUI.pde Adding src/Serial.java Adding src/dataTypes.pde Adding src/jssc_test.java Adding src/openBCI2ft.java Adding src/pde2java.txt Transmitting file data ................ Committed revision 10599. Cleaned up and added java implementation for openbci, see https://github.com/fieldtrip/fieldtrip/tree/master/realtime/src/acquisition/openbci/java I moved some files around and removed some documentation files. I have not attempted to re-build the jar files, and the existing jar files won't work (yet) on my computer: mac011> java -jar openBCI2ft.jar Exception in thread "main" java.lang.UnsupportedClassVersionError: openBCI2ft : Unsupported major.minor version 51.0 at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClassCond(ClassLoader.java:637) at java.lang.ClassLoader.defineClass(ClassLoader.java:621) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141) at java.net.URLClassLoader.defineClass(URLClassLoader.java:283) at java.net.URLClassLoader.access$000(URLClassLoader.java:58) at java.net.URLClassLoader$1.run(URLClassLoader.java:197) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:247) mac011> java -version java version "1.6.0_65" Java(TM) SE Runtime Environment (build 1.6.0_65-b14-462-11M4609) Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-462, mixed mode)
Robert Oostenveld - 2015-08-17 08:54:23 +0200
mac011> svn commit Adding . Adding (bin) BufferServer.class Adding BufferServer.java Adding COPYING Adding (bin) FieldtripBufferMonitor.class Adding FieldtripBufferMonitor.java Adding (bin) MemoryMonitor.class Adding MemoryMonitor.java Adding Project.ede Adding README Adding (bin) SystemOutMonitor.class Adding SystemOutMonitor.java Adding data Adding (bin) data/Chunk.class Adding data/Chunk.java Adding (bin) data/Data.class Adding data/Data.java Adding (bin) data/DataModel.class Adding data/DataModel.java Adding (bin) data/DataRingBuffer.class Adding data/DataRingBuffer.java Adding (bin) data/Event.class Adding data/Event.java Adding (bin) data/EventRingBuffer.class Adding data/EventRingBuffer.java Adding (bin) data/Header.class Adding data/Header.java Adding (bin) data/RingDataStore.class Adding data/RingDataStore.java Adding (bin) data/SavingRingDataStore.class Adding data/SavingRingDataStore.java Adding (bin) data/SimpleDataStore.class Adding data/SimpleDataStore.java Adding exceptions Adding (bin) exceptions/ClientException.class Adding exceptions/ClientException.java Adding (bin) exceptions/DataException.class Adding exceptions/DataException.java Adding network Adding (bin) network/ConnectionThread.class Adding network/ConnectionThread.java Adding (bin) network/Message.class Adding network/Message.java Adding (bin) network/NetworkProtocol.class Adding network/NetworkProtocol.java Adding (bin) network/Request.class Adding network/Request.java Adding (bin) network/WaitRequest.class Adding network/WaitRequest.java Transmitting file data ............................................. Committed revision 10600. I do not know how to compile it to a jar file and/or how to execute it, hence I have not been able to test it.
Robert Oostenveld - 2015-08-17 09:01:32 +0200
I have mentioned the java buffer server on http://www.fieldtriptoolbox.org/development/realtime/buffer_java. There should be more documentation, including a description how to compile and start it (which I have not managed to do yet). I have mentioned the openbci implementation on http://www.fieldtriptoolbox.org/development/realtime/openbci
Robert Oostenveld - 2015-08-17 09:02:33 +0200
To do: it would be good to sit down with Jason to figure out and document what is needed to use the java implementations on a standard computer (i.e. not his computer).
Jason Farquhar - 2015-08-26 14:11:24 +0200
Created attachment 728 v1.5 jar
Jason Farquhar - 2015-08-26 14:12:48 +0200
Created attachment 729 v1.5 buffer-client jar
Jason Farquhar - 2015-08-26 14:13:08 +0200
(In reply to Robert Oostenveld from comment #2) This code set is built using apache ANT which is a standard java build tool (think Make but platform independent.) With ant installed type ant in the directory to build -- however the configuration file build.xml will need to be modified to point to the BufferClient.jar file for the buffer connection library. Also the code did not run because it was built targeting java 7. Attached is another version targeting java 1.4 which should run on all machines. Note though to run you (again) need the BufferClient.jar file also. Assuming it is in the lib directory you can run using: java -cp lib/BufferClient.jar:lib/jssc.jar:openBCI2ft.jar openBCI2ft
Jason Farquhar - 2015-08-26 14:14:01 +0200
Created attachment 730 v1.5 buffer-server jar
Jason Farquhar - 2015-08-26 14:14:59 +0200
The build environment is based on ANT with the config in build.xml. The jar version was for java 7. Attached is a version for java 1.5 which should run on most/all machines.
Robert Oostenveld - 2015-08-26 15:07:14 +0200
I did the following to install ANT mac011> sudo port install apache-ant Password: ---> Fetching archive for apache-ant ---> Attempting to fetch apache-ant-1.9.6_0.darwin_13.noarch.tbz2 from http://lil.fr.packages.macports.org/apache-ant ---> Attempting to fetch apache-ant-1.9.6_0.darwin_13.noarch.tbz2.rmd160 from http://lil.fr.packages.macports.org/apache-ant ---> Installing apache-ant @1.9.6_0 ---> Activating apache-ant @1.9.6_0 ---> Cleaning apache-ant ---> Updating database of binaries ---> Scanning binaries for linking errors ---> No broken files found. I understand that Java SE version "x" is also known as version "1.x", right? I have on my machine (which has OS X version 10.9.5) the following mac011> ls -al `which java` lrwxr-xr-x 1 root wheel 74 Apr 3 2014 /usr/bin/java -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java and mac011> ls -al /System/Library/Frameworks/JavaVM.framework/Versions/ total 64 drwxr-xr-x 11 root wheel 374 Apr 3 2014 . drwxr-xr-x 12 root wheel 408 Mar 11 09:08 .. lrwxr-xr-x 1 root wheel 10 Apr 3 2014 1.4 -> CurrentJDK lrwxr-xr-x 1 root wheel 10 Apr 3 2014 1.4.2 -> CurrentJDK lrwxr-xr-x 1 root wheel 10 Apr 3 2014 1.5 -> CurrentJDK lrwxr-xr-x 1 root wheel 10 Apr 3 2014 1.5.0 -> CurrentJDK lrwxr-xr-x 1 root wheel 10 Apr 3 2014 1.6 -> CurrentJDK lrwxr-xr-x 1 root wheel 10 Apr 3 2014 1.6.0 -> CurrentJDK drwxr-xr-x 8 root wheel 272 Mar 3 09:03 A lrwxr-xr-x 1 root wheel 1 Apr 3 2014 Current -> A lrwxr-xr-x 1 root wheel 59 Apr 3 2014 CurrentJDK -> /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents
Robert Oostenveld - 2015-08-26 15:15:22 +0200
mac011> cd ~/fieldtrip/realtime/src mac011> find . -name build.xml ./acquisition/openbci/java/build.xml Am I correct that ANT is required for the openbci java implementation, but not for the other java code that lives under ~/fieldtrip/realtime/src/buffer/java? Perhaps we have to reorganise the java source code of certain tools. Perhaps we should also start distributing jar files, just like we are distributing "exe" files. Should we consider a fieldtrip/realtime/bin/java directory, alongside teh system-specific binaries? I would like to have an instruction on the relevant wiki pages for the use the java code, like the one at http://www.fieldtriptoolbox.org/development/realtime/buffer_java?&#compilation
Jason Farquhar - 2015-08-26 15:38:02 +0200
Created attachment 732 build script for the java buffer server
Jason Farquhar - 2015-08-26 15:39:35 +0200
(In reply to Robert Oostenveld from comment #12) Ant is required simply to build the files (like make for the c versions.) Attached is a build.xml for the buffer server code to go in the fieldtrip/realtime/src/buffer/java/bufferserver directory. If you put it there and run ant (from that directory) it should rebuild fully.
Robert Oostenveld - 2015-08-26 15:41:55 +0200
Created attachment 733 build error log file See attached log file, below is stderr: BUILD FAILED /Users/roboos/matlab/fieldtrip/realtime/src/buffer/java/bufferserver/build.xml:20: Compile failed; see the compiler error output for details. Total time: 0 seconds
Robert Oostenveld - 2015-08-26 15:52:50 +0200
(In reply to Robert Oostenveld from comment #15) this was actually my fault. After removing the *.class files and trying again, it does work, resulting in "BufferServer.jar" mac011> svn commit Deleting BufferServer.class Deleting FieldtripBufferMonitor.class Deleting MemoryMonitor.class Deleting SystemOutMonitor.class Adding build.xml Deleting data/Chunk.class Deleting data/Data.class Deleting data/DataModel.class Deleting data/DataRingBuffer.class Deleting data/Event.class Deleting data/EventRingBuffer.class Deleting data/Header.class Deleting data/RingDataStore.class Deleting data/SavingRingDataStore.class Deleting data/SimpleDataStore.class Deleting exceptions/ClientException.class Deleting exceptions/DataException.class Deleting network/ConnectionThread.class Deleting network/Message.class Deleting network/NetworkProtocol.class Deleting network/Request.class Deleting network/WaitRequest.class Transmitting file data . Committed revision 10633. mac011> ant Buildfile: /Users/roboos/matlab/fieldtrip/realtime/src/buffer/java/bufferserver/build.xml compile: [javac] /Users/roboos/matlab/fieldtrip/realtime/src/buffer/java/bufferserver/build.xml:20: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds [javac] Compiling 21 source files to /Users/roboos/matlab/fieldtrip/realtime/src/buffer/java/bufferserver server: [jar] Building jar: /Users/roboos/matlab/fieldtrip/realtime/src/buffer/java/bufferserver/BufferServer.jar build: dist: [copy] Copying 1 file to /Users/roboos/matlab/fieldtrip/realtime/src/buffer/java main: BUILD SUCCESSFUL Total time: 1 second
Robert Oostenveld - 2015-08-26 15:58:09 +0200
you wrote in your email that you also included startOpenBCI.bat and startOpenBCI.sh, but I have not been able to find them. Consequently, I still don't know how to start it. (Sorry that I am such a Java noob)
Jason Farquhar - 2015-08-26 17:04:06 +0200
Created attachment 734 updated java buffer server build script
Jason Farquhar - 2015-08-26 17:04:36 +0200
(In reply to Robert Oostenveld from comment #16) Hi Actually, the build file was still buggy. Attached is an updated working one. If it works then you should be able to start the server with: java -jar BufferServer.jar 1972
Robert Oostenveld - 2015-08-26 17:09:45 +0200
(In reply to Jason Farquhar from comment #19) great, it works! mac011> svn commit Sending README Sending build.xml Transmitting file data .. Committed revision 10636.
Jason Farquhar - 2015-08-26 17:11:03 +0200
Created attachment 735 open bci java startup script
Jason Farquhar - 2015-08-26 17:11:25 +0200
Created attachment 736 open bci java startup script
Jason Farquhar - 2015-08-26 17:11:59 +0200
(In reply to Robert Oostenveld from comment #17) Attached are the startup scripts for the openBCI2ft.jar (Note you need to ensure BufferClient.jar is in the indicated place.)
Robert Oostenveld - 2015-08-26 17:26:02 +0200
(In reply to Jason Farquhar from comment #22) I think we should split code (development) from runtime executables (production). how about fieldtrip/realtime/bin/java/OpenBCI.jar fieldtrip/realtime/bin/java/startOpenBCI.sh fieldtrip/realtime/bin/java/startOpenBCI.bat and fieldtrip/realtime/bin/java/BufferServer.jar fieldtrip/realtime/bin/java/startBufferServer.sh fieldtrip/realtime/bin/java/startBufferServer.bat etc. and making that consistent for all java code? I am also fine with using ANT consistently (i.e. also for the other code) with a build.xml if that makes deployment easier. How should the other code be organised? Now most us under fieldtrip/realtime/src/java, including some utilities. And some is under fieldtrip/realtime/src/acquisition/openbci/java. Should the utilities that can be executed not all be under fieldtrip/realtime/src/utilities? Or should we split it in another way, e.g. make a fieldtrip/realtime/src/java directory (like there is an arduino directory) and move all java code there? I am not happy about it being so scattered. We could go for fieldtrip/realtime/src/java/OpenBCI fieldtrip/realtime/src/java/BufferServer fieldtrip/realtime/src/java/AudioToBuffer fieldtrip/realtime/src/java/MarkerGUI fieldtrip/realtime/src/java/MidiToBuffer fieldtrip/realtime/src/java/testclient directories, each with the respective code in it (some only a single file, some multiple), each with a build.xml and each with a jar/sh/bat triplet that is located in fieldtrip/realtime/bin/java.. Although, I realise that AudioToBuffer.java, MarkerGUI.java and MidiToBuffer.java all make use of the existing fieldtrip/realtime/src/buffer/java/nl/fcdonders/fieldtrip directory content. Ideas?
Robert Oostenveld - 2015-08-26 17:28:23 +0200
(In reply to Robert Oostenveld from comment #24) perhaps something for me to try and understand better: in which cases would one put java code (i.e. *.java files) in a structure like nl.fcdonders.fieldtrip and ion which case does one use a structure like you have in fieldtrip/realtime/src/buffer/java/bufferserver? Is there a technical reason, or is it a matter of (different) conventions?
Robert Oostenveld - 2018-11-08 14:02:09 +0100
I don't think that there is any further work to be expected here, so lets close it.