JSimm
High Speed I/O Products
JSimm Quad Serial (JSQS)
Serial Echo App Note

Real Java
for the
real world
[Purchase JSQS]

JSimm is an open expansion system for
Systronix embedded Java and SimmStick systems


This application note will explain how to write simple, event driven rs-232 serial applications using JSimm Quad Serial. The example program will allow users to communicate with up to 14 Uarts and will count the number of bytes echoed.

Files
RevisionDownloadDateRemarks
1.0 50 KBytes

2003 Aug 20

2008 Feb 19

The first production (beta) version. This .zip file includes the required JSimmQuadSerial.jar api. If you do not have com3A through 5D available in Jembuilder, extract the JStikFlashConfiguration and JStikRamConfiguration files from JSimmQuadSerial.jar to your Ajile configurations directory.

If you are using the new aJile 4.4.02 or later release, you will not need to use these configurations - they are already included in the current aJile runtime support for JStik. Just compile and run the code.


Installing and running the demo program

These instructions assume that you have installed the Ajile runtime and ant to help you build your class files and download programs to JStik. If this is not the case, see Practical Embedded Java for more information.

First, extract the attached zip file to a directory on your computer. This directory will be called %Project% in this document. Open a command prompt in the %Project% directory and type "ant" to compile the example program and put the resulting class files in the "classes" directory.

Next, open the JSQSEcho.ajp file with Jembuilder. Change the Project->Output Files->output directory setting to a convienient directory like "%Project%\flashbuild". Change the classpath to "%Project%\classes;%Project%\JSimmQuadSerial.jar". Go to Project->Drivers in the Jembuilder menu bar. You will see all possible AJ-100 and JSQS serial ports displayed in the list. Be sure to remove the drivers that there is no hardware for. Each JSimm Quad Serial board comes configured in the com3 configuration. If you have multiple boards, see the javadocs on how to set the dip switches and jumpers on the additional boards. Now press the build button in jembuilder to build the project.

Make sure your JStik and JSimm Quad Serial board are connected and configured. JP3 should not be installed on your JStik. The HSIO ribbon cable should be plugged into both your JStik and JSQS board and both boards should be plugged into a 6 slot backplane. The backplane should be powered by a 12V power cube.

Finally, start Charade. Change the directory to the output directory from jembuilder with the cd command. The easiest way to do this is to cut and paste the Jembuilder ouput directory into Charade after typing in "cd ". After entering "cd %Output Directory%" into charade, press enter. Make sure "AJ-100" is selected under the device menu in the menu bar and press the load button. Once the program has loaded, press the "run" button to begin execution.

You should now see a list of the com ports you have enabled displayed to the charade debugging window after a version message. If all you see is the version message, there is probably an error in the JSQS hardware configuration. Check the jembuilder drivers and the JSQS javadocs to make sure your board is properly configured. A good debugging procedure is to remove all the drivers except for com1 and com2, the internal JStik uarts and try again. If these two uarts work, you can begin enabling the com ports on JSQS to see which port is not responding.

After you see the list of ports, connect a DCE dongle to any port and plug that port into a PC serial port. Start a terminal program with com parameters 115200 baud, no parity, one stop bit and type some text into the terminal. You should see that text echoed back to the terminal and the number of bytes transmitted by JStik increase in the charade debugging window. Try unplugging the dongle from one terminal and plugging it into each serial port you would like to test to verify their function.


Demo Program Code

The serial echo program uses javax.comm.CommPortIdentifier.getPortIdentifiers() to dynamically get all the serial ports installed on any system with javax.comm installed and will run on JStik, JStamp, TINI, TStik, personal computers and any other system with javax.comm capable of operating at 115200 baud, no flow control, no parity, one stop bit. It works by registering a SerialPortEventListener that dynamically finds the appropriate SerialPort from the SerialPortEvent passed into the event listener by javax.comm as a parameter. There is a performance penalty to this level of dynamic behavior and often users will want to store InputStreams and OutputStreams, as well as SerialPorts in variables to make event listeners smaller for better performance.

In conclusion, the serial echo program in this app note gives examples of how to initialize serial ports, read input and write output. It is meant to demonstrate that with three JSimm Quad Serial boards and a JStik, it is possible to have up to 14 RS-232 Uarts communicating with external devices.

 
Systronix® 939 Edison Street, Salt Lake City, Utah, USA 84111
Tel +1-801-534-1017, Fax +1-801-534-1019
 

Java and all Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries.
Systronix is independent of Sun Microsystems, Inc.
TStik, JStik, JCX, JStamp, JSimm, JDroid, and JRealTime are trademarks of Systronix, Inc.
1-Wire, iButton and TINI are trademarks of Dallas Semiconductor
Simmstick is a trademark of Dontronics
LEGO® is a trademark of Lego A/S, Denmark