/** * * This bean
provides some basic functions to implement full dulplex * information
exchange through the srial port. * */
public class
SerialBean { static String PortName; CommPortIdentifier
portId; SerialPort serialPort; static OutputStream out; static
InputStream in;
SerialBuffer SB; ReadSerial
RT;
/** * * Constructor * * @param PortID the ID
of the serial to be used. 1 for COM1, * 2 for COM2,
etc. * */
public SerialBean(int
PortID) { PortName = "COM" +
PortID; }
/** * * This function initialize the serial
port for communication. It starts a * thread which consistently
monitors the serial port. Any signal captured * from the serial port
is stored into a buffer area. * */
// when successfully open the serial port, create
a new serial buffer, // then create a thread that consistently accepts
incoming signals from // the serial port. Incoming signals are stored
in the serial buffer.
SB = new SerialBuffer(); RT = new
ReadSerial(SB, in); RT.start();
// return success
information
return InitSuccess; }
/** * *
This function returns a string with a certain length from the
incoming * messages. * * @param Length The length of the
string to be returned. * */