-
- All Known Subinterfaces:
I2C
,I2CRegisterDataReaderWriter
- All Known Implementing Classes:
I2CBase
public interface I2CRegisterDataReader
I2C Register Data Writer Interface for Pi4J Data Communications- Version:
- $Id: $Id
- Author:
- Robert Savage Based on previous contributions from: Daniel Sendula, RasPelikan
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description int
readRegister(int register)
Read a single raw byte (8-bit) value from an I2C device register.default int
readRegister(int register, byte[] buffer)
Read data from the I2C device register into the provided byte array starting at the zero index (first byte) and up to the available space in the buffer.default int
readRegister(int register, byte[] buffer, int length)
Read data from the I2C device register into the provided byte array starting at the zero index (first byte) and up to the specified data length (number of bytes).int
readRegister(int register, byte[] buffer, int offset, int length)
Read data from the I2C device register into the provided byte array at the given offset and up to the specified data length (number of bytes).default int
readRegister(int register, char[] buffer)
Read ASCII data from the I2C device register into the provided character array starting at the zero index (first byte) and up to the available space in the buffer/array.default int
readRegister(int register, char[] buffer, int length)
Read ASCII data from the I2C device register into the provided character array starting with the first byte in the array up to the provided length.default int
readRegister(int register, char[] buffer, int offset, int length)
Read ASCII character data from the I2C device register into the provided character array at the given offset and up to the specified data length (number of characters).default int
readRegister(int register, ByteBuffer buffer)
Read data from the I2C device register into the provided byte buffer starting with the first byte in the array up to available space remaining in the buffer.default int
readRegister(int register, ByteBuffer buffer, int length)
Read data from the I2C device register into the provided byte buffer starting with the first byte in the array up to the provided length.default int
readRegister(int register, ByteBuffer buffer, int offset, int length)
Read data from the I2C device register into the provided byte buffer at the given offset and up to the specified data length (number of bytes).default int
readRegister(int register, CharBuffer buffer)
Read ASCII character data from the I2C device register into the provided character buffer starting at the zero index (first position) up to available space remaining in the buffer.default int
readRegister(int register, CharBuffer buffer, int length)
Read ASCII character data from the I2C device register into the provided character buffer starting at the zero index (first position) up to available space remaining in the buffer.default int
readRegister(int register, CharBuffer buffer, int offset, int length)
Read ASCII character data from the I/O device into the provided character buffer at the given offset and up to the specified data length (number of characters).default int
readRegister(int register, Charset charset, char[] buffer)
Read data from the I2C device register into the provided character array starting at the zero index (first byte) and up to the available space in the buffer/array.default int
readRegister(int register, Charset charset, char[] buffer, int length)
Read data from the I2C device register into the provided character array starting with the first byte in the array up to the provided length.default int
readRegister(int register, Charset charset, char[] buffer, int offset, int length)
Read character data from the I2C device register into the provided character array at the given offset and up to the specified data length (number of characters).default int
readRegister(int register, Charset charset, CharBuffer buffer)
Read character data from the I2C device register into the provided character buffer starting at the zero index (first position) up to available space remaining in the buffer.default int
readRegister(int register, Charset charset, CharBuffer buffer, int length)
Read character data from the I2C device register into the provided character buffer starting at the zero index (first position) up to available space remaining in the buffer.default int
readRegister(int register, Charset charset, CharBuffer buffer, int offset, int length)
Read character data from the I2C device register into the provided character buffer starting at the zero index (first position) up to the specified data length (number of characters).default byte
readRegisterByte(int register)
Read a single raw byte (8-bit) value from an I2C device register.default ByteBuffer
readRegisterByteBuffer(int register, int length)
Read data from the I2C device register up to a specified length (number of bytes) and return the data read in a new ByteBuffer.default ByteBuffer
readRegisterByteBuffer(int register, int offset, int length)
Read data from the I2C device register up to a specified length (number of bytes) and return the data read in a new ByteBuffer.default char[]
readRegisterCharArray(int register, int numberOfBytes)
Read ASCII data from the I2C device register up to a specified length (number of bytes) and return the data read in a new character array.default char[]
readRegisterCharArray(int register, int offset, int numberOfBytes)
Read ASCII data from the I2C device register up to a specified length (number of bytes) and return the data read in a new character array.default char[]
readRegisterCharArray(int register, Charset charset, int numberOfBytes)
Read data from the I2C device register up to a specified length (number of bytes) and return the data read in a new character array.default char[]
readRegisterCharArray(int register, Charset charset, int offset, int numberOfBytes)
Read data from the I2C device register up to a specified length (number of bytes) and return the data read in a new character array.default CharBuffer
readRegisterCharBuffer(int register, int numberOfBytes)
Read ASCII data from the I2C device register up to a specified length (number of bytes) and return the data read in a new CharBuffer instance.default CharBuffer
readRegisterCharBuffer(int register, int offset, int numberOfBytes)
Read ASCII data from the I2C device register up to a specified length (number of bytes) and return the data read in a new CharBuffer instance.default CharBuffer
readRegisterCharBuffer(int register, Charset charset, int numberOfBytes)
Read data from the I2C device register up to a specified length (number of bytes) and return the data read in a new CharBuffer instance.default CharBuffer
readRegisterCharBuffer(int register, Charset charset, int offset, int numberOfBytes)
Read data from the I2C device register up to a specified length (number of bytes) and return the data read in a new CharBuffer instance.default byte[]
readRegisterNBytes(int register, int length)
Read data from the I2C device register up to a specified length (number of bytes) and return the data read in a new byte array.default byte[]
readRegisterNBytes(int register, int offset, int length)
Read data from the I2C device register up to a specified length (number of bytes) and return the data read in a new byte array.default String
readRegisterString(int register, int numberOfBytes)
Read ASCII data from the I2C device registere up to a specified length (number of bytes) and return the data read in a new String instance.default String
readRegisterString(int register, int offset, int numberOfBytes)
Read ASCII data from the I2C device registere up to a specified length (number of bytes) and return the data read in a new String instance.default String
readRegisterString(int register, Charset charset, int numberOfBytes)
Read data from the I2C device registere up to a specified length (number of bytes) and return the data read in a new String instance.default String
readRegisterString(int register, Charset charset, int offset, int numberOfBytes)
Read data from the I2C device registere up to a specified length (number of bytes) and return the data read in a new String instance.default int
readRegisterWord(int register)
Read a single raw word (2-byte; 16-bit) value from an I2C device register.
-
-
-
Method Detail
-
readRegister
int readRegister(int register)
Read a single raw byte (8-bit) value from an I2C device register.- Parameters:
register
- The I2C device register address to write to.- Returns:
- If successful, a zero or positive integer value representing the byte value (0-255) is returned. If a read error was encountered, a negative error code may be returned.
-
readRegister
int readRegister(int register, byte[] buffer, int offset, int length)
Read data from the I2C device register into the provided byte array at the given offset and up to the specified data length (number of bytes).- Parameters:
register
- The I2C device register address to write to.buffer
- the byte array/buffer the read data will be copied/inserted intooffset
- the offset index in the data buffer to start copying read datalength
- the number of bytes to read- Returns:
- If successful, return the number of bytes read from the I/O device; else on a read error, return a negative error code.
-
readRegister
default int readRegister(int register, byte[] buffer, int length)
Read data from the I2C device register into the provided byte array starting at the zero index (first byte) and up to the specified data length (number of bytes).- Parameters:
register
- The I2C device register address to write to.buffer
- the byte array/buffer the read data will be copied/inserted intolength
- the number of bytes to read- Returns:
- If successful, return the number of bytes read from the I/O device; else on a read error, return a negative error code.
-
readRegister
default int readRegister(int register, byte[] buffer)
Read data from the I2C device register into the provided byte array starting at the zero index (first byte) and up to the available space in the buffer.- Parameters:
register
- The I2C device register address to write to.buffer
- the byte array/buffer the read data will be copied/inserted into- Returns:
- If successful, return the number of bytes read from the I/O device; else on a read error, return a negative error code.
-
readRegister
default int readRegister(int register, ByteBuffer buffer, int offset, int length)
Read data from the I2C device register into the provided byte buffer at the given offset and up to the specified data length (number of bytes). NOTE: The buffer's internal position tracking is not used but rather only the explicit offset and length provided. If the requested length is greater than the buffers capacity (minus offset) then the specified length will be ignored and this function will only write the number of bytes up to the buffers' available space.- Parameters:
register
- The I2C device register address to write to.buffer
- the byte buffer the read data will be copied/inserted intooffset
- the offset index in the data buffer to start copying read datalength
- the number of bytes to read- Returns:
- If successful, return the number of bytes read from the I2C device register; else on a read error, return a negative error code.
-
readRegister
default int readRegister(int register, ByteBuffer buffer, int length)
Read data from the I2C device register into the provided byte buffer starting with the first byte in the array up to the provided length. NOTE: The data bytes read from the I2C device register are copied/ inserted into the byte buffer starting at the current position index up to the length requested or up to the buffer's remaining limit; whichever is is lower . If the buffer's current position is already at the buffer's limit, then we will automatically rewind the buffer to begin writing data from the zero position up to the buffer's limit.- Parameters:
register
- The I2C device register address to write to.buffer
- the byte buffer the read data will be copied/inserted intolength
- the number of bytes to read- Returns:
- If successful, return the number of bytes read from the I2C device register; else on a read error, return a negative error code.
-
readRegister
default int readRegister(int register, ByteBuffer buffer)
Read data from the I2C device register into the provided byte buffer starting with the first byte in the array up to available space remaining in the buffer. NOTE: The data bytes read from the I2C device register are copied/ inserted into the byte buffer starting at the current position index up to the buffer's remaining limit. If the buffer's current position is already at the buffer's limit, then we will automatically rewind the buffer to begin writing data from the zero position up to the buffer's limit.- Parameters:
register
- The I2C device register address to write to.buffer
- byte buffer of data where data read from the I2C device register will be copied (from current position to limit)- Returns:
- If successful, return the number of bytes read from the I2C device register; else on a read error, return a negative error code.
-
readRegister
default int readRegister(int register, Charset charset, char[] buffer, int offset, int length)
Read character data from the I2C device register into the provided character array at the given offset and up to the specified data length (number of characters). Specify the character set to be used to decode the bytes into chars.- Parameters:
register
- The I2C device register address to write to.charset
- character set to use for byte decodingbuffer
- the character array the read data will be copied/inserted intooffset
- the offset index in the character array to start copying read datalength
- the number of bytes to read- Returns:
- If successful, return the number of bytes read from the I2C device register; else on a read error, return a negative error code.
-
readRegister
default int readRegister(int register, Charset charset, char[] buffer, int length)
Read data from the I2C device register into the provided character array starting with the first byte in the array up to the provided length. Specify the character set to be used to decode the bytes into chars.- Parameters:
register
- The I2C device register address to write to.charset
- character set to use for byte decodingbuffer
- the character array the read data will be copied/inserted intolength
- the number of bytes to read- Returns:
- If successful, return the number of bytes read from the I2C device register; else on a read error, return a negative error code.
-
readRegister
default int readRegister(int register, Charset charset, char[] buffer)
Read data from the I2C device register into the provided character array starting at the zero index (first byte) and up to the available space in the buffer/array. Specify the character set to be used to decode the bytes into chars.- Parameters:
register
- The I2C device register address to write to.charset
- character set to use for byte decodingbuffer
- the character array the read data will be copied/inserted into- Returns:
- If successful, return the number of bytes read from the I2C device register; else on a read error, return a negative error code.
-
readRegister
default int readRegister(int register, char[] buffer, int offset, int length)
Read ASCII character data from the I2C device register into the provided character array at the given offset and up to the specified data length (number of characters). ASCII is the internal character set used to decode the bytes into chars.- Parameters:
register
- The I2C device register address to write to.buffer
- the character array the read data will be copied/inserted intooffset
- the offset index in the character array to start copying read datalength
- the number of bytes to read- Returns:
- If successful, return the number of bytes read from the I2C device register; else on a read error, return a negative error code.
-
readRegister
default int readRegister(int register, char[] buffer, int length)
Read ASCII data from the I2C device register into the provided character array starting with the first byte in the array up to the provided length. ASCII is the internal character set used to decode the bytes into chars.- Parameters:
register
- The I2C device register address to write to.buffer
- the character array the read data will be copied/inserted intolength
- the number of bytes to read- Returns:
- If successful, return the number of bytes read from the I2C device register; else on a read error, return a negative error code.
-
readRegister
default int readRegister(int register, char[] buffer)
Read ASCII data from the I2C device register into the provided character array starting at the zero index (first byte) and up to the available space in the buffer/array. ASCII is the internal character set used to decode the bytes into chars.- Parameters:
register
- The I2C device register address to write to.buffer
- the character array the read data will be copied/inserted into- Returns:
- If successful, return the number of bytes read from the I2C device register; else on a read error, return a negative error code.
-
readRegister
default int readRegister(int register, Charset charset, CharBuffer buffer, int offset, int length)
Read character data from the I2C device register into the provided character buffer starting at the zero index (first position) up to the specified data length (number of characters). Specify the character set to be used to decode the bytes into chars. NOTE: The data characters read and decoded from the I2C device register are copied/inserted into the character buffer starting at the current position index up to the length requested or up to the buffer's remaining limit; whichever is is lower . If the buffer's current position is already at the buffer's limit, then we will automatically rewind the buffer to begin writing data from the zero position up to the buffer's limit.- Parameters:
register
- The I2C device register address to write to.charset
- character set to use for byte decodingbuffer
- the character array the read data will be copied/inserted intolength
- the number of bytes to readoffset
- a int.- Returns:
- If successful, return the number of bytes (not characters) read from the I2C device register; else on a read error, return a negative error code.
-
readRegister
default int readRegister(int register, Charset charset, CharBuffer buffer, int length)
Read character data from the I2C device register into the provided character buffer starting at the zero index (first position) up to available space remaining in the buffer. Specify the character set to be used to decode the bytes into chars. NOTE: The data characters read from the I2C device register are copied/ inserted into the character buffer starting at the current position index up to the buffer's remaining limit. If the buffer's current position is already at the buffer's limit, then we will automatically rewind the buffer to begin writing data from the zero position up to the buffer's limit.- Parameters:
register
- The I2C device register address to write to.charset
- character set to use for byte decodingbuffer
- the character array the read data will be copied/inserted intolength
- a int.- Returns:
- If successful, return the number of bytes (not characters) read from the I2C device register; else on a read error, return a negative error code.
-
readRegister
default int readRegister(int register, Charset charset, CharBuffer buffer)
Read character data from the I2C device register into the provided character buffer starting at the zero index (first position) up to available space remaining in the buffer. Specify the character set to be used to decode the bytes into chars. NOTE: The data characters read from the I2C device register are copied/ inserted into the character buffer starting at the current position index up to the buffer's remaining limit. If the buffer's current position is already at the buffer's limit, then we will automatically rewind the buffer to begin writing data from the zero position up to the buffer's limit.- Parameters:
register
- The I2C device register address to write to.charset
- character set to use for byte decodingbuffer
- the character array the read data will be copied/inserted into- Returns:
- If successful, return the number of bytes (not characters) read from the I2C device register; else on a read error, return a negative error code.
-
readRegister
default int readRegister(int register, CharBuffer buffer, int offset, int length)
Read ASCII character data from the I/O device into the provided character buffer at the given offset and up to the specified data length (number of characters). ASCII is the internal character set used to decode the bytes into chars. NOTE: The buffer's internal position tracking is not used but rather only the explicit offset and length provided. If the requested length is greater than the buffers capacity (minus offset) then the specified length will be ignored and this function will only write the number of characters up to the buffers' available space.- Parameters:
buffer
- the character array the read data will be copied/inserted intooffset
- the offset index in the character buffer to start copying read datalength
- the number of bytes to readregister
- a int.- Returns:
- If successful, return the number of bytes (not characters) read from the I/O device; else on a read error, return a negative error code.
-
readRegister
default int readRegister(int register, CharBuffer buffer, int length)
Read ASCII character data from the I2C device register into the provided character buffer starting at the zero index (first position) up to available space remaining in the buffer. ASCII is the internal character set used to decode the bytes into chars. NOTE: The data characters read from the I2C device register are copied/ inserted into the character buffer starting at the current position index up to the buffer's remaining limit. If the buffer's current position is already at the buffer's limit, then we will automatically rewind the buffer to begin writing data from the zero position up to the buffer's limit.- Parameters:
register
- The I2C device register address to write to.buffer
- the character array the read data will be copied/inserted intolength
- a int.- Returns:
- If successful, return the number of bytes (not characters) read from the I2C device register; else on a read error, return a negative error code.
-
readRegister
default int readRegister(int register, CharBuffer buffer)
Read ASCII character data from the I2C device register into the provided character buffer starting at the zero index (first position) up to available space remaining in the buffer. ASCII is the internal character set used to decode the bytes into chars. NOTE: The data characters read from the I2C device register are copied/ inserted into the character buffer starting at the current position index up to the buffer's remaining limit. If the buffer's current position is already at the buffer's limit, then we will automatically rewind the buffer to begin writing data from the zero position up to the buffer's limit.- Parameters:
register
- The I2C device register address to write to.buffer
- the character array the read data will be copied/inserted into- Returns:
- If successful, return the number of bytes (not characters) read from the I2C device register; else on a read error, return a negative error code.
-
readRegisterByte
default byte readRegisterByte(int register)
Read a single raw byte (8-bit) value from an I2C device register.- Parameters:
register
- The I2C device register address to write to.- Returns:
- The 8-bit byte value
- Throws:
IOReadException
- if any.
-
readRegisterWord
default int readRegisterWord(int register)
Read a single raw word (2-byte; 16-bit) value from an I2C device register.- Parameters:
register
- The I2C device register address to write to.- Returns:
- The 16-bit (2-byte) word value
-
readRegisterNBytes
default byte[] readRegisterNBytes(int register, int offset, int length)
Read data from the I2C device register up to a specified length (number of bytes) and return the data read in a new byte array. The 'offset' parameter allows you to skip a certain number of bytes in the read data and exclude them from the returned data byte array. Note: the resulting byte array size will be at most the 'length' - 'offset'.- Parameters:
register
- The I2C device register address to write to.offset
- the offset index in the data read to start copying read datalength
- the number of bytes to read- Returns:
- a new byte array containing the data bytes read from the I2C device register.
- Throws:
IllegalArgumentException
- An java.lang.IllegalArgumentException is thrown if one of the method parameters are invalid.
-
readRegisterNBytes
default byte[] readRegisterNBytes(int register, int length)
Read data from the I2C device register up to a specified length (number of bytes) and return the data read in a new byte array.- Parameters:
register
- The I2C device register address to write to.length
- the number of bytes to read- Returns:
- a new byte array containing the data bytes read from the I2C device register.
- Throws:
IllegalArgumentException
- An java.lang.IllegalArgumentException is thrown if one of the method parameters are invalid.
-
readRegisterByteBuffer
default ByteBuffer readRegisterByteBuffer(int register, int offset, int length)
Read data from the I2C device register up to a specified length (number of bytes) and return the data read in a new ByteBuffer. The 'offset' parameter allows you to skip a certain number of bytes in the read data and excludes them from the returned data ByteBuffer. Note: the resulting byte buffer size will be at most the 'length' - 'offset'.- Parameters:
register
- The I2C device register address to write to.offset
- the offset index in the data read to start copying read datalength
- the number of bytes to read- Returns:
- a new ByteBuffer containing the data bytes read from the I2C device register.
- Throws:
IllegalArgumentException
- An java.lang.IllegalArgumentException is thrown if one of the method parameters are invalid.
-
readRegisterByteBuffer
default ByteBuffer readRegisterByteBuffer(int register, int length)
Read data from the I2C device register up to a specified length (number of bytes) and return the data read in a new ByteBuffer. The 'offset' parameter allows you to skip a certain number of bytes in the read data and excludes them from the returned data ByteBuffer.- Parameters:
register
- The I2C device register address to write to.length
- the number of bytes to read- Returns:
- a new ByteBuffer containing the data bytes read from the I2C device register.
- Throws:
IllegalArgumentException
- An java.lang.IllegalArgumentException is thrown if one of the method parameters are invalid.
-
readRegisterCharArray
default char[] readRegisterCharArray(int register, Charset charset, int offset, int numberOfBytes) throws IOReadException
Read data from the I2C device register up to a specified length (number of bytes) and return the data read in a new character array. The 'offset' parameter allows you to skip a certain number of bytes in the read data and excludes them from the returned character array.- Parameters:
register
- The I2C device register address to write to.charset
- character set to use for byte decodingoffset
- the offset index in the raw bytes read to start fromnumberOfBytes
- the number of bytes to read (not number of characters)- Returns:
- a new character array containing the decoded character data read from the I2C device register.
- Throws:
IOReadException
- An com.pi4j.io.exception.IOReadException is thrown if a read access error code is returned from the underlying read() functions.IllegalArgumentException
- An java.lang.IllegalArgumentException is thrown if one of the method parameters are invalid.
-
readRegisterCharArray
default char[] readRegisterCharArray(int register, Charset charset, int numberOfBytes) throws IOReadException
Read data from the I2C device register up to a specified length (number of bytes) and return the data read in a new character array.- Parameters:
register
- The I2C device register address to write to.charset
- character set to use for byte decodingnumberOfBytes
- the number of bytes to read (not number of characters)- Returns:
- a new character array containing the decoded character data read from the I2C device register.
- Throws:
IOReadException
- An com.pi4j.io.exception.IOReadException is thrown if a read access error code is returned from the underlying read() functions.IllegalArgumentException
- An java.lang.IllegalArgumentException is thrown if one of the method parameters are invalid.
-
readRegisterCharArray
default char[] readRegisterCharArray(int register, int offset, int numberOfBytes) throws IOReadException
Read ASCII data from the I2C device register up to a specified length (number of bytes) and return the data read in a new character array. The 'offset' parameter allows you to skip a certain number of bytes in the read data and excludes them from the returned character array. ASCII is the internal character set used to decode the bytes into chars.- Parameters:
register
- The I2C device register address to write to.offset
- the offset index in the raw bytes read to start fromnumberOfBytes
- the number of bytes to read (not number of characters)- Returns:
- a new character array containing the decoded character data read from the I2C device register.
- Throws:
IOReadException
- An com.pi4j.io.exception.IOReadException is thrown if a read access error code is returned from the underlying read() functions.IllegalArgumentException
- An java.lang.IllegalArgumentException is thrown if one of the method parameters are invalid.
-
readRegisterCharArray
default char[] readRegisterCharArray(int register, int numberOfBytes) throws IOReadException
Read ASCII data from the I2C device register up to a specified length (number of bytes) and return the data read in a new character array. ASCII is the internal character set used to decode the bytes into chars.- Parameters:
register
- The I2C device register address to write to.numberOfBytes
- the number of bytes to read (not number of characters)- Returns:
- a new character array containing the decoded character data read from the I2C device register.
- Throws:
IOReadException
- An com.pi4j.io.exception.IOReadException is thrown if a read access error code is returned from the underlying read() functions.IllegalArgumentException
- An java.lang.IllegalArgumentException is thrown if one of the method parameters are invalid.
-
readRegisterCharBuffer
default CharBuffer readRegisterCharBuffer(int register, Charset charset, int offset, int numberOfBytes) throws IOReadException
Read data from the I2C device register up to a specified length (number of bytes) and return the data read in a new CharBuffer instance. The 'offset' parameter allows you to skip a certain number of bytes in the read data and excludes them from the returned character array.- Parameters:
charset
- character set to use for byte decodingoffset
- the offset index in the raw bytes read to start fromnumberOfBytes
- the number of bytes to read (not number of characters)register
- a int.- Returns:
- a new character buffer (CharBuffer) containing the decoded character data read from the I2C device register.
- Throws:
IOReadException
- An com.pi4j.io.exception.IOReadException is thrown if a read access error code is returned from the underlying read() functions.IllegalArgumentException
- An java.lang.IllegalArgumentException is thrown if one of the method parameters are invalid.
-
readRegisterCharBuffer
default CharBuffer readRegisterCharBuffer(int register, Charset charset, int numberOfBytes) throws IOReadException
Read data from the I2C device register up to a specified length (number of bytes) and return the data read in a new CharBuffer instance.- Parameters:
charset
- character set to use for byte decodingnumberOfBytes
- the number of bytes to read (not number of characters)register
- a int.- Returns:
- a new character buffer (CharBuffer) containing the decoded character data read from the I2C device register.
- Throws:
IOReadException
- An com.pi4j.io.exception.IOReadException is thrown if a read access error code is returned from the underlying read() functions.IllegalArgumentException
- An java.lang.IllegalArgumentException is thrown if one of the method parameters are invalid.
-
readRegisterCharBuffer
default CharBuffer readRegisterCharBuffer(int register, int offset, int numberOfBytes) throws IOReadException
Read ASCII data from the I2C device register up to a specified length (number of bytes) and return the data read in a new CharBuffer instance. The 'offset' parameter allows you to skip a certain number of bytes in the read data and excludes them from the returned character array. ASCII is the internal character set used to decode the bytes into chars.- Parameters:
offset
- the offset index in the raw bytes read to start fromnumberOfBytes
- the number of bytes to read (not number of characters)register
- a int.- Returns:
- a new character buffer (CharBuffer) containing the decoded character data read from the I2C device register.
- Throws:
IOReadException
- An com.pi4j.io.exception.IOReadException is thrown if a read access error code is returned from the underlying read() functions.IllegalArgumentException
- An java.lang.IllegalArgumentException is thrown if one of the method parameters are invalid.
-
readRegisterCharBuffer
default CharBuffer readRegisterCharBuffer(int register, int numberOfBytes) throws IOReadException
Read ASCII data from the I2C device register up to a specified length (number of bytes) and return the data read in a new CharBuffer instance. ASCII is the internal character set used to decode the bytes into chars.- Parameters:
numberOfBytes
- the number of bytes to read (not number of characters)register
- a int.- Returns:
- a new character buffer (CharBuffer) containing the decoded character data read from the I2C device register.
- Throws:
IOReadException
- An com.pi4j.io.exception.IOReadException is thrown if a read access error code is returned from the underlying read() functions.IllegalArgumentException
- An java.lang.IllegalArgumentException is thrown if one of the method parameters are invalid.
-
readRegisterString
default String readRegisterString(int register, Charset charset, int offset, int numberOfBytes) throws IOReadException
Read data from the I2C device registere up to a specified length (number of bytes) and return the data read in a new String instance. The 'offset' parameter allows you to skip a certain number of bytes in the read data and excludes them from the returned string.- Parameters:
charset
- character set to use for byte decodingoffset
- the offset index in the raw bytes read to start fromnumberOfBytes
- the number of bytes to read (not number of characters)register
- a int.- Returns:
- a new character buffer (CharBuffer) containing the decoded character data read from the I2C device register.
- Throws:
IOReadException
- An com.pi4j.io.exception.IOReadException is thrown if a read access error code is returned from the underlying read() functions.IllegalArgumentException
- An java.lang.IllegalArgumentException is thrown if one of the method parameters are invalid.
-
readRegisterString
default String readRegisterString(int register, Charset charset, int numberOfBytes)
Read data from the I2C device registere up to a specified length (number of bytes) and return the data read in a new String instance.- Parameters:
charset
- character set to use for byte decodingnumberOfBytes
- the number of bytes to read (not number of characters)register
- a int.- Returns:
- a new character buffer (CharBuffer) containing the decoded character data read from the I2C device register.
- Throws:
IllegalArgumentException
- An java.lang.IllegalArgumentException is thrown if one of the method parameters are invalid.
-
readRegisterString
default String readRegisterString(int register, int offset, int numberOfBytes)
Read ASCII data from the I2C device registere up to a specified length (number of bytes) and return the data read in a new String instance. The 'offset' parameter allows you to skip a certain number of bytes in the read data and excludes them from the returned string. ASCII is the internal character set used to decode the bytes into chars.- Parameters:
offset
- the offset index in the raw bytes read to start fromnumberOfBytes
- the number of bytes to read (not number of characters)register
- a int.- Returns:
- a new character buffer (CharBuffer) containing the decoded character data read from the I2C device register.
- Throws:
IllegalArgumentException
- An java.lang.IllegalArgumentException is thrown if one of the method parameters are invalid.
-
readRegisterString
default String readRegisterString(int register, int numberOfBytes) throws IOReadException
Read ASCII data from the I2C device registere up to a specified length (number of bytes) and return the data read in a new String instance. ASCII is the internal character set used to decode the bytes into chars.- Parameters:
numberOfBytes
- the number of bytes to read (not number of characters)register
- a int.- Returns:
- a new character buffer (CharBuffer) containing the decoded character data read from the I2C device register.
- Throws:
IOReadException
- An com.pi4j.io.exception.IOReadException is thrown if a read access error code is returned from the underlying read() functions.IllegalArgumentException
- An java.lang.IllegalArgumentException is thrown if one of the method parameters are invalid.
-
-