jcontrol.comm
Class RS232
java.lang.Object
jcontrol.comm.UART
jcontrol.comm.RS232
- All Implemented Interfaces:
- ConsoleInputStream, ConsoleOutputStream, BasicInputStream, BasicOutputStream
public class RS232
- extends UART
- implements ConsoleOutputStream, ConsoleInputStream
Implements RS232 communication for JControl.
Fields inherited from class jcontrol.comm.UART |
PARAMS_ECHO, PARAMS_FLOWCONTROL_RTSCTS, PARAMS_FLOWCONTROL_XONXOFF, PARAMS_MULTIDROP_ADDRESS, PARAMS_MULTIDROP_DATA, PARAMS_PARITY_EVEN, PARAMS_PARITY_MASK, PARAMS_PARITY_ODD, PORT_RS232_0, PORT_RS232_1, PORT_RS232_2, PORT_RS232_3, PORT_RS422_0, PORT_RS422_1, PORT_RS422_2, PORT_RS422_3 |
Constructor Summary |
RS232()
Constructs a new RS232 I/O-stream using the default baudrate. |
RS232(int baudrate)
Constructs a new RS232 I/O-stream using the specified baudrate. |
Method Summary |
void |
print(String text)
Writes a String to the serial line. |
void |
println()
Writes a linefeed to the serial line. |
void |
println(String text)
Writes a String and a linefeed to the serial line. |
String |
readLine()
Reads a single String from the serial line. |
Methods inherited from class jcontrol.comm.UART |
available, close, errorCode, flush, getBaudrate, getParams, mark, markSupported, read, read, read, reset, setBaudrate, setCharacterGuardTime, setParams, skip, write, write, write |
RS232
public RS232()
throws IOException
- Constructs a new RS232 I/O-stream using the default baudrate. On the same hardware there are
no multiple instances allowed. The default baudrate is specified in the system property "
rs232.baudrate
".
- Throws:
IOException
- if port is in use
RS232
public RS232(int baudrate)
throws IOException
- Constructs a new RS232 I/O-stream using the specified baudrate.
- Parameters:
baudrate
- the bautrate to use, possible values are: 2400, 9600, 19200 (default), 31250,
63 (62500), 125 (125000), 250 (250000). This is controller dependent.
- Throws:
IOException
- if port is in use- See Also:
UART.setBaudrate(int)
readLine
public String readLine()
throws IOException
- Reads a single
String
from the serial line.
The String is received character-by-character until an linefeed character defined in ConsoleInputStream
is received. There is a buffer if size BUFFERSIZE
allocated to store the received bytes, if the buffer
is full a linefeed is forced.
- Specified by:
readLine
in interface ConsoleInputStream
- Returns:
- the
String
read
- Throws:
IOException
- if an error occurs- See Also:
String
print
public void print(String text)
- Writes a
String
to the serial line. Unicode characters will not be decoded.
- Specified by:
print
in interface ConsoleOutputStream
- Parameters:
text
- String
to write, its temporary stored in heap- See Also:
String
println
public void println(String text)
- Writes a
String
and a linefeed to the serial line. Unicode characters will not be decoded.
- Specified by:
println
in interface ConsoleOutputStream
- Parameters:
text
- String
to write, its temporary stored in heap- See Also:
String
println
public void println()
- Writes a linefeed to the serial line.
- Specified by:
println
in interface ConsoleOutputStream