Interface SerialReceiver
- All Superinterfaces:
Availability, ByteDestination, ByteReceiver, BytesDestination, BytesReceiver, Closable, Closable.CloseAutomaton, ClosedAccessor, ConnectableComponent, ConnectableComponent.ConnectableAutomaton, ConnectionStatusAccessor, InputStreamAccessor, LinkComponent, LinkComponent.LinkAutomaton, Openable, Openable.OpenAutomaton, OpenedAccessor, Receivable, SegmentDestination, SegmentReceiver, Skippable, TimeoutInputStreamAccessor
- All Known Subinterfaces:
Port<PM>, SerialTransceiver
- All Known Implementing Classes:
AbstractPort, AbstractPortDecorator, CrossoverLoopbackPort, LoopbackPort
public interface SerialReceiver
extends BytesReceiver, SegmentReceiver, LinkComponent.LinkAutomaton, Skippable
A
SerialReceiver is used to read data from a serial port or the like.-
Nested Class Summary
Nested classes/interfaces inherited from interface BytesReceiver
BytesReceiver.ReceiverInputStreamNested classes/interfaces inherited from interface Closable
Closable.CloseAutomaton, Closable.CloseBuilder<B>Nested classes/interfaces inherited from interface ClosedAccessor
ClosedAccessor.ClosedMutator, ClosedAccessor.ClosedPropertyNested classes/interfaces inherited from interface ConnectableComponent
ConnectableComponent.ConnectableAutomatonNested classes/interfaces inherited from interface ConnectionStatusAccessor
ConnectionStatusAccessor.ConnectionStatusMutator, ConnectionStatusAccessor.ConnectionStatusPropertyNested classes/interfaces inherited from interface InputStreamAccessor
InputStreamAccessor.InputStreamBuilder<B>, InputStreamAccessor.InputStreamMutator, InputStreamAccessor.InputStreamPropertyNested classes/interfaces inherited from interface LinkComponent
LinkComponent.LinkAutomaton, LinkComponent.LinkComponentBuilder<B>Nested classes/interfaces inherited from interface Openable
Openable.OpenAutomaton, Openable.OpenBuilder<B>Nested classes/interfaces inherited from interface OpenedAccessor
OpenedAccessor.OpenedMutator, OpenedAccessor.OpenedPropertyNested classes/interfaces inherited from interface TimeoutInputStreamAccessor
TimeoutInputStreamAccessor.TimeoutInputStreamBuilder<B>, TimeoutInputStreamAccessor.TimeoutInputStreamMutator, 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 Availability
hasAvailableMethods inherited from interface BytesDestination
receiveBytesMethods inherited from interface BytesReceiver
getInputStream, getInputStream, receiveAllBytes, receiveBytesWithin, receiveBytesWithin, receiveByteWithin, skipMethods inherited from interface Closable
closeIn, closeQuietly, closeUncheckedMethods inherited from interface Closable.CloseAutomaton
isClosableMethods inherited from interface ClosedAccessor
isClosedMethods inherited from interface ConnectionStatusAccessor
getConnectionStatus, isOpenedMethods inherited from interface Openable
openUncheckedMethods inherited from interface Openable.OpenAutomaton
isOpenableMethods inherited from interface SegmentReceiver
onReceiveSegment, onReceiveSegmentMethods inherited from interface 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 interfaceAvailability- Specified by:
availablein interfaceSkippable- 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 interfaceByteDestination- Specified by:
receiveBytein interfaceBytesDestination- Throws:
IOException
-
receiveBytes
- Specified by:
receiveBytesin interfaceBytesDestination- Specified by:
receiveBytesin interfaceBytesReceiver- 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:
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:
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 interfaceOpenable- 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 interfaceClosable- Throws:
IOException
-