int read()
Throws:
int read(boolean sendNACK)
Throws:
int read(byte[] buf)
Throws:
int read(byte[] buf, boolean sendNACK)
Throws:
int read(byte[] buf, int offset, int len)
Throws:
int read(byte[] buf, int offset, int len, boolean sendNACK)
Throws:
_INSERT_METHOD_SIGNATURE_HERE_
Description:
The read method reads data from an I2C slave device when the iLCD-controllerJoC board is in master mode or from an I2C master device when the iLCD-controllerJoC board is in slave mode. Slave mode can be set via the I2C-constructor.
Parameter | Description |
---|---|
dest | array storing the returned data |
offs | offset of bytes |
len | count of bytes |
sendNACK | Send NACK after len bytes in slave mode |
int read() method:
Returns | Description |
---|---|
data | returns one byte as int or -1 if no data was read |
int read(boolean sendNACK) method:
Returns | Description |
---|---|
data | returns one byte as int or -1 if no data was read |
When sendNACK is true in slave mode, NACK will be returned instead of ACK after the last byte received (default value is false). Note that the sendNACK parameter will be ignored in master mode (obligatory NACK after last received byte).
int read(byte[] buf) method:
Returns | Description |
---|---|
nr_of_bytes | returns number of bytes successfully received |
The parameter buf is used to store the received data bytes. The number of data bytes to be received is specified by buf.length. Note that the number of actually received bytes might be smaller then len.
int read(byte[] buf, boolean sendNACK) method:
Returns | Description |
---|---|
nr_of_bytes | returns number of bytes successfully received |
The first parameter buf is used to store the received data bytes. The number of data bytes to be received is specified by buf.length. Note that the number of actually received bytes might be smaller then len. When sendNACK is true in slave mode, NACK will be returned instead of ACK after the last byte received (default value is false). Note that the sendNACK parameter will be ignored in master mode (obligatory NACK after last received byte).
int read(byte[] buf, int offset, int len) method:
Returns | Description |
---|---|
nr_of_bytes | returns number of bytes successfully received |
The first parameter buf is used to store the received data bytes. The number of data bytes to be received is specified by the len parameter. Note that the number of actually received bytes might be smaller then len. The offset paramter specifies the offest in the buf array.
int read(byte[] buf, int offset, int len, boolean sendNACK) method:
Returns | Description |
---|---|
nr_of_bytes | returns number of bytes successfully received |
The first parameter buf is used to store the received data bytes. The number of data bytes to be received is specified by the len parameter. Note that the number of actually received bytes might be smaller then len. The offset paramter specifies the offest in the buf array. When sendNACK is true in slave mode, NACK will be returned instead of ACK after the last byte received (default value is false). Note that the sendNACK parameter will be ignored in master mode (obligatory NACK after last received byte).
Note
Example
A typical sequence for reading a slave device might look like this:
byte[] data = new byte[2];
try
{
i2c.start();
write((byte) SI7021_MEASRH_NOHOLD_CMD);
i2c.reStart();
delay(25);
ret = i2c.read(data);
i2c.stop();
}
catch(Exception exc)
{
Console.println(exc.getMessage());
}
See also:
Copyright © demmel products gmbh. All rights reserved.