- All Superinterfaces:
org.refcodes.io.Availability
,org.refcodes.io.ByteDestination
,org.refcodes.io.ByteReceiver
,org.refcodes.io.BytesDestination
,org.refcodes.io.BytesReceiver
,org.refcodes.component.Closable
,org.refcodes.component.Closable.CloseAutomaton
,org.refcodes.component.ClosedAccessor
,org.refcodes.component.ConnectableComponent
,org.refcodes.component.ConnectableComponent.ConnectableAutomaton
,org.refcodes.component.ConnectionStatusAccessor
,org.refcodes.mixin.InputStreamAccessor
,org.refcodes.component.LinkComponent
,org.refcodes.component.LinkComponent.LinkAutomaton
,org.refcodes.component.Openable
,org.refcodes.component.Openable.OpenAutomaton
,org.refcodes.component.OpenedAccessor
,org.refcodes.io.Receivable
,SegmentDestination
,SegmentReceiver
,org.refcodes.io.Skippable
,org.refcodes.io.TimeoutInputStreamAccessor
- All Known Subinterfaces:
Port<PM>
,SerialTransceiver
- All Known Implementing Classes:
AbstractPort
,AbstractPortDecorator
,CrossoverLoopbackPort
,LoopbackPort
public interface SerialReceiver
extends org.refcodes.io.BytesReceiver, SegmentReceiver, org.refcodes.component.LinkComponent.LinkAutomaton, org.refcodes.io.Skippable
A
SerialReceiver
is used to read data from a serial port or the like.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.refcodes.io.BytesReceiver
org.refcodes.io.BytesReceiver.ReceiverInputStream
Nested classes/interfaces inherited from interface org.refcodes.component.Closable
org.refcodes.component.Closable.CloseAutomaton, org.refcodes.component.Closable.CloseBuilder<B extends org.refcodes.component.Closable.CloseBuilder<B>>
Nested classes/interfaces inherited from interface org.refcodes.component.ClosedAccessor
org.refcodes.component.ClosedAccessor.ClosedMutator, org.refcodes.component.ClosedAccessor.ClosedProperty
Nested classes/interfaces inherited from interface org.refcodes.component.ConnectableComponent
org.refcodes.component.ConnectableComponent.ConnectableAutomaton
Nested classes/interfaces inherited from interface org.refcodes.component.ConnectionStatusAccessor
org.refcodes.component.ConnectionStatusAccessor.ConnectionStatusMutator, org.refcodes.component.ConnectionStatusAccessor.ConnectionStatusProperty
Nested classes/interfaces inherited from interface org.refcodes.mixin.InputStreamAccessor
org.refcodes.mixin.InputStreamAccessor.InputStreamBuilder<B extends org.refcodes.mixin.InputStreamAccessor.InputStreamBuilder<?>>, org.refcodes.mixin.InputStreamAccessor.InputStreamMutator, org.refcodes.mixin.InputStreamAccessor.InputStreamProperty
Nested classes/interfaces inherited from interface org.refcodes.component.LinkComponent
org.refcodes.component.LinkComponent.LinkAutomaton, org.refcodes.component.LinkComponent.LinkComponentBuilder<B extends org.refcodes.component.LinkComponent.LinkComponentBuilder<B>>
Nested classes/interfaces inherited from interface org.refcodes.component.Openable
org.refcodes.component.Openable.OpenAutomaton, org.refcodes.component.Openable.OpenBuilder<B extends org.refcodes.component.Openable.OpenBuilder<B>>
Nested classes/interfaces inherited from interface org.refcodes.component.OpenedAccessor
org.refcodes.component.OpenedAccessor.OpenedMutator, org.refcodes.component.OpenedAccessor.OpenedProperty
Nested classes/interfaces inherited from interface org.refcodes.io.TimeoutInputStreamAccessor
org.refcodes.io.TimeoutInputStreamAccessor.TimeoutInputStreamBuilder<B extends org.refcodes.io.TimeoutInputStreamAccessor.TimeoutInputStreamBuilder<?>>, org.refcodes.io.TimeoutInputStreamAccessor.TimeoutInputStreamMutator, org.refcodes.io.TimeoutInputStreamAccessor.TimeoutInputStreamProperty
-
Method Summary
Modifier and TypeMethodDescriptionint
Returns the number of bytes which can be read directly e.g. which are already been stored in an internal buffer.void
close()
Attention: Implementations of this method should do aObject.notifyAll()
in order to terminate any pending asynchronous operations such asSegmentReceiver.onReceiveSegment(Segment)
orSegmentReceiver.onReceiveSegment(Segment, SegmentConsumer)
.void
open()
Attention: Implementations of this method should do aObject.notifyAll()
in order to terminate any pending asynchronous operations such asSegmentReceiver.onReceiveSegment(Segment)
orSegmentReceiver.onReceiveSegment(Segment, SegmentConsumer)
.default byte
default byte[]
receiveBytes
(int aLength) default <SEGMENT extends Segment>
voidreceiveSegment
(SEGMENT aSegment) Receives aSegment
(and blocks this thread) till all it'sSequence
data has been received and updates theSegment
by invokingSegment.fromTransmission(Sequence)
.default <SEGMENT extends Segment>
voidreceiveSegmentWithin
(long aTimeoutMillis, SEGMENT aSegment) Receives aSegment
(and blocks this thread) till all it'sSequence
data has been received and updates theSegment
by invokingSegment.fromTransmission(Sequence)
.default Sequence
receiveSequence
(int aLength) Receives aSequence
with the number of bytes specified.This method blocks till all bytes are read.default Sequence
receiveSequenceWithin
(long aTimeoutMillis, int aLength) Receives aSequence
with the number of bytes specified.Methods inherited from interface org.refcodes.io.Availability
hasAvailable
Methods inherited from interface org.refcodes.io.BytesDestination
receiveBytes
Methods inherited from interface org.refcodes.io.BytesReceiver
getInputStream, getInputStream, receiveAllBytes, receiveBytesWithin, receiveBytesWithin, receiveByteWithin, skip
Methods inherited from interface org.refcodes.component.Closable
closeIn, closeQuietly, closeUnchecked
Methods inherited from interface org.refcodes.component.Closable.CloseAutomaton
isClosable
Methods inherited from interface org.refcodes.component.ClosedAccessor
isClosed
Methods inherited from interface org.refcodes.component.ConnectionStatusAccessor
getConnectionStatus, isOpened
Methods inherited from interface org.refcodes.component.Openable
openUnchecked
Methods inherited from interface org.refcodes.component.Openable.OpenAutomaton
isOpenable
Methods inherited from interface org.refcodes.serial.SegmentReceiver
onReceiveSegment, onReceiveSegment
Methods inherited from interface org.refcodes.io.Skippable
skipAvailable, skipAvailableExcept, skipAvailableTill, skipAvailableTillSilenceFor, skipAvailableTillSilenceFor, skipAvailableWithin, skipAvailableWithin, skipAvailableWithin
-
Method Details
-
available
Returns the number of bytes which can be read directly e.g. which are already been stored in an internal buffer. May return (0 or) a value less than 0 (-1) when it is not supported. Similar toInputStream.available()
: "Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking by the next invocation of a method for this input stream. The next invocation might be the same thread or another thread. A single read or skip of this many bytes will not block, but may read or skip fewer bytes. Note that while some implementations of InputStream will return the total number of bytes in the stream, many will not. It is never correct to use the return value of this method to allocate a buffer intended to hold all data in this stream. A subclass' implementation of this method may choose to throw an IOException if this input stream has been closed by invoking the close() method. The available method for class InputStream always returns 0. This method should be overridden by subclasses."- Specified by:
available
in interfaceorg.refcodes.io.Availability
- Specified by:
available
in interfaceorg.refcodes.io.Skippable
- Returns:
- The number of available bytes: An estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking or 0 when it reaches the end of the input stream. Throws:
- Throws:
IOException
- - if an I/O error occurs.
-
receiveByte
- Specified by:
receiveByte
in interfaceorg.refcodes.io.ByteDestination
- Specified by:
receiveByte
in interfaceorg.refcodes.io.BytesDestination
- Throws:
IOException
-
receiveBytes
- Specified by:
receiveBytes
in interfaceorg.refcodes.io.BytesDestination
- Specified by:
receiveBytes
in interfaceorg.refcodes.io.BytesReceiver
- Throws:
IOException
-
receiveSequenceWithin
Receives aSequence
with the number of bytes specified. This method blocks till all bytes are read or the timeout has been reached.- Parameters:
aTimeoutMillis
- The default timeout for read operations not explicitly called with a timeout argument. With a value of -1 timeout handling is disabled (blocking mode) or a technical timeout occurs (implementation depended).aLength
- The number of bytes to receive.- Returns:
- A
Sequence
containing the accordingly received bytes. - Throws:
IOException
- thrown in case of I/O issues (e.g. a timeout) while receiving.
-
receiveSequence
Receives aSequence
with the number of bytes specified.This method blocks till all bytes are read.- Parameters:
aLength
- The number of bytes to receive.- Returns:
- A
Sequence
containing the accordingly received bytes. - Throws:
IOException
- thrown in case of I/O issues (e.g. a timeout) while receiving.
-
receiveSegmentWithin
default <SEGMENT extends Segment> void receiveSegmentWithin(long aTimeoutMillis, SEGMENT aSegment) throws IOException Receives aSegment
(and blocks this thread) till all it'sSequence
data has been received and updates theSegment
by invokingSegment.fromTransmission(Sequence)
. This method blocks till all bytes are read or the timeout has been reached.- Specified by:
receiveSegmentWithin
in interfaceSegmentReceiver
- Type Parameters:
SEGMENT
- TheSegment
type describing theSegment
subclass of implementingSegment
types.- Parameters:
aTimeoutMillis
- The default timeout for read operations not explicitly called with a timeout argument. With a value of -1 timeout handling is disabled (blocking mode) or a technical timeout occurs (implementation depended).aSegment
- TheSegment
to be (re-)initialized with the received data.- Throws:
TransmissionException
- Thrown in case the received data cannot be used to (re-)initialize the givenSegment
.IOException
- thrown in case of I/O issues (e.g. a timeout) while receiving.
-
receiveSegment
Receives aSegment
(and blocks this thread) till all it'sSequence
data has been received and updates theSegment
by invokingSegment.fromTransmission(Sequence)
. This method blocks till all bytes are read.- Specified by:
receiveSegment
in interfaceSegmentDestination
- Type Parameters:
SEGMENT
- TheSegment
type describing theSegment
subclass of implementingSegment
types.- Parameters:
aSegment
- TheSegment
to be (re-)initialized with the received data.- Throws:
TransmissionException
- Thrown in case the received data cannot be used to (re-)initialize the givenSegment
.IOException
- thrown in case of I/O issues (e.g. a timeout) while receiving.
-
open
Attention: Implementations of this method should do aObject.notifyAll()
in order to terminate any pending asynchronous operations such asSegmentReceiver.onReceiveSegment(Segment)
orSegmentReceiver.onReceiveSegment(Segment, SegmentConsumer)
.- Specified by:
open
in interfaceorg.refcodes.component.Openable
- Throws:
IOException
-
close
Attention: Implementations of this method should do aObject.notifyAll()
in order to terminate any pending asynchronous operations such asSegmentReceiver.onReceiveSegment(Segment)
orSegmentReceiver.onReceiveSegment(Segment, SegmentConsumer)
.- Specified by:
close
in interfaceorg.refcodes.component.Closable
- Throws:
IOException
-