Interface SerialReceiver

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 Type
    Method
    Description
    int
    Returns the number of bytes which can be read directly e.g. which are already been stored in an internal buffer.
    void
    Attention: Implementations of this method should do a Object.notifyAll() in order to terminate any pending asynchronous operations such as SegmentReceiver.onReceiveSegment(Segment) or SegmentReceiver.onReceiveSegment(Segment, SegmentConsumer).
    void
    Attention: Implementations of this method should do a Object.notifyAll() in order to terminate any pending asynchronous operations such as SegmentReceiver.onReceiveSegment(Segment) or SegmentReceiver.onReceiveSegment(Segment, SegmentConsumer).
    default byte
    default byte[]
    receiveBytes(int aMaxLength)
    default <SEGMENT extends Segment>
    void
    receiveSegment(SEGMENT aSegment)
    Receives a Segment (and blocks this thread) till all it's Sequence data has been received and updates the Segment by invoking Segment.fromTransmission(Sequence).
    default <SEGMENT extends Segment>
    void
    receiveSegmentWithin(long aTimeoutInMs, SEGMENT aSegment)
    Receives a Segment (and blocks this thread) till all it's Sequence data has been received and updates the Segment by invoking Segment.fromTransmission(Sequence).
    default Sequence
    receiveSequence(int aLength)
    Receives a Sequence with the number of bytes specified.This method blocks till all bytes are read.
    default Sequence
    receiveSequenceWithin(long aTimeoutInMs, int aLength)
    Receives a Sequence 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

      int available() throws IOException
      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 to InputStream.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 interface org.refcodes.io.Availability
      Specified by:
      available in interface org.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

      default byte receiveByte() throws IOException
      Specified by:
      receiveByte in interface org.refcodes.io.ByteDestination
      Specified by:
      receiveByte in interface org.refcodes.io.BytesDestination
      Throws:
      IOException
    • receiveBytes

      default byte[] receiveBytes(int aMaxLength) throws IOException
      Specified by:
      receiveBytes in interface org.refcodes.io.BytesDestination
      Specified by:
      receiveBytes in interface org.refcodes.io.BytesReceiver
      Throws:
      IOException
    • receiveSequenceWithin

      default Sequence receiveSequenceWithin(long aTimeoutInMs, int aLength) throws IOException
      Receives a Sequence with the number of bytes specified. This method blocks till all bytes are read or the timeout has been reached.
      Parameters:
      aTimeoutInMs - 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

      default Sequence receiveSequence(int aLength) throws IOException
      Receives a Sequence 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 aTimeoutInMs, SEGMENT aSegment) throws TransmissionException, IOException
      Receives a Segment (and blocks this thread) till all it's Sequence data has been received and updates the Segment by invoking Segment.fromTransmission(Sequence). This method blocks till all bytes are read or the timeout has been reached.
      Specified by:
      receiveSegmentWithin in interface SegmentReceiver
      Type Parameters:
      SEGMENT - The Segment type describing the Segment subclass of implementing Segment types.
      Parameters:
      aTimeoutInMs - 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 - The Segment to be (re-)initialized with the received data.
      Throws:
      TransmissionException - Thrown in case the received data cannot be used to (re-)initialize the given Segment.
      IOException - thrown in case of I/O issues (e.g. a timeout) while receiving.
    • receiveSegment

      default <SEGMENT extends Segment> void receiveSegment(SEGMENT aSegment) throws TransmissionException, IOException
      Receives a Segment (and blocks this thread) till all it's Sequence data has been received and updates the Segment by invoking Segment.fromTransmission(Sequence). This method blocks till all bytes are read.
      Specified by:
      receiveSegment in interface SegmentDestination
      Type Parameters:
      SEGMENT - The Segment type describing the Segment subclass of implementing Segment types.
      Parameters:
      aSegment - The Segment to be (re-)initialized with the received data.
      Throws:
      TransmissionException - Thrown in case the received data cannot be used to (re-)initialize the given Segment.
      IOException - thrown in case of I/O issues (e.g. a timeout) while receiving.
    • open

      void open() throws IOException
      Attention: Implementations of this method should do a Object.notifyAll() in order to terminate any pending asynchronous operations such as SegmentReceiver.onReceiveSegment(Segment) or SegmentReceiver.onReceiveSegment(Segment, SegmentConsumer).
      Specified by:
      open in interface org.refcodes.component.Openable
      Throws:
      IOException
    • close

      void close() throws IOException
      Attention: Implementations of this method should do a Object.notifyAll() in order to terminate any pending asynchronous operations such as SegmentReceiver.onReceiveSegment(Segment) or SegmentReceiver.onReceiveSegment(Segment, SegmentConsumer).
      Specified by:
      close in interface org.refcodes.component.Closable
      Throws:
      IOException