public interface SerialDataReader
Modifier and Type | Method and 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.
|
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.
|
byte[] |
read(int length)
Reads a length of bytes from the port/serial device.
|
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(int length,
OutputStream stream)
Reads a length bytes from the serial port/device into a provided OutputStream.
|
void |
read(OutputStream stream)
Reads all available bytes from the serial device into a provided OutputStream.
|
int available() throws IllegalStateException, IOException
IllegalStateException
IOException
void discardData() throws IllegalStateException, IOException
discard/drain all available bytes from the serial port/device.
IllegalStateException
IOException
byte[] read() throws IllegalStateException, IOException
Reads all available bytes from the serial port/device.
IllegalStateException
IOException
byte[] read(int length) throws IllegalStateException, IOException
Reads a length of bytes from the port/serial device.
length
- The number of bytes to get from the serial port/device.
This number must not be higher than the number of available bytes.IllegalStateException
IOException
void read(ByteBuffer buffer) throws IllegalStateException, IOException
Reads all available bytes from the serial device into a provided ByteBuffer.
buffer
- The ByteBuffer object to write to.IllegalStateException
IOException
void read(int length, ByteBuffer buffer) throws IllegalStateException, IOException
Reads a length bytes from the serial port/device into a provided ByteBuffer.
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.IllegalStateException
IOException
void read(OutputStream stream) throws IllegalStateException, IOException
Reads all available bytes from the serial device into a provided OutputStream.
stream
- The OutputStream object to write to.IllegalStateException
IOException
void read(int length, OutputStream stream) throws IllegalStateException, IOException
Reads a length bytes from the serial port/device into a provided OutputStream.
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.IllegalStateException
IOException
void read(Collection<ByteBuffer> collection) throws IllegalStateException, IOException
Reads all available bytes from the serial port/device into a provided collection of ByteBuffer objects.
collection
- The collection of CharSequence objects to append to.IllegalStateException
IOException
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.
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.IllegalStateException
IOException
CharBuffer read(Charset charset) throws IllegalStateException, IOException
Reads all available bytes from the port/serial device and returns a CharBuffer from the decoded bytes.
charset
- The character set to use for encoding/decoding bytes to/from text charactersIllegalStateException
IOException
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.
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 charactersIllegalStateException
IOException
void read(Charset charset, Writer writer) throws IllegalStateException, IOException
Reads all available bytes from the serial port/device into a provided Writer.
charset
- The character set to use for encoding/decoding bytes to/from text characterswriter
- The Writer object to write to.IllegalStateException
IOException
void read(int length, Charset charset, Writer writer) throws IllegalStateException, IOException
Reads a length bytes from the serial port/device into a provided Writer.
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.IllegalStateException
IOException
Copyright © 2012–2021 Pi4J. All rights reserved.