jaugment2.UI.textUI
Class SerialTextInputDevice
java.lang.Object
|
+--jaugment2.UI.textUI.SimpleTextInputDevice
|
+--jaugment2.UI.textUI.SerialTextInputDevice
- public class SerialTextInputDevice
- extends SimpleTextInputDevice
- implements javax.comm.SerialPortEventListener, javax.comm.CommPortOwnershipListener, TextOutputDevice
a text-input-device reading from a serial-port (ttyS/COM-port)
|
Field Summary |
private static boolean |
debug
|
private java.io.InputStream |
is
|
private java.io.OutputStream |
os
|
private javax.comm.CommPortIdentifier |
portId
|
(package private) boolean |
serialIsOpen
|
private javax.comm.SerialPort |
sPort
|
| Fields inherited from interface javax.comm.CommPortOwnershipListener |
PORT_OWNED,
PORT_OWNERSHIP_REQUESTED,
PORT_UNOWNED |
|
Method Summary |
void |
closeConnection()
Close the ttyS?/com-port and clean up associated elements. |
void |
openConnection()
Attempts to open a serial connection and streams using the parameters
in the SerialParameters object. |
void |
ownershipChange(int type)
Handles ownership events. |
void |
PrintTextOutput(java.lang.String out)
|
void |
serialEvent(javax.comm.SerialPortEvent e)
Some data arived on the serial-port |
void |
setConnectionParameters()
Sets the connection parameters of the ttyS?/com-port to the setting
in the parameters object. |
| Methods inherited from class java.lang.Object |
,
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
registerNatives,
toString,
wait,
wait,
wait |
debug
private static final boolean debug
portId
private javax.comm.CommPortIdentifier portId
sPort
private javax.comm.SerialPort sPort
os
private java.io.OutputStream os
is
private java.io.InputStream is
serialIsOpen
boolean serialIsOpen
SerialTextInputDevice
public SerialTextInputDevice()
PrintTextOutput
public void PrintTextOutput(java.lang.String out)
throws java.rmi.RemoteException
- Specified by:
- PrintTextOutput in interface TextOutputDevice
serialEvent
public void serialEvent(javax.comm.SerialPortEvent e)
- Some data arived on the serial-port
- Specified by:
- serialEvent in interface javax.comm.SerialPortEventListener
ownershipChange
public void ownershipChange(int type)
- Handles ownership events. If a PORT_OWNERSHIP_REQUESTED event is
received a dialog box is created asking the user if they are
willing to give up the port. No action is taken on other types
of ownership events.
- Specified by:
- ownershipChange in interface javax.comm.CommPortOwnershipListener
openConnection
public void openConnection()
- Attempts to open a serial connection and streams using the parameters
in the SerialParameters object. If it is unsuccesfull at any step it
returns the port to a closed state, throws a
SerialConnectionException, and returns.
Gives a timeout of 3
0 seconds on the portOpen to allow other applications
to reliquish the port if have it open and no longer need it.
setConnectionParameters
public void setConnectionParameters()
- Sets the connection parameters of the ttyS?/com-port to the setting
in the parameters object. If set fails return the parameters object
to origional settings and throw exception.
closeConnection
public void closeConnection()
- Close the ttyS?/com-port and clean up associated elements.