Java Example

Here is a complete Java application that uses the alphasign.xsl file from the BBXML package. It reads your XML command file, transforms it to Alpha Sign protocol, and writes that output to the serial port.

Requirements

Setup

You will need to install RXTX 2.1 for serial port communication. Just copy the .jar and native library files (.dll, .so, .jnilib, etc.) to the jre/lib/ext directory of your Java home directory (C:\j2sdk1.4.2_07\jre\lib\ext, for example).

Windows
copy Windows\i368-mingw32\rxtxSerial.dll %JAVA_HOME%\jre\lib\ext
copy RXTXcomm.jar %JAVA_HOME%\jre\lib\ext

Mac
sudo cp Mac_OS_X/librxtxSerial.jnilib RXTXcomm.jar /Library/Java/Extensions

Running It

java -jar bbxml.jar -port COM1 -xsl alphasign.xsl -xml hello.xml

The serial port name on Windows is "COM1", "COM2", etc. On Mac OSX, it is something like "/dev/tty.USA19QI1b22P1.1", depending on what device you use. On Linux, it looks like "/dev/ttyS0".

If all is well, it should send "hello" to your sign. You can send the clearmsg.xml file to clear the display.

java -jar bbxml.jar -port COM1 -xsl alphasign.xsl -xml clearmsg.xml

If you have an old sign like mine that does not understand the 3-byte protocol, add the -proto1 flag.

java -jar bbxml.jar -port COM1 -xsl alphasign.xsl -xml hello.xml -proto1

There is also a -read option to read data back from the sign after sending one of the "read" commands.

darin@fuji% java -jar bbxml.jar -port /dev/tty.USA19QIfd35P1.1 -xsl alphasign.xsl -proto1 -xml read.xml -read   
Experimental:  JNI_OnLoad called.
Stable Library
=========================================
Native lib Version = RXTX-2.1-7
Java lib Version   = RXTX-2.1-7
writing...
reading...
output (665 bytes):
_01000_02E 0330_030130_02E$AAU171DFF00ADU07504000_030578_02AA_030087_02IA0750000
00000000000000000000000000000000000000000000000000000000000000000000000000000_0D
00000000000000000000000000000000000000000000000000000000000000000000000000000000
_0D00000000000000000000000000000000000000000000000000000000000000000000000000000
000_0D00000000000000000000000000000000000000000000000000000000000000000000000000
000000_0D00000000000000000000000000000000000000000000000000000000000000000000000
000000000_0D00000000000000000000000000000000000000000000000000000000000000000000
000000000000_0D00000000000000000000000000000000000000000000000000000000000000000
000000000000000_0D_036AB6_02E.TUA_030162_02E2A02_03011F_02E&2_0300A2_04
	

The Code

There are two main steps for using XML with the Alpha sign.

  1. Transform the command XML file using alphasign.xsl.
  2. Write the output of the transform to the serial port.

The application code is AlphaSignXMLApp.java. See comments in that file for further explanation. The original java file is included inside bbxml.jar.


[up]
Darin Franklin