public class SerialChannel extends Object implements AsynchronousByteChannel
read and
write methods defined by this
class allow a timeout to be specified when initiating a read or write operation. If the timeout
elapses before an operation completes then the operation completes with the exception
InterruptedByTimeoutException. A timeout may leave the channel, or the underlying
connection, in an inconsistent state. Where the implementation cannot guarantee that bytes have
not been read from the channel then it puts the channel into an implementation specific
error state. A subsequent attempt to initiate a {| Modifier and Type | Method and Description |
|---|---|
void |
close() |
void |
configure(SerialPort.BaudRate baudRate,
SerialPort.DataBits dataBits,
SerialPort.Parity parity,
SerialPort.StopBits stopBits,
SerialPort.FlowControl flowControl)
Configures the serial port channel.
|
SerialPort.BaudRate |
getBaudRate()
Returns the baud rate being used.
|
SerialPort.DataBits |
getDataBits()
Returns the number of data bits being used.
|
SerialPort.FlowControl |
getFlowControl()
Returns the flow control mechanism being used.
|
SerialPort.Parity |
getParity()
Returns the parity type being used.
|
SerialPort |
getPort()
Returns the serial port associated with the channel.
|
SerialPort.StopBits |
getStopBits()
Returns the number of stop bits being used.
|
boolean |
isOpen() |
Future<Integer> |
read(ByteBuffer target) |
<A> void |
read(ByteBuffer target,
A attachment,
CompletionHandler<Integer,? super A> handler) |
String |
toString() |
Future<Integer> |
write(ByteBuffer source) |
<A> void |
write(ByteBuffer source,
A attachment,
CompletionHandler<Integer,? super A> handler) |
public SerialPort.BaudRate getBaudRate()
public SerialPort.DataBits getDataBits()
public SerialPort.StopBits getStopBits()
public SerialPort.Parity getParity()
public SerialPort.FlowControl getFlowControl()
public <A> void read(ByteBuffer target, A attachment, CompletionHandler<Integer,? super A> handler) throws IllegalArgumentException, ReadPendingException, ShutdownChannelGroupException
read in interface AsynchronousByteChannelIllegalArgumentExceptionReadPendingExceptionShutdownChannelGroupExceptionpublic Future<Integer> read(ByteBuffer target) throws IllegalArgumentException, ReadPendingException
read in interface AsynchronousByteChannelIllegalArgumentExceptionReadPendingExceptionpublic <A> void write(ByteBuffer source, A attachment, CompletionHandler<Integer,? super A> handler) throws IllegalArgumentException, WritePendingException, ShutdownChannelGroupException
write in interface AsynchronousByteChannelIllegalArgumentExceptionWritePendingExceptionShutdownChannelGroupExceptionpublic Future<Integer> write(ByteBuffer source) throws WritePendingException
write in interface AsynchronousByteChannelWritePendingExceptionpublic void configure(SerialPort.BaudRate baudRate, SerialPort.DataBits dataBits, SerialPort.Parity parity, SerialPort.StopBits stopBits, SerialPort.FlowControl flowControl) throws PeripheralConfigurationException
baudRate - the baud ratedataBits - the number of data bits per wordparity - the parity mechanism to usestopBits - the number of stop bits to useflowControl - the flow control to usePeripheralConfigurationException - if an I/O error occurs while configuring the channelpublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in interface AsynchronousChannelclose in interface ChannelIOExceptionpublic SerialPort getPort()
Copyright © 2011. All Rights Reserved.