|
Oracle Java Wireless Client | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface I2CSlave
The I2CSlave
interface provides methods for sending and receiving
data to/from an I2C slave device.
I2CSlave
instance can be acquired by a call to I2CManager.getSlave(int)
or I2CManager.getSlave(java.lang.String)
.
On an I2C bus, data is transferred between the I2C master device and an I2C slave device
through single or combined messages:
I2CSlave.close()
method
to release the I2C slave. Any further attempt to transmit/write or receive/read to/from an I2C slave which has been
released will result in a PeripheralNotAvailableException
been thrown.
Note that the appropriate I2C clock frequency... for exchanging data with a particular I2C slave device are set by
the platform.
I2CManager
,
I2CPermission
,
PeripheralNotAvailableException
Method Summary | |
int |
read()
Reads one byte of data from this slave device. |
int |
read(byte[] rxBuf,
int rxOff,
int rxLen)
Reads up to rxLen bytes of data from this slave device into an array of bytes. |
int |
read(int rxSkip,
byte[] rxBuf,
int rxOff,
int rxLen)
Reads up to rxLen bytes of data from this slave device into an array of bytes
skipping the first rxSkip bytes read. |
void |
write(byte[] txBuf,
int txOff,
int txLen)
Writes to this slave device txLen bytes from buffer txBuf . |
void |
write(int txData)
Writes one byte to this slave device. |
int |
writeThenRead(byte[] txBuf,
int txOff,
int txLen,
byte[] rxBuf,
int rxOff,
int rxLen)
Writes to this slave device up to txLen bytes from the buffer txBuf
then reads into the buffer rxBuf up to rxLen bytes
from this slave device. |
int |
writeThenRead(byte[] txBuf,
int txOff,
int txLen,
int rxSkip,
byte[] rxBuf,
int rxOff,
int rxLen)
Writes to this slave device up to txLen bytes from the buffer txBuf
then reads into the buffer rxBuf up to rxLen bytes
from this slave device skipping the first rxSkip bytes read. |
Methods inherited from interface com.oracle.deviceaccess.Peripheral |
close, getID, getName |
Method Detail |
int read() throws java.io.IOException, PeripheralNotAvailableException
int
in the range 0
to 255
.
java.io.IOException
- if an I/O error occurs.
PeripheralNotAvailableException
- if the peripheral is not currently available (has been released).int read(byte[] rxBuf, int rxOff, int rxLen) throws java.io.IOException, PeripheralNotAvailableException
rxLen
bytes of data from this slave device into an array of bytes.
rxBuf
- the buffer into which the data is read.rxOff
- the offset in rxBuf
where to start copying the bytes read.rxLen
- the maximum number of bytes to read.
java.io.IOException
- if an IO error occurred.
java.lang.NullPointerException
- If rxBuf
is null
.
java.lang.IndexOutOfBoundsException
- rxOff
or rxLen
points
or results in pointing outside rxBuf
.
PeripheralNotAvailableException
- if the peripheral is not currently available (has been released).int read(int rxSkip, byte[] rxBuf, int rxOff, int rxLen) throws java.io.IOException, PeripheralNotAvailableException
rxLen
bytes of data from this slave device into an array of bytes
skipping the first rxSkip
bytes read.
rxSkip
- the number of read bytes that must be ignored/skipped before filling in the rxBuf
buffer.rxBuf
- the buffer into which the data is read.rxOff
- the offset in rxBuf
where to start copying the bytes read.rxLen
- the maximum number of bytes to read.
java.io.IOException
- if an IO error occurred.
java.lang.NullPointerException
- If rxBuf
is null
.
java.lang.IndexOutOfBoundsException
- rxOff
or rxLen
points
or results in pointing outside rxBuf
.
PeripheralNotAvailableException
- if the peripheral is not currently available (has been released).void write(int txData) throws java.io.IOException, PeripheralNotAvailableException
data
are written.
The 24 high-order bits of txData
are ignored.
txData
- the byte to be written
java.io.IOException
- if an I/O error occurred
PeripheralNotAvailableException
void write(byte[] txBuf, int txOff, int txLen) throws java.io.IOException, PeripheralNotAvailableException
txLen
bytes from buffer txBuf
.
txBuf
- the buffer containing the bytes to write.txOff
- the offset in txBuf
of the first byte to write.txLen
- the number of bytes from txBuf
to write.
java.io.IOException
- if an IO error occurred.
java.lang.NullPointerException
- If txBuf
is null
.
java.lang.IndexOutOfBoundsException
- txOff
or txLen
points
or results in pointing outside txBuf
.
PeripheralNotAvailableException
- if the peripheral is not currently available (has been released).int writeThenRead(byte[] txBuf, int txOff, int txLen, byte[] rxBuf, int rxOff, int rxLen) throws java.io.IOException, PeripheralNotAvailableException
txLen
bytes from the buffer txBuf
then reads into the buffer rxBuf
up to rxLen
bytes
from this slave device.
This uses a combined message form of I2C communication where a command is written
to the I2C slave device and corresponding response is read.
txBuf
- the buffer containing the bytes to write (usually an address or command).txOff
- the offset in txBuf
of the first byte to write.txLen
- the number of bytes from txBuf
to write.rxBuf
- the buffer into which the data is read.rxOff
- the offset in rxBuf
where to start copying the bytes read.rxLen
- the number of bytes to read.
rxBuf
.
java.io.IOException
- if an IO error occurred.
java.lang.NullPointerException
- If txBuf
or rxBuf
is null
.
java.lang.IndexOutOfBoundsException
- txOff
, txLen
, rxOff
or rxLen
points
or results in pointing outside txBuf
or rxBuf
.
PeripheralNotAvailableException
- if the peripheral is not currently available (has been released).int writeThenRead(byte[] txBuf, int txOff, int txLen, int rxSkip, byte[] rxBuf, int rxOff, int rxLen) throws java.io.IOException, PeripheralNotAvailableException
txLen
bytes from the buffer txBuf
then reads into the buffer rxBuf
up to rxLen
bytes
from this slave device skipping the first rxSkip
bytes read.
This uses a combined message form of I2C communication where a command is written
to the I2C slave device and corresponding response is read.
txBuf
- the buffer containing the bytes to write (usually an address or command).txOff
- the offset in txBuf
of the first byte to write.txLen
- the number of bytes from txBuf
to write.rxSkip
- the number of read bytes that must be ignored/skipped before filling in the rxBuf
buffer.rxBuf
- the buffer into which the data is read.rxOff
- the offset in rxBuf
where to start copying the bytes read.rxLen
- the number of bytes to read.
rxBuf
.
java.io.IOException
- if an IO error occurred.
java.lang.NullPointerException
- If txBuf
or rxBuf
is null
.
java.lang.IndexOutOfBoundsException
- txOff
, txLen
, rxOff
or rxLen
points
or results in pointing outside txBuf
or rxBuf
.
PeripheralNotAvailableException
- if the peripheral is not currently available (has been released).
|
Oracle Java Wireless Client | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |