Interface SerialDataReader
-
- All Known Subinterfaces:
Serial
- All Known Implementing Classes:
AbstractSerialDataReader
,AbstractSerialDataReaderWriter
,SerialImpl
public interface SerialDataReader
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description int
available()
Gets the number of bytes available for reading, or -1 for any error condition.void
discardData()
discard/drain all available bytes from the serial port/device.byte[]
read()
Reads all available bytes from the serial port/device.byte[]
read(int length)
Reads a length of bytes from the port/serial device.void
read(int length, OutputStream stream)
Reads a length bytes from the serial port/device into a provided OutputStream.void
read(int length, ByteBuffer buffer)
Reads a length bytes from the serial port/device into a provided ByteBuffer.CharBuffer
read(int length, Charset charset)
Reads a length of bytes from the port/serial device and returns a CharBuffer from the decoded bytes.void
read(int length, Charset charset, Writer writer)
Reads a length bytes from the serial port/device into a provided Writer.void
read(int length, Collection<ByteBuffer> collection)
Reads a length of bytes from the serial port/device into a provided collection of ByteBuffer objects.void
read(OutputStream stream)
Reads all available bytes from the serial device into a provided OutputStream.void
read(ByteBuffer buffer)
Reads all available bytes from the serial device into a provided ByteBuffer.CharBuffer
read(Charset charset)
Reads all available bytes from the port/serial device and returns a CharBuffer from the decoded bytes.void
read(Charset charset, Writer writer)
Reads all available bytes from the serial port/device into a provided Writer.void
read(Collection<ByteBuffer> collection)
Reads all available bytes from the serial port/device into a provided collection of ByteBuffer objects.
-
-
-
Method Detail
-
available
int available() throws IllegalStateException, IOException
Gets the number of bytes available for reading, or -1 for any error condition.- Returns:
- Returns the number of bytes available for reading, or -1 for any error
- Throws:
IllegalStateException
IOException
-
discardData
void discardData() throws IllegalStateException, IOException
discard/drain all available bytes from the serial port/device.
- Throws:
IllegalStateException
IOException
-
read
byte[] read() throws IllegalStateException, IOException
Reads all available bytes from the serial port/device.
- Returns:
- Returns a byte array with the data read from the serial port.
- Throws:
IllegalStateException
IOException
-
read
byte[] read(int length) throws IllegalStateException, IOException
Reads a length of bytes from the port/serial device.
- Parameters:
length
- The number of bytes to get from the serial port/device. This number must not be higher than the number of available bytes.- Returns:
- Returns a byte array with the data read from the serial port.
- Throws:
IllegalStateException
IOException
-
read
void read(ByteBuffer buffer) throws IllegalStateException, IOException
Reads all available bytes from the serial device into a provided ByteBuffer.
- Parameters:
buffer
- The ByteBuffer object to write to.- Throws:
IllegalStateException
IOException
-
read
void read(int length, ByteBuffer buffer) throws IllegalStateException, IOException
Reads a length bytes from the serial port/device into a provided ByteBuffer.
- Parameters:
length
- The number of bytes to get from the serial port/device. This number must not be higher than the number of available bytes.buffer
- The ByteBuffer object to write to.- Throws:
IllegalStateException
IOException
-
read
void read(OutputStream stream) throws IllegalStateException, IOException
Reads all available bytes from the serial device into a provided OutputStream.
- Parameters:
stream
- The OutputStream object to write to.- Throws:
IllegalStateException
IOException
-
read
void read(int length, OutputStream stream) throws IllegalStateException, IOException
Reads a length bytes from the serial port/device into a provided OutputStream.
- Parameters:
length
- The number of bytes to get from the serial port/device. This number must not be higher than the number of available bytes.stream
- The OutputStream object to write to.- Throws:
IllegalStateException
IOException
-
read
void read(Collection<ByteBuffer> collection) throws IllegalStateException, IOException
Reads all available bytes from the serial port/device into a provided collection of ByteBuffer objects.
- Parameters:
collection
- The collection of CharSequence objects to append to.- Throws:
IllegalStateException
IOException
-
read
void read(int length, Collection<ByteBuffer> collection) throws IllegalStateException, IOException
Reads a length of bytes from the serial port/device into a provided collection of ByteBuffer objects.
- Parameters:
length
- The number of bytes to get from the serial port/device. This number must not be higher than the number of available bytes.collection
- The collection of CharSequence objects to append to.- Throws:
IllegalStateException
IOException
-
read
CharBuffer read(Charset charset) throws IllegalStateException, IOException
Reads all available bytes from the port/serial device and returns a CharBuffer from the decoded bytes.
- Parameters:
charset
- The character set to use for encoding/decoding bytes to/from text characters- Returns:
- Returns a character set with the data read from the serial port.
- Throws:
IllegalStateException
IOException
-
read
CharBuffer read(int length, Charset charset) throws IllegalStateException, IOException
Reads a length of bytes from the port/serial device and returns a CharBuffer from the decoded bytes.
- Parameters:
length
- The number of bytes to get from the serial port/device. This number must not be higher than the number of available bytes.charset
- The character set to use for encoding/decoding bytes to/from text characters- Returns:
- Returns a character set with the data read from the serial port.
- Throws:
IllegalStateException
IOException
-
read
void read(Charset charset, Writer writer) throws IllegalStateException, IOException
Reads all available bytes from the serial port/device into a provided Writer.
- Parameters:
charset
- The character set to use for encoding/decoding bytes to/from text characterswriter
- The Writer object to write to.- Throws:
IllegalStateException
IOException
-
read
void read(int length, Charset charset, Writer writer) throws IllegalStateException, IOException
Reads a length bytes from the serial port/device into a provided Writer.
- Parameters:
length
- The number of bytes to get from the serial port/device. This number must not be higher than the number of available bytes.charset
- The character set to use for encoding/decoding bytes to/from text characterswriter
- The Writer object to write to.- Throws:
IllegalStateException
IOException
-
-