- 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.ReceiverInputStreamNested 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.ClosedPropertyNested classes/interfaces inherited from interface org.refcodes.component.ConnectableComponent
org.refcodes.component.ConnectableComponent.ConnectableAutomatonNested classes/interfaces inherited from interface org.refcodes.component.ConnectionStatusAccessor
org.refcodes.component.ConnectionStatusAccessor.ConnectionStatusMutator, org.refcodes.component.ConnectionStatusAccessor.ConnectionStatusPropertyNested 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.InputStreamPropertyNested 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.OpenedPropertyNested 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 TypeMethodDescriptionintReturns the number of bytes which can be read directly e.g. which are already been stored in an internal buffer.voidclose()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).voidopen()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 bytedefault byte[]receiveBytes(int aLength) default <SEGMENT extends Segment>
voidreceiveSegment(SEGMENT aSegment) Receives aSegment(and blocks this thread) till all it'sSequencedata has been received and updates theSegmentby invokingSegment.fromTransmission(Sequence).default <SEGMENT extends Segment>
voidreceiveSegmentWithin(long aTimeoutMillis, SEGMENT aSegment) Receives aSegment(and blocks this thread) till all it'sSequencedata has been received and updates theSegmentby invokingSegment.fromTransmission(Sequence).default SequencereceiveSequence(int aLength) Receives aSequencewith the number of bytes specified.This method blocks till all bytes are read.default SequencereceiveSequenceWithin(long aTimeoutMillis, int aLength) Receives aSequencewith the number of bytes specified.Methods inherited from interface org.refcodes.io.Availability
hasAvailableMethods inherited from interface org.refcodes.io.BytesDestination
receiveBytesMethods inherited from interface org.refcodes.io.BytesReceiver
getInputStream, getInputStream, receiveAllBytes, receiveBytesWithin, receiveBytesWithin, receiveByteWithin, skipMethods inherited from interface org.refcodes.component.Closable
closeIn, closeQuietly, closeUncheckedMethods inherited from interface org.refcodes.component.Closable.CloseAutomaton
isClosableMethods inherited from interface org.refcodes.component.ClosedAccessor
isClosedMethods inherited from interface org.refcodes.component.ConnectionStatusAccessor
getConnectionStatus, isOpenedMethods inherited from interface org.refcodes.component.Openable
openUncheckedMethods inherited from interface org.refcodes.component.Openable.OpenAutomaton
isOpenableMethods inherited from interface org.refcodes.serial.SegmentReceiver
onReceiveSegment, onReceiveSegmentMethods 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:
availablein interfaceorg.refcodes.io.Availability- Specified by:
availablein 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:
receiveBytein interfaceorg.refcodes.io.ByteDestination- Specified by:
receiveBytein interfaceorg.refcodes.io.BytesDestination- Throws:
IOException
-
receiveBytes
- Specified by:
receiveBytesin interfaceorg.refcodes.io.BytesDestination- Specified by:
receiveBytesin interfaceorg.refcodes.io.BytesReceiver- Throws:
IOException
-
receiveSequenceWithin
Receives aSequencewith 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
Sequencecontaining the accordingly received bytes. - Throws:
IOException- thrown in case of I/O issues (e.g. a timeout) while receiving.
-
receiveSequence
Receives aSequencewith the number of bytes specified.This method blocks till all bytes are read.- Parameters:
aLength- The number of bytes to receive.- Returns:
- A
Sequencecontaining 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'sSequencedata has been received and updates theSegmentby invokingSegment.fromTransmission(Sequence). This method blocks till all bytes are read or the timeout has been reached.- Specified by:
receiveSegmentWithinin interfaceSegmentReceiver- Type Parameters:
SEGMENT- TheSegmenttype describing theSegmentsubclass of implementingSegmenttypes.- 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- TheSegmentto 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'sSequencedata has been received and updates theSegmentby invokingSegment.fromTransmission(Sequence). This method blocks till all bytes are read.- Specified by:
receiveSegmentin interfaceSegmentDestination- Type Parameters:
SEGMENT- TheSegmenttype describing theSegmentsubclass of implementingSegmenttypes.- Parameters:
aSegment- TheSegmentto 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:
openin 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:
closein interfaceorg.refcodes.component.Closable- Throws:
IOException
-