Package com.diozero.api
Interface SerialDeviceInterface
- All Superinterfaces:
AutoCloseable
,Closeable
,DeviceInterface
- All Known Implementing Classes:
DefaultNativeSerialDevice
,SerialDevice
public interface SerialDeviceInterface extends DeviceInterface
-
Method Summary
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 dataMethods inherited from interface com.diozero.api.DeviceInterface
close, getKey, isOpen
-
Method Details
-
read
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
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
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
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
Write the byte buffer to the device- Parameters:
data
- The data to write- Throws:
RuntimeIOException
- if an I/O error occurs
-
bytesAvailable
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
-