|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object jcontrol.comm.UART
public class UART
Access to UART-Ports of Device
Field Summary | |
---|---|
static int |
PARAMS_ECHO
Enables echo for received characters. |
static int |
PARAMS_FLOWCONTROL_RTSCTS
Enables hardware handshaking using RTS and CTS lines. |
static int |
PARAMS_FLOWCONTROL_XONXOFF
Enables software handshaking using XON and XOFF symbols. |
static int |
PARAMS_MULTIDROP_ADDRESS
Enables address multidrop mode. |
static int |
PARAMS_MULTIDROP_DATA
Enables data multidrop mode. |
static int |
PARAMS_PARITY_EVEN
Enables even parity "8E1" (default: no parity "8N1"). |
static int |
PARAMS_PARITY_MASK
There can only exists one of the 4 parity-types PARAMS_PARITY_EVEN, PARAMS_PARITY_ODD, PARAMS_MULTIDROP_ADDRESS and PARAMS_MULTIDROP_DATA. |
static int |
PARAMS_PARITY_ODD
Enables odd parity "8O1" (default: no parity "8N1"). |
static int |
PORT_RS232_0
port declaration: rs232_0 existing on all JControl-Devices |
static int |
PORT_RS232_1
port declaration: rs232_1 existing on JControl/BFT-Device |
static int |
PORT_RS232_2
port declaration: rs232_2 for future purposes |
static int |
PORT_RS232_3
port declaration: rs232_3 for future purposes |
static int |
PORT_RS422_0
port declaration: rs422_0 existing on JControl/BFT-Device |
static int |
PORT_RS422_1
port declaration: rs422_1 for future purposes |
static int |
PORT_RS422_2
port declaration: rs422_2 for future purposes |
static int |
PORT_RS422_3
port declaration: rs422_3 for future purposes |
Constructor Summary | |
---|---|
UART(int port)
Constructor |
Method Summary | |
---|---|
int |
available()
Returns the number of available characters in the input buffer. |
void |
close()
Closes the stream, further writes and reads are not possible, the RS232 hardware will be turned off. |
int |
errorCode()
Returns the current Error-Code. |
void |
flush()
flush unsent bytes (if exists) |
int |
getBaudrate()
Gets the current Baudrate of Device |
int |
getParams()
Gets some serail port feature parameters. |
void |
mark(int readlimit)
NOTE: not supported! |
boolean |
markSupported()
NOTE: not supported! |
int |
read()
Reads the next available character from the input buffer. |
int |
read(byte[] b)
Reads some number of bytes from the input stream and stores them into the buffer array b . |
int |
read(byte[] buffer,
int startindex,
int length)
Reads a byte array from the input buffer. |
void |
reset()
NOTE: not supported! |
void |
setBaudrate(int baudrate)
Sets the serial port baudrate. |
void |
setCharacterGuardTime(int bits)
Sets the character guard time, i.e. the time to wait between sending two characters over the serial port. |
void |
setParams(int params)
Sets some serial port feature parameters. |
int |
skip(int n)
skips n bytes of reading characters |
void |
write(byte[] b)
Writes b.length bytes from the specified byte array
to this output stream. |
void |
write(byte[] buffer,
int startindex,
int length)
Writes a block of bytes to the serial port -- as it is. |
void |
write(int b)
Writes one byte to the serial port. |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, notifyAll, toString, wait |
Field Detail |
---|
public static final int PARAMS_PARITY_MASK
public static final int PARAMS_PARITY_EVEN
PARITY_ODD,PARAMS_MULTIDROP_ADDRESS,PARAMS_MULTIDROP_DATA
.
setParams(int)
,
#PARITY_ODD
,
PARAMS_MULTIDROP_ADDRESS
,
PARAMS_MULTIDROP_DATA
,
Constant Field Valuespublic static final int PARAMS_PARITY_ODD
PARITY_EVEN,PARAMS_MULTIDROP_ADDRESS,PARAMS_MULTIDROP_DATA
.
setParams(int)
,
#PARITY_EVEN
,
PARAMS_MULTIDROP_ADDRESS
,
PARAMS_MULTIDROP_DATA
,
Constant Field Valuespublic static final int PARAMS_MULTIDROP_ADDRESS
PARAMS_PARITY_EVEN,PARAMS_PARITY_ODD,PARAMS_MULTIDROP_DATA
.
In multidrop mode during receiving the character type (data/address) is ignored and can't identified.
setParams(int)
,
#PARITY_EVEN
,
#PARITY_ODD
,
PARAMS_MULTIDROP_DATA
,
Constant Field Valuespublic static final int PARAMS_MULTIDROP_DATA
PARAMS_PARITY_EVEN,PARAMS_PARITY_ODD,PARAMS_MULTIDROP_ADDRESS
.
In multidrop mode during receiving the character type (data/address) is ignored and can't identified.
setParams(int)
,
#PARITY_EVEN
,
#PARITY_ODD
,
PARAMS_MULTIDROP_ADDRESS
,
Constant Field Valuespublic static final int PARAMS_ECHO
setParams(int)
,
Constant Field Valuespublic static final int PARAMS_FLOWCONTROL_XONXOFF
XON
and XOFF
symbols.
Use only for ASCII based communication. Do not use in conjunction with FLOWCONTROL_RTSCTS
.
setParams(int)
,
Constant Field Valuespublic static final int PARAMS_FLOWCONTROL_RTSCTS
RTS
and CTS
lines.
May be ignored on some devices. Do not use in conjunction with FLOWCONTROL_XONXOFF
.
setParams(int)
,
Constant Field Valuespublic static final int PORT_RS232_0
public static final int PORT_RS232_1
public static final int PORT_RS232_2
public static final int PORT_RS232_3
public static final int PORT_RS422_0
public static final int PORT_RS422_1
public static final int PORT_RS422_2
public static final int PORT_RS422_3
Constructor Detail |
---|
public UART(int port) throws IOException
IOException
Method Detail |
---|
public int available() throws IOException
available
in interface BasicInputStream
IOException
- if an error occurspublic int read() throws IOException
read
in interface BasicInputStream
IOException
- if an error occursavailable()
public int read(byte[] buffer, int startindex, int length) throws IOException
read
in interface BasicInputStream
buffer
- the byte array to fillindex
- the index to start filling the arraylength
- number of bytes to read; the array is filled from index
to
index
+length
-1
IOException
- if an error occursInputStream.read()
public int read(byte[] b) throws IOException
BasicInputStream
b
. The number of bytes actually read is
returned as an integer. This method blocks until input data is
available, end of file is detected, or an exception is thrown.
If b
is null
, a
NullPointerException
is thrown. If the length of
b
is zero, then no bytes are read and 0
is
returned; otherwise, there is an attempt to read at least one byte. If
no byte is available because the stream is at end of file, the value
-1
is returned; otherwise, at least one byte is read and
stored into b
.
The first byte read is stored into element b[0]
, the
next one into b[1]
, and so on. The number of bytes read is,
at most, equal to the length of b
. Let k be the
number of bytes actually read; these bytes will be stored in elements
b[0]
through b[
k-1]
,
leaving elements b[
k]
through
b[b.length-1]
unaffected.
If the first byte cannot be read for any reason other than end of
file, then an IOException
is thrown. In particular, an
IOException
is thrown if the input stream has been closed.
The read(b)
method for class InputStream
has the same effect as:
read(b, 0, b.length)
read
in interface BasicInputStream
b
- the buffer into which the data is read.
-1
is there is no more data because the end of
the stream has been reached.
IOException
- if an I/O error occurs.read(byte[] buffer, int startindex, int length)
public void write(int b) throws IOException
write
in interface BasicOutputStream
data
- the byte to send (coded in a short allowing a range 0 ... 255)
IOException
- if an I/O error occurs. In particular,
an IOException
may be thrown if the
output stream has been closed.write(byte[],int,int)
public void write(byte[] buffer, int startindex, int length) throws IOException
write
in interface BasicOutputStream
buffer
- the byte array to sendindex
- the index to start reading the arraylength
- number of bytes to write; the array is read from index
to
index
+length
-1
IOException
- if an I/O error occurs. In particular,
an IOException
is thrown if the output
stream is closed.public void write(byte[] b) throws IOException
BasicOutputStream
b.length
bytes from the specified byte array
to this output stream. The general contract for write(b)
is that it should have exactly the same effect as the call
write(b, 0, b.length)
.
write
in interface BasicOutputStream
b
- the data.
IOException
- if an I/O error occurs.write(byte[] buffer, int startindex, int length)
public void close()
close
in interface BasicInputStream
close
in interface BasicOutputStream
public void setBaudrate(int baudrate)
baudrate
- the baudrate to use, possible values are:
Baudrate | Parameter |
600 | 600 |
1200 | 1200 |
2400 | 2400 |
4800 | 4800 |
9600 | 9600 |
19.200 | 19200 |
31.250 | 31250 |
38.400 | 38 |
62.500 | 62 |
125.000 | 125 |
250.000 | 250 |
Baudrate | Parameter |
300 | 300 |
600 | 600 |
1200 | 1200 |
2400 | 2400 |
4800 | 4800 |
9600 | 9600 |
19.200 | 19200 |
31.250 | 31250 |
62.500 | 62500 |
125.000 | 125000 |
250.000 | 250000 |
rs232.baudrate
".public int getBaudrate()
public void setParams(int params)
rs232.params
".
params
- bitmask with parameters#PARITY_EVEN
,
#PARITY_ODD
,
#ECHO
,
#FLOWCONTROL_XONXOFF
,
#FLOWCONTROL_RTSCTS
public int getParams()
public int errorCode()
IOException
) the cause may be found here.
The Error-Code is cleared after readout (if not, the error remains active and every RS232 access will throw
another IOException
). If an overrun error is indicated the FIFO should be cleared using read(...)
.
readLine()
is waiting for a linefeed characterpublic void setCharacterGuardTime(int bits)
bits
- minimum bits to wait between two characterspublic int skip(int n) throws IOException
skip
in interface BasicInputStream
n
- the number of bytes to skip
IOException
- if an I/O error occurs.public void flush() throws IOException
flush
in interface BasicOutputStream
IOException
- if an I/O error occurs.public void mark(int readlimit)
mark
in interface BasicInputStream
readlimit
- the maximum limit of bytes that can be read before
the mark position becomes invalid.public boolean markSupported()
markSupported
in interface BasicInputStream
true
if this stream instance supports the mark
and reset methods; false
otherwise.public void reset() throws IOException
reset
in interface BasicInputStream
IOException
- if this stream has not been makred or if the
mark has been invalidated.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |