| 
  • If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • Stop wasting time looking for files and revisions. Connect your Gmail, DriveDropbox, and Slack accounts and in less than 2 minutes, Dokkio will automatically organize all your file attachments. Learn more and claim your free account.

View
 

RxTxOSX

Page history last edited by PBworks 13 years, 4 months ago

Exemplar, d.tools and all related java projects use the javax.comm package for serial communication. Sun does not offer an implementation of this package for OS X. RXTX does. Here's an account of trying to substitute RXTX for a Mac port of Exemplar:

 

First, get Exemplar to run on a Max (download Eclipse 3.2.2, J2SE5.0, get eclispe-plugin from CVS on context)


Unsuccessful attempt with rxtx 2.0 on Mac

 

Download rxtx-2.0-7pre1. Link is on page http://users.frii.com/jarvi/rxtx/download.html.

 

Download 2.0 instead of 2.1 because we want to continue to use package javax8.comm instead of gnu.io, so we don't have to rewrite the code for windows.

 

Install RXTX binaries from MACOSX_IDE/ForPackageMaker/RXTX_Jag.pkg with following manual steps:

  • i didn't have /var/spool/uucp . instructions say to create it with the following set of commands (this still holds for rxtx 2.1 below, i think):
    • sudo mkdir /var/spool/uucp
    • sudo chmod 775 /var/spool/uucp
    • sudo niutil -destroyval / /groups/uucp users `whoami`
    • sudo niutil -appendprop / /groups/uucp users `whoami`
    • you should install Solaris version of comm.jar file from sun's web site (solaris version http://java.sun.com/products/javacomm/index.html) into /System/Library/Frameworks/JavaVM.framework/Home/lib/ext folder
  • in exemplar, removed external-jars/comm.jar from buildpath and edited MANIFEST.MF to remove package exports for com.sun.com and javax.comm
  • download serial driver for Mac - in this case, CP210x. file is http://www.chip45.com/download/CP210x_MacOSX_v1.00e.zip from page http://www.chip45.com/index.pl?page=Crumb128_Downloads〈=en (requires restart!)
  • to test whether the driver works, connect a d.tools board and run the test listed on http://www.tigoe.net/pcomp/resources/archives/avr/000749.shtml (screen /dev/tty.SLAB_USBtoUART)
  • next, try to pass that port to Exemplar instead of "COMxx" on windows - does not work
  • tried to debug - wrote small test program "ListCommPorts" - found that java doesn't know about rxtx:
    • javax.comm: Can't find javax.comm.properties!

java.io.IOException: javax.comm: platform driver class name = null

(Check 'driver' property in javax.comm.properties)

Gave up on this line and deleted comm.jar / javax.comm.properties / other stuff.


using rxtx 2.1 (package gnu.io) on Mac

 

Downloaded txt-2.1-7-bins-r2 and followed manual instructions from there (copy two different files).

 

Restart.

 

In ListCommPorts, replaced javax.comm with gnu.io - ran it, and it found the ports successfully.

 

Next we need to install RxTx on my PC and gerenate a new OSCSerialPort class to use namespace gnu.io instead of javax.comm


using rxtx on PC

On the PC, installed JDK1.6.0_01 (interesting: comes witha scripting engine)

 

Then downloaded rxtx-2.1-7-bins-r2.zip

RXTXcomm.jar goes in jrelibext (under java)

rxtxSerial.dll goes in jrebin

 

I copied RXTXcomm.jar to:

C:Program FilesJavajdk1.6.0_01jrelibext

C:Program FilesJavajre1.6.0_01libext

and similarly made two copies of rxtxSerial.dll

 

Then tried to run ListCommPorts under Windows with RxTx instead of javax.comm.

I had to update JRE list in Eclipse preferences first to just 1.6.0_01, where rxtx is installed. After that, test executed successfully.

 

Then did a global search for javax.comm - there are only two matches, one in OSCSerialPort.java and one in SerialIO, both within dtools-eclipse-plugin. Swapping both out for gnu.io, and finding out how to package rxtx with dll in our distributions should do the trick.

Tried to do this and expot java-osc-rxtx.jar back to the Mac, but getting BundleLoaderExceptions so far from the line "serialPort = new OSCSerialPort(...) .

 

Need to debug this on a smaller test case than the entire plug-in, i.e., Dtools2Flash...

Replacing java-osc with java-osc-rxtx.jar in Dtools2Flash on the PC was no problem. (properties->remove comm.jar, remove java-osc.jar, add java-osc-rxtx.jar)

 

Aha, error was somewhere else - replaced Exemplar with latest from Branch. This fixed the problem of the UI not starting up at all. However, Exemplar still cannot find port /dev/cu.SLAB_USBtoUART, even though ListCommPorts shows it.

 

