Main /
RxTxRxTx is one of the Java Serial Port Interfaces. The XBee page was getting long, so the RxTx information was moved here. See Also
Raw serial interfaceTo communicate with the XBee, we could try using the code in ptolemy.actor.lib.io.comm.SerialComm. One of the big issues is that we would need to figure out the protocol and what commands to send. This is documented as AT commands, see XBee Mac OS X: Update the Java LibraryThe SerialComm actor uses RXTX, which needs to be installed in the correct location.
With the version of RxTx that ships with the XBeeJava, a shared library must be loaded. With nrjavaserial, the shared library is included in the jar file, much like how JNA loads the foreign function interface. Below is documentation about how to install the RxTx that shipped with XBeeJava. Ptolemy II is using nrjavaserial, so this is moot. With the version of RxTx that ships with XBeeJava, one of the problems is that installing RXTX for use by $PTII/bin/vergil requires adding it to a directory referred to by the java.library.path System property. On the Mac, this is /Library/Java/Extensions. I copied versions from the XBeeJavaLibrary ealmac23:~ root# cp ~/src/workspacePt/myFirstXBeeApp/libs/native/Mac_OS_X/librxtxSerial.jnilib /Library/Java/Extensions/librxtxSerial.jnilib ealmac23:~ root# cp ~cxh/src/workspacePt/myFirstXBeeApp/libs/rxtx-2.2.jar /Library/Java/Extensions/ An alternative is to set java.library.path from the command line: export JAVAFLAGS=-Djava.library.path=${PTII}/lib $PTII/bin/vergil -v ptolemy/actor/lib/io/comm/demo/SerialConsole/SerialConsole.xml Under Eclipse, we can set something in .classpath. <classpathentry kind="lib" path="lib/rxtx-2.2.jar"> <attributes> <attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="myFirstXBeeApp/libs/native/Mac_OS_X"/> </attributes> </classpathentry> The problem here is that the value has to have the name of the project in it a runtime. If we hardwire the project name "ptII", then running a model that uses the shared library will only work if the project is named Attribute key for a classpath attribute referencing a list of shared libraries that should appear on the -Djava.library.path system property.
The factory methods newLibraryPathsAttribute(String[]) and getLibraryPaths(IClasspathAttribute) should be used to encode and decode the attribute value.
Each string is used to create an IPath using the constructor Path(String), and may contain IStringVariable's. Variable substitution is performed on the string prior to constructing a path from the string. If the resulting IPath is a relative path, it is interpreted as relative to the workspace location. If the path is absolute, it is interpreted as an absolute path in the local file system.
This points to setting the java.library.path variable inside Ptolemy II, which is covered next Setting the java.library.path property at runtimeThe idea is to get the $PTII/ptolemy/actor/gui/ConfigurationApplication invokes Now it is possible to open Mac OS X: Remove the Quarantine Flag from the RXTX jar and native libraryAs an aside, when files are downloaded, they get a quarantine tag, which shows up as a If you need to remove the quarantine tag from a file, do the following: root# cd /Library/Java/Extensions/ ealmac23:Extensions root# xattr librxtxSerial.jnilib com.apple.quarantine ealmac23:Extensions root# xattr -d com.apple.quarantine librxtxSerial.jnilib ealmac23:Extensions root# xattr librxtxSerial.jnilib ealmac23:Extensions root# xattr -d com.apple.quarantine rxtx-2.2.jar ealmac23:Extensions root# RxTx VersionsThere is some confusion about RxTx Versions.
RxTx Version MismatchWhen running Vergil using the RxTx from the XBeeJava Github installation, we get: WARNING: RXTX Version mismatch Jar version = RXTX-2.2pre1 native lib Version = RXTX-2.2 (CVS snapshot 2011.02.03, modified by CMU CREATE Lab, http://code.google.com/p/create-lab-commons/) This warning can be ignored. One interesting thing is that this version has a date of 2011, but was based on pre1 instead of pre2? RxTx Sources
|