Package com.diozero.api
Interface SerialDeviceInterface
-
- All Superinterfaces:
AutoCloseable
,DeviceInterface
- All Known Subinterfaces:
InternalSerialDeviceInterface
- All Known Implementing Classes:
DefaultNativeSerialDevice
,SerialDevice
public interface SerialDeviceInterface extends DeviceInterface
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description int
bytesAvailable()
Get the number of bytes that are available to be readint
read()
Read a single byte returning error responsesint
read(byte[] buffer)
Attempt to read buffer.length bytes into the specified buffer, returning the number of bytes actually read; throw a RuntimeIOException if an I/O error occursbyte
readByte()
Read a single byte, throw an exception if unable to read any datavoid
write(byte... data)
Write the byte buffer to the devicevoid
writeByte(byte bVal)
Write a single byte, throw an exception if unable to write the data-
Methods inherited from interface com.diozero.api.DeviceInterface
close
-
-
-
-
Method Detail
-
read
int read() throws RuntimeIOException
Read a single byte returning error responses- Returns:
- Signed integer representation of the data read, including error responses (values < 0)
- Throws:
RuntimeIOException
- if an I/O error occurs
-
readByte
byte readByte() throws RuntimeIOException
Read a single byte, throw an exception if unable to read any data- Returns:
- The data read
- Throws:
RuntimeIOException
- if an I/O error occurs
-
writeByte
void writeByte(byte bVal) throws RuntimeIOException
Write a single byte, throw an exception if unable to write the data- Parameters:
bVal
- The data to write- Throws:
RuntimeIOException
- if an I/O error occurs
-
read
int read(byte[] buffer) throws RuntimeIOException
Attempt to read buffer.length bytes into the specified buffer, returning the number of bytes actually read; throw a RuntimeIOException if an I/O error occurs- Parameters:
buffer
- The buffer to read into, the length of this buffer specifies the number of bytes to read- Returns:
- The number of bytes read
- Throws:
RuntimeIOException
- if an I/O error occurs
-
write
void write(byte... data) throws RuntimeIOException
Write the byte buffer to the device- Parameters:
data
- The data to write- Throws:
RuntimeIOException
- if an I/O error occurs
-
bytesAvailable
int bytesAvailable() throws RuntimeIOException
Get the number of bytes that are available to be read- Returns:
- The number of bytes that are available to read
- Throws:
RuntimeIOException
- if an I/O error occurs
-
-