Next, I tried to expand on ListCommPorts to open a port on the Mac (on the PC, this works just fine). Discovered that the implementation of the RXTX class is now in gnu.io.RXTXPort(), and that gnu.io.SerialPort() is just an interface (or abstract base, i don't remember).

 

Next error: "gnuio.PortInUseException" - this is an OSX specific error from lock files, with a potential workaround listed at http://mailman.qbang.org/pipermail/rxtx/Week-of-Mon-20060306/006521.html

http://rxtx.qbang.org/wiki/index.php/Installation#Mac_OS_X_users

http://lists.apple.com/archives/Java-dev/2006/Mar/msg00138.html

 

sudo chmod 777 /var/lock and

sudo chmod 777 /var/spool/uucp did the trick.

 

Problem with Exemplar is NOT about rxtx library at this point - it's about MANIFEST.MF (Bundle-ClassPath) and build.properties (bin.includes) - in Build Configuration->Binary Build, jars/java-osc-rxtx was unchecked; in Package explorer, it's not listed in jars for some reason)

 

This problem may be related to how Eclipse finds jars (it may not look in jre/lib/ext):

http://dev.eclipse.org/newslists/news.eclipse.platform/msg35611.html


Finishing up Exemplar w/ RxTx on a PC, then moving it back to a Mac

Restart on Tuesday.

First, I will concentrate efforts on getting exemplar to run with rxtx correctly on a PC, where I have better debugging skills.

I added RXTX jar and dll to the eclipse project and then explicitly referenced them in project build and plug-in build settings:

  • In project properties build path, replaced comm.jar and java-osc.jar with rxtxcomm.jar and java-osc-rxtx.jar
  • In manifest, exported packages - removed sun.java.comm and javax.comm, added gnu.io
  • In manifest, classpath - replaced comm.jar and java-osc.jar with rxtxcomm.jar and java-osc-rxtx.jar

 

This works under Windows (Exemplar starts up, I see data from an attached d.tools board), although there is a ~100ms delay. I'll check this code in along with a mac rxtx binary and try to check it run it on the mac.

Finally! first screenshot of Exemplar running on Mac OSX with input from a d.tools board:

 

 

Next tasks:

  • Fix the UI ugliness in OSX
  • Compare changes between CHI branch and CS247 branch of code

 

UPSHOT

  • Use RxTx 2.1; install by copying (two) files manually into the right directories on each platform; Mac OSX needs special massaging of directory permissions for lock files
  • Also copy the RxTx files into the plugin and plugin/jars directory of exemplar
  • Replace all references to package javax.comm with gnu.io in the source code
  • Replace references to comm.jar and java-osc.jar with RxTxcomm.jar and java-osx-rxtx in Eclipse's project build path and plug-in build configuration.

 


Here's an old Exemplar problem that now reared its head again using RxTx:

When creating the serial port in Activator.start(), there is a threading issue. the following two errors are generated in pairs:

 

While loading class "edu.stanford.hci.exemplar.Converter", thread "Thread-2" timed out waiting (5000ms) for thread "main" to finish starting bundle "edu.stanford.hci.exemplar". To avoid deadlock, thread "Thread-2" is proceeding but "edu.stanford.hci.exemplar.Converter" may not be fully initialized.


java.lang.Exception: Generated exception.
at org.eclipse.core.runtime.internal.adaptor.EclipseLazyStarter.preFindLocalClass(EclipseLazyStarter.java:75)
at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClass(ClasspathManager.java:409)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.findLocalClass(DefaultClassLoader.java:188)
at org.eclipse.osgi.framework.internal.core.BundleLoader.findLocalClass(BundleLoader.java:339)
at org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(BundleLoader.java:391)
at org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(BundleLoader.java:352)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:83)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at edu.stanford.hci.exemplar.UpdateDataTask.acceptMessage(UpdateDataTask.java:46)
at com.illposed.osc.utility.OSCPacketDispatcher.dispatchMessage(OSCPacketDispatcher.java:121)
at com.illposed.osc.utility.OSCPacketDispatcher.dispatchMessage(OSCPacketDispatcher.java:107)
at com.illposed.osc.utility.OSCPacketDispatcher.dispatchPacket(OSCPacketDispatcher.java:88)
at edu.stanford.hci.dtools.serial.WiTiltSerialPort.buildOSCByteBuffer(WiTiltSerialPort.java:118)
at edu.stanford.hci.dtools.serial.WiTiltSerialPort.serialEvent(WiTiltSerialPort.java:55)
at gnu.io.RXTXPort.sendEvent(RXTXPort.java:732)
at gnu.io.RXTXPort.eventLoop(Native Method)
at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1575)

and

While loading class "gnu.io.SerialPortEvent", thread "Thread-2" timed out waiting (5000ms) for thread "main" to finish starting bundle "edu.stanford.hci.exemplar". To avoid deadlock, thread "Thread-2" is proceeding but "gnu.io.SerialPortEvent" may not be fully initialized.

java.lang.Exception: Generated exception.
at org.eclipse.core.runtime.internal.adaptor.EclipseLazyStarter.preFindLocalClass(EclipseLazyStarter.java:75)
at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClass(ClasspathManager.java:409)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.findLocalClass(DefaultClassLoader.java:188)
at org.eclipse.osgi.framework.internal.core.BundleLoader.findLocalClass(BundleLoader.java:339)
at org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(BundleLoader.java:391)
at org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(BundleLoader.java:352)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:83)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at gnu.io.RXTXPort.sendEvent(RXTXPort.java:720)
at gnu.io.RXTXPort.eventLoop(Native Method)
at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1575)

Comments (0)

You don't have permission to comment on this page.