Module com.pi4j

Interface I2CRegisterDataWriter

  • All Known Subinterfaces:
    I2C, I2CRegisterDataReaderWriter
    All Known Implementing Classes:
    I2CBase

    public interface I2CRegisterDataWriter
    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
      default int write​(int register, InputStream stream, int length)
      Write a stream of stream of data up to the length (number of bytes) specified to a specific I2C device register.
      int writeRegister​(int register, byte b)
      Write a single raw byte (8-bit) value to the I2C device register.
      default int writeRegister​(int register, byte... data)
      Write an array of byte values to a specific I2C device register.
      default int writeRegister​(int register, byte[]... data)
      Write multiple byte arrays of data to a specific I2C device register.
      default int writeRegister​(int register, byte[] data, int length)
      Write an array of byte values starting with the first byte in the array up to the provided length to a specific I2C device register.
      int writeRegister​(int register, byte[] data, int offset, int length)
      Write a array of byte values with given offset (starting position) and length in the provided data array to a specific I2C device register.
      default int writeRegister​(int register, char... data)
      Writes an ASCII based character array (1 or more chars) to a specific I2C device register.
      default int writeRegister​(int register, char[] data, int length)
      Writes an ASCII based character array (1 or more chars) with a given length starting from the 0 index position to a specific I2C device register.
      default int writeRegister​(int register, char[] data, int offset, int length)
      Writes an ASCII based character array (1 or more chars) with a given offset and length to a specific I2C device register.
      default int writeRegister​(int register, int b)
      Write a single raw byte (8-bit) value to the I2C device register.
      default int writeRegister​(int register, InputStream stream)
      Write a stream of data bytes to a specific I2C device register.
      default int writeRegister​(int register, InputStream... stream)
      Write multiple streams of data bytes to a specific I2C device register.
      default int writeRegister​(int register, CharSequence data)
      Writes an ASCII data string/character sequence to a specific I2C device register.
      default int writeRegister​(int register, CharSequence... data)
      Writes multiple ASCII data strings/character sequences to a specific I2C device register.
      default int writeRegister​(int register, ByteBuffer buffer)
      Write a buffer of byte values (all bytes in buffer) to a specific I2C device register.
      default int writeRegister​(int register, ByteBuffer... buffer)
      Write multiple byte buffers to a specific I2C device register.
      default int writeRegister​(int register, ByteBuffer buffer, int length)
      Write a buffer of byte values starting from the first byte in the buffer up to the provided length to a specific I2C device register.
      default int writeRegister​(int register, ByteBuffer buffer, int offset, int length)
      Write a buffer of byte values starting from a given offset index in the array up to the provided length to a specific I2C device register.
      default int writeRegister​(int register, CharBuffer data)
      Writes an ASCII based character buffer to a specific I2C device register.
      default int writeRegister​(int register, CharBuffer... data)
      Writes an ASCII based character buffer to a specific I2C device register.
      default int writeRegister​(int register, CharBuffer data, int length)
      Writes an ASCII based character buffer starting at first index to a given length to a specific I2C device register.
      default int writeRegister​(int register, CharBuffer data, int offset, int length)
      Writes an ASCII based character buffer with a given offset and length to a specific I2C device register.
      default int writeRegister​(int register, Charset charset, char... data)
      Writes a character array (1 or more chars) to a specific I2C device register.
      default int writeRegister​(int register, Charset charset, char[] data, int length)
      Writes a character based array starting at the first index with a given length.
      default int writeRegister​(int register, Charset charset, char[] data, int offset, int length)
      Writes a character based array with a given offset and length.
      default int writeRegister​(int register, Charset charset, CharSequence data)
      Writes a data string with specified character set (encoding) to a specific I2C device register.
      default int writeRegister​(int register, Charset charset, CharSequence... data)
      Writes a data string with specified character set (encoding) to a specific I2C device register.
      default int writeRegister​(int register, Charset charset, CharBuffer buffer)
      Write a character buffer using a specified character set to encode the chars into bytes to a specific I2C device register.
      default int writeRegister​(int register, Charset charset, CharBuffer... data)
      Writes multiple character buffers using a specified character set to encode the chars into bytes to a specific I2C device register.
      default int writeRegister​(int register, Charset charset, CharBuffer buffer, int length)
      Write a character buffer starting at first index to a given length using a specified character set to encode the chars into bytes to a specific I2C device register.
      default int writeRegister​(int register, Charset charset, CharBuffer buffer, int offset, int length)
      Writes a character buffer with a given offset and length using a specified character set to encode the chars into bytes to a specific I2C device register.
      default int writeRegister​(int register, Charset charset, Collection<char[]> data)
      Write a collection of character arrays.
      default int writeRegister​(int register, Charset charset, Collection<CharSequence>... data)
      Write a collection of ASCII character sequences with specified character set (encoding) to a specific I2C device register.
      default int writeRegister​(int register, Collection<byte[]> data)
      Write a collection of byte arrays of data to a specific I2C device register.
      default int writeRegister​(int register, Collection<CharSequence>... data)
      Write a collection of ASCII character sequences to a specific I2C device register.
      default int writeRegisterWord​(int register, int word)
      Write a single word value (16-bit) to the I2C device register.
    • Method Detail

      • writeRegister

        int writeRegister​(int register,
                          byte b)
        Write a single raw byte (8-bit) value to the I2C device register.
        Parameters:
        register - the register address to write to
        b - byte to be written
        Returns:
        a int.
      • writeRegister

        default int writeRegister​(int register,
                                  int b)
        Write a single raw byte (8-bit) value to the I2C device register. (The integer value provided will be cast to a byte thus only using the lowest 8 bits)
        Parameters:
        register - the register address to write to
        b - byte to be written; the provided Integer wll be cast to a Byte.
        Returns:
        a int.
      • writeRegisterWord

        default int writeRegisterWord​(int register,
                                      int word)
        Write a single word value (16-bit) to the I2C device register.
        Parameters:
        register - the register address to write to
        word - 16-bit word value to be written
        Returns:
        a int.
      • writeRegister

        int writeRegister​(int register,
                          byte[] data,
                          int offset,
                          int length)
        Write a array of byte values with given offset (starting position) and length in the provided data array to a specific I2C device register.
        Parameters:
        register - the register address to write to
        data - data array of bytes to be written
        offset - offset in data buffer to start at
        length - number of bytes to be written
        Returns:
        The number of bytes written, possibly zero
      • writeRegister

        default int writeRegister​(int register,
                                  byte[] data,
                                  int length)
        Write an array of byte values starting with the first byte in the array up to the provided length to a specific I2C device register.
        Parameters:
        register - the register address to write to
        data - data array of bytes to be written
        length - number of bytes to be written
        Returns:
        The number of bytes written, possibly zero
      • writeRegister

        default int writeRegister​(int register,
                                  byte... data)
        Write an array of byte values to a specific I2C device register.
        Parameters:
        register - the register address to write to
        data - data to be written to the i2c device in one go
        Returns:
        The number of bytes written, possibly zero
      • writeRegister

        default int writeRegister​(int register,
                                  byte[]... data)
                           throws IOException
        Write multiple byte arrays of data to a specific I2C device register.
        Parameters:
        register - the register address to write to
        data - data to be written to the i2c device in one go
        Returns:
        The number of bytes written, possibly zero
        Throws:
        IOException - thrown on write error
      • writeRegister

        default int writeRegister​(int register,
                                  Collection<byte[]> data)
                           throws IOException
        Write a collection of byte arrays of data to a specific I2C device register.
        Parameters:
        register - the register address to write to
        data - data to be written to the i2c device in one go
        Returns:
        The number of bytes written, possibly zero
        Throws:
        IOException - thrown on write error
      • writeRegister

        default int writeRegister​(int register,
                                  ByteBuffer buffer,
                                  int offset,
                                  int length)
                           throws IOException
        Write a buffer of byte values starting from a given offset index in the array up to the provided length to a specific I2C device register. NOTE: The buffer's internal position tracking is no 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 read the number of bytes up to the buffers' available space.
        Parameters:
        register - the register address to write to
        buffer - byte buffer of data to be written to the i2c device in one go
        offset - offset in buffer
        length - number of bytes to be written
        Returns:
        The number of bytes written, possibly zero
        Throws:
        IOException - thrown on write error
      • writeRegister

        default int writeRegister​(int register,
                                  ByteBuffer buffer,
                                  int length)
                           throws IOException
        Write a buffer of byte values starting from the first byte in the buffer up to the provided length to a specific I2C device register. NOTE: The contents from the byte buffer is read from 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 flip the buffer to begin reading data from the zero position up to the buffer's limit.
        Parameters:
        register - the register address to write to
        buffer - byte buffer of data to be written
        length - number of bytes to be written
        Returns:
        The number of bytes written, possibly zero
        Throws:
        IOException - thrown on write error
      • writeRegister

        default int writeRegister​(int register,
                                  ByteBuffer buffer)
                           throws IOException
        Write a buffer of byte values (all bytes in buffer) to a specific I2C device register. NOTE: The contents from the byte buffer is read from 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 flip the buffer to begin reading data from the zero position up to the buffer's limit.
        Parameters:
        register - the register address to write to
        buffer - byte buffer of data to be written to the i2c device in one go
        Returns:
        The number of bytes written, possibly zero
        Throws:
        IOException - thrown on write error
      • writeRegister

        default int writeRegister​(int register,
                                  ByteBuffer... buffer)
                           throws IOException
        Write multiple byte buffers to a specific I2C device register. NOTE: The contents from each byte buffer is read from 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 flip the buffer to begin reading data from the zero position up to the buffer's limit.
        Parameters:
        register - the register address to write to
        buffer - byte buffer of data to be written to the i2c device in one go
        Returns:
        The number of bytes written, possibly zero
        Throws:
        IOException - thrown on write error
      • writeRegister

        default int writeRegister​(int register,
                                  InputStream stream)
                           throws IOException
        Write a stream of data bytes to a specific I2C device register.
        Parameters:
        register - the register address to write to
        stream - stream of data to be written
        Returns:
        The number of bytes written, possibly zero
        Throws:
        IOException - thrown on write error
      • write

        default int write​(int register,
                          InputStream stream,
                          int length)
                   throws IOException
        Write a stream of stream of data up to the length (number of bytes) specified to a specific I2C device register.
        Parameters:
        register - the register address to write to
        stream - stream of data to be written
        length - number of bytes to be written
        Returns:
        The number of bytes written, possibly zero
        Throws:
        IOException - thrown on write error
      • writeRegister

        default int writeRegister​(int register,
                                  InputStream... stream)
                           throws IOException
        Write multiple streams of data bytes to a specific I2C device register.
        Parameters:
        register - the register address to write to
        stream - stream of data to be written
        Returns:
        The number of bytes written, possibly zero
        Throws:
        IOException - thrown on write error
      • writeRegister

        default int writeRegister​(int register,
                                  Charset charset,
                                  CharSequence data)
                           throws IOException
        Writes a data string with specified character set (encoding) to a specific I2C device register.
        Parameters:
        register - the register address to write to
        charset - character set to use for byte encoding
        data - string data (US_ASCII) to be written
        Returns:
        The number of bytes written, possibly zero
        Throws:
        IOException - thrown on write error
      • writeRegister

        default int writeRegister​(int register,
                                  Charset charset,
                                  CharSequence... data)
                           throws IOException
        Writes a data string with specified character set (encoding) to a specific I2C device register.
        Parameters:
        register - the register address to write to
        charset - character set to use for byte encoding
        data - string data (US_ASCII) to be written
        Returns:
        The number of bytes written, possibly zero
        Throws:
        IOException - thrown on write error
      • writeRegister

        default int writeRegister​(int register,
                                  Charset charset,
                                  Collection<CharSequence>... data)
                           throws IOException
        Write a collection of ASCII character sequences with specified character set (encoding) to a specific I2C device register.
        Parameters:
        register - the register address to write to
        charset - character set to use for byte encoding
        data - collection of character sequences of data to be written
        Returns:
        The number of bytes written, possibly zero
        Throws:
        IOException - thrown on write error
      • writeRegister

        default int writeRegister​(int register,
                                  CharSequence data)
                           throws IOException
        Writes an ASCII data string/character sequence to a specific I2C device register.
        Parameters:
        register - the register address to write to
        data - string data (US_ASCII) to be written
        Returns:
        The number of bytes written, possibly zero
        Throws:
        IOException - thrown on write error
      • writeRegister

        default int writeRegister​(int register,
                                  CharSequence... data)
                           throws IOException
        Writes multiple ASCII data strings/character sequences to a specific I2C device register.
        Parameters:
        register - the register address to write to
        data - string data (US_ASCII) to be written
        Returns:
        The number of bytes written, possibly zero
        Throws:
        IOException - thrown on write error
      • writeRegister

        default int writeRegister​(int register,
                                  Collection<CharSequence>... data)
                           throws IOException
        Write a collection of ASCII character sequences to a specific I2C device register.
        Parameters:
        register - the register address to write to
        data - collection of character sequences of data to be written
        Returns:
        The number of bytes written, possibly zero
        Throws:
        IOException - thrown on write error
      • writeRegister

        default int writeRegister​(int register,
                                  char[] data,
                                  int offset,
                                  int length)
                           throws IOException
        Writes an ASCII based character array (1 or more chars) with a given offset and length to a specific I2C device register.
        Parameters:
        register - the register address to write to
        data - ASCII character array used for data write
        offset - offset in data character array to start at
        length - number of character in character array to be written
        Returns:
        The number of bytes (not characters) written, possibly zero
        Throws:
        IOException - thrown on write error
      • writeRegister

        default int writeRegister​(int register,
                                  char[] data,
                                  int length)
                           throws IOException
        Writes an ASCII based character array (1 or more chars) with a given length starting from the 0 index position to a specific I2C device register.
        Parameters:
        register - the register address to write to
        data - ASCII character array used for data write
        length - number of character in character array to be written
        Returns:
        The number of bytes (not characters) written, possibly zero
        Throws:
        IOException - thrown on write error
      • writeRegister

        default int writeRegister​(int register,
                                  char... data)
                           throws IOException
        Writes an ASCII based character array (1 or more chars) to a specific I2C device register.
        Parameters:
        register - the register address to write to
        data - ASCII character array used for data write
        Returns:
        The number of bytes (not characters) written, possibly zero
        Throws:
        IOException - thrown on write error
      • writeRegister

        default int writeRegister​(int register,
                                  Charset charset,
                                  char[] data,
                                  int offset,
                                  int length)
                           throws IOException
        Writes a character based array with a given offset and length. Specify the encoding to be used to encode the chars into bytes to a specific I2C device register.
        Parameters:
        register - the register address to write to
        charset - character set to use for byte encoding
        data - ASCII character array used for data write
        offset - offset in data character array to start at
        length - number of character in character array to be written
        Returns:
        The number of bytes (not characters) written, possibly zero
        Throws:
        IOException - thrown on write error
      • writeRegister

        default int writeRegister​(int register,
                                  Charset charset,
                                  char[] data,
                                  int length)
                           throws IOException
        Writes a character based array starting at the first index with a given length. Specify the encoding to be used to encode the chars into bytes to a specific I2C device register.
        Parameters:
        register - the register address to write to
        charset - character set to use for byte encoding
        data - ASCII character array used for data write
        length - number of character in character array to be written
        Returns:
        The number of bytes (not characters) written, possibly zero
        Throws:
        IOException - thrown on write error
      • writeRegister

        default int writeRegister​(int register,
                                  Charset charset,
                                  char... data)
                           throws IOException
        Writes a character array (1 or more chars) to a specific I2C device register.
        Parameters:
        register - the register address to write to
        data - character array (1 or more chars) to be written
        charset - character set to use for byte encoding
        Returns:
        The number of bytes written, possibly zero
        Throws:
        IOException - thrown on write error
      • writeRegister

        default int writeRegister​(int register,
                                  Charset charset,
                                  Collection<char[]> data)
                           throws IOException
        Write a collection of character arrays. Specify the encoding to be used to encode the chars into bytes to a specific I2C device register.
        Parameters:
        register - the register address to write to
        data - collection of character sequences of data to be written
        charset - a Charset object.
        Returns:
        The number of bytes written, possibly zero
        Throws:
        IOException - thrown on write error
      • writeRegister

        default int writeRegister​(int register,
                                  CharBuffer data,
                                  int offset,
                                  int length)
                           throws IOException
        Writes an ASCII based character buffer with a given offset and length to a specific I2C device register.
        Parameters:
        register - the register address to write to
        data - ASCII character array used for data write
        offset - offset in data character array to start at
        length - number of character in character array to be written
        Returns:
        The number of bytes (not characters) written, possibly zero
        Throws:
        IOException - thrown on write error
      • writeRegister

        default int writeRegister​(int register,
                                  CharBuffer data,
                                  int length)
                           throws IOException
        Writes an ASCII based character buffer starting at first index to a given length to a specific I2C device register.
        Parameters:
        register - the register address to write to
        data - ASCII character array used for data write
        length - number of character in character array to be written
        Returns:
        The number of bytes (not characters) written, possibly zero
        Throws:
        IOException - thrown on write error
      • writeRegister

        default int writeRegister​(int register,
                                  CharBuffer data)
                           throws IOException
        Writes an ASCII based character buffer to a specific I2C device register.
        Parameters:
        register - the register address to write to
        data - ASCII character array used for data write
        Returns:
        The number of bytes (not characters) written, possibly zero
        Throws:
        IOException - thrown on write error
      • writeRegister

        default int writeRegister​(int register,
                                  CharBuffer... data)
                           throws IOException
        Writes an ASCII based character buffer to a specific I2C device register.
        Parameters:
        register - the register address to write to
        data - ASCII character array used for data write
        Returns:
        The number of bytes (not characters) written, possibly zero
        Throws:
        IOException - thrown on write error
      • writeRegister

        default int writeRegister​(int register,
                                  Charset charset,
                                  CharBuffer buffer,
                                  int offset,
                                  int length)
                           throws IOException
        Writes a character buffer with a given offset and length using a specified character set to encode the chars into bytes to a specific I2C device register. NOTE: The buffer's internal position tracking is no 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 read the number of characters up to the buffers' available space.
        Parameters:
        register - the register address to write to
        charset - character set to use for byte encoding
        buffer - character buffer used for data write
        offset - offset in data character array to start at
        length - number of character in character array to be written
        Returns:
        The number of bytes (not characters) written, possibly zero
        Throws:
        IOException - thrown on write error
      • writeRegister

        default int writeRegister​(int register,
                                  Charset charset,
                                  CharBuffer buffer,
                                  int length)
                           throws IOException
        Write a character buffer starting at first index to a given length using a specified character set to encode the chars into bytes to a specific I2C device register. NOTE: The contents from the character buffer is read from 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 flip the buffer to begin reading data from the zero position up to the buffer's limit.
        Parameters:
        register - the register address to write to
        charset - character set to use for byte encoding
        buffer - character buffer used for data write
        length - number of character in character array to be written
        Returns:
        The number of bytes (not characters) written, possibly zero
        Throws:
        IOException - thrown on write error
      • writeRegister

        default int writeRegister​(int register,
                                  Charset charset,
                                  CharBuffer buffer)
                           throws IOException
        Write a character buffer using a specified character set to encode the chars into bytes to a specific I2C device register. NOTE: The contents from the character buffer is read from 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 flip the buffer to begin reading data from the zero position up to the buffer's limit.
        Parameters:
        register - the register address to write to
        charset - character set to use for byte encoding
        buffer - character array used for data write
        Returns:
        The number of bytes (not characters) written, possibly zero
        Throws:
        IOException - thrown on write error
      • writeRegister

        default int writeRegister​(int register,
                                  Charset charset,
                                  CharBuffer... data)
                           throws IOException
        Writes multiple character buffers using a specified character set to encode the chars into bytes to a specific I2C device register. NOTE: The contents from each character buffer is read from 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 flip the buffer to begin reading data from the zero position up to the buffer's limit.
        Parameters:
        register - the register address to write to
        charset - character set to use for byte encoding
        data - ASCII character array used for data write
        Returns:
        The number of bytes (not characters) written, possibly zero
        Throws:
        IOException - thrown on write error