|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.motorola.oem.i2c.I2CDatagram
public class I2CDatagram
Holder of data to be sent or received from I2CdatagramConnection.I2CDatagram consists of two parts:
reset()
may be called to reset the read/write point back to the beginning of the buffer.
Field Summary | |
---|---|
static int |
ADDRESS_MODE_10_BITS
Specifies 10 bits address mode. |
static int |
ADDRESS_MODE_7_BITS
Specifies 7 bits address mode. |
static int |
START_TYPE_BIT
Specifies end point with bit start type. |
static int |
START_TYPE_BYTE
Specifies end point with byte start type. |
Method Summary | |
---|---|
void |
enableReceiveStartBit(boolean flag)
Enable or disable the start bit in receive. |
void |
enableReceiveStopBit(boolean flag)
Enable or disable the stop bit in receive. |
java.lang.String |
getAddress()
Gets the address from the datagram header (device address and register address). |
byte[] |
getData()
Gets the data buffer. |
int |
getDeviceAddressType()
Gets the device's address type from the datagram header. |
int |
getLength()
Gets the length of the data buffer. |
int |
getOffset()
Gets the offset of the data buffer. |
int |
getRegisterAddressLen()
Gets the register's address length from the datagram header. |
int |
getStartType()
Gets the start type from the datagram header. |
int |
read()
|
boolean |
readBoolean()
See the general contract of the readBoolean
method of DataInput . |
byte |
readByte()
See the general contract of the readByte
method of DataInput . |
char |
readChar()
See the general contract of the readChar
method of DataInput . |
double |
readDouble()
See the general contract of the readDouble
method of DataInput . |
float |
readFloat()
See the general contract of the readFloat
method of DataInput . |
void |
readFully(byte[] b)
See the general contract of the readFully
method of DataInput . |
void |
readFully(byte[] b,
int off,
int len)
See the general contract of the readFully
method of DataInput . |
int |
readInt()
See the general contract of the readInt
method of DataInput . |
long |
readLong()
See the general contract of the readLong
method of DataInput . |
short |
readShort()
See the general contract of the readShort
method of DataInput . |
int |
readUnsignedByte()
See the general contract of the readUnsignedByte
method of DataInput . |
int |
readUnsignedShort()
See the general contract of the readUnsignedShort
method of DataInput . |
java.lang.String |
readUTF()
See the general contract of the readUTF
method of DataInput . |
void |
reset()
Zero the read/write pointer, offset and length parameters of the data buffer. |
void |
setAddress(javax.microedition.io.Datagram reference)
Sets address in the datagram header (device address and register address), copying the address from another datagram. |
void |
setAddress(java.lang.String addr)
Sets the address in the datagram header (device address and register address). |
void |
setData(byte[] buf,
int off,
int len)
Sets the buffer, offset and length. |
void |
setDeviceAddressType(int deviceAddrType)
Sets the device's address type in the datagram header. |
void |
setLength(int len)
Sets the data buffer's length. |
void |
setRegisterAddressLen(int registerAddrLen)
Sets the register's address's length, in bytes, in the datagram header. |
void |
setStartType(int startType)
Sets the start type in the datagram header. |
int |
skipBytes(int n)
See the general contract of the skipBytes
method of DataInput . |
void |
write(byte[] b)
Writes to the output stream all the bytes in array b . |
void |
write(byte[] b,
int off,
int len)
Writes len bytes from array
b , in order, to
the output stream. |
void |
write(int b)
Writes to the output stream the eight low-order bits of the argument b . |
void |
writeBoolean(boolean v)
Writes a boolean value to this output stream. |
void |
writeByte(int v)
Writes to the output stream the eight low- order bits of the argument v . |
void |
writeChar(int v)
Writes a char value, wich
is comprised of two bytes, to the
output stream. |
void |
writeChars(java.lang.String s)
Writes every character in the string s ,
to the output stream, in order,
two bytes per character. |
void |
writeDouble(double d)
See the general contract of the writeDouble
method of DataOutput . |
void |
writeFloat(float f)
See the general contract of the writeFloat
method of DataOutput . |
void |
writeInt(int v)
Writes an int value, which is
comprised of four bytes, to the output stream. |
void |
writeLong(long v)
Writes an long value, which is
comprised of four bytes, to the output stream. |
void |
writeShort(int v)
Writes two bytes to the output stream to represent the value of the argument. |
void |
writeUTF(java.lang.String str)
Writes two bytes of length information to the output stream, followed by the Java modified UTF representation of every character in the string s . |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int ADDRESS_MODE_7_BITS
public static final int ADDRESS_MODE_10_BITS
public static final int START_TYPE_BYTE
public static final int START_TYPE_BIT
Method Detail |
---|
public void enableReceiveStartBit(boolean flag)
flag
- - TRUE - Enable the start bit in receive method.public void enableReceiveStopBit(boolean flag)
flag
- - TRUE - Enable the stop bit in receive method.public java.lang.String getAddress()
getAddress
in interface javax.microedition.io.Datagram
setAddress(java.lang.String)
public byte[] getData()
getData
in interface javax.microedition.io.Datagram
setData(byte[], int, int)
public int getOffset()
getOffset
in interface javax.microedition.io.Datagram
public int getLength()
getLength
in interface javax.microedition.io.Datagram
public void setAddress(java.lang.String addr) throws java.io.IOException
"I2C://"[device address]:[register address]The device address and register address must be in a Hexadecimal representation. Any of the addresses may be omitted. If the register address is omitted, it will not be used while referring the target.
I2C://0x01:0x88Example 2 - device address is set to 0x01, while register address is absent:
I2C://0x01:Note: if the device address of an I2Cdatagram is not specified, the user will not be able to send or receive any data.
setAddress
in interface javax.microedition.io.Datagram
addr
- The string's scheme.
java.io.IOException
- I/O error.java.lang.IllegalArgumentException
- Either the addresses are invalid or the receive scheme is incorrect.getAddress()
public void setAddress(javax.microedition.io.Datagram reference)
setAddress
in interface javax.microedition.io.Datagram
reference
- The datagram who's addresses will be copied as the new target address for this datagram.
java.lang.IllegalArgumentException
- Address is invalid.getAddress()
public void setData(byte[] buf, int off, int len)
setData
in interface javax.microedition.io.Datagram
buf
- data bufferoff
- data buffer's offsetlen
- data buffer's length
java.lang.IllegalArgumentException
- Length or offset exceeds the buffer.getData()
public void setLength(int len)
setLength
in interface javax.microedition.io.Datagram
len
- The new length of the data buffer.
java.lang.IllegalArgumentException
- Length is either negative or exceeding the buffer.getLength()
public void reset()
reset
in interface javax.microedition.io.Datagram
public int getDeviceAddressType()
ADDRESS_MODE_7_BITS
,ADDRESS_MODE_10_BITS
.public void setDeviceAddressType(int deviceAddrType)
deviceAddrType
- The device's address Type.ADDRESS_MODE_7_BITS
,ADDRESS_MODE_10_BITS
.java.lang.IllegalArgumentException
- Parameter is out of range.public void setStartType(int startType)
startType
- The start type.START_TYPE_BYTE
,START_TYPE_BIT
.java.lang.IllegalArgumentException
- Parameter is out of range.public int getStartType()
START_TYPE_BYTE
,START_TYPE_BIT
.public void setRegisterAddressLen(int registerAddrLen)
registerAddrLen
- Register's address length.java.lang.IllegalArgumentException
- Parameters is out of range.public int getRegisterAddressLen()
public final int read() throws java.io.IOException
java.io.IOException
public final void readFully(byte[] b) throws java.io.IOException
readFully
method of DataInput
.
Bytes for this operation are read from the contained input stream.
readFully
in interface java.io.DataInput
b
- the buffer into which the data is read.
java.io.EOFException
- if this input stream reaches the end before
reading all the bytes.
java.io.IOException
- if an I/O error occurs.public final void readFully(byte[] b, int off, int len) throws java.io.IOException
readFully
method of DataInput
.
Bytes for this operation are read from the contained input stream.
readFully
in interface java.io.DataInput
b
- the buffer into which the data is read.off
- the start offset of the data.len
- the number of bytes to read.
java.io.EOFException
- if this input stream reaches the end before
reading all the bytes.
java.io.IOException
- if an I/O error occurs.public final int skipBytes(int n) throws java.io.IOException
skipBytes
method of DataInput
.
Bytes for this operation are read from the contained input stream.
skipBytes
in interface java.io.DataInput
n
- the number of bytes to be skipped.
java.io.IOException
- if an I/O error occurs.public final double readDouble() throws java.io.IOException
readDouble
method of DataInput
.
Bytes for this operation are read from the contained input stream.
readDouble
in interface java.io.DataInput
double
value read.
java.io.EOFException
- if this input stream has reached the end.
java.io.IOException
- if an I/O error occurs.public final float readFloat() throws java.io.IOException
readFloat
method of DataInput
.
Bytes for this operation are read from the contained input stream.
readFloat
in interface java.io.DataInput
float
value read.
java.io.EOFException
- if this input stream has reached the end.
java.io.IOException
- if an I/O error occurs.public final void writeDouble(double d) throws java.io.IOException
writeDouble
method of DataOutput
.
Bytes for this operation are write to the contained output stream.
writeDouble
in interface java.io.DataOutput
java.io.IOException
- if an I/O error occurs.public final void writeFloat(float f) throws java.io.IOException
writeFloat
method of DataOutput
.
Bytes for this operation are write to the contained output stream.
writeFloat
in interface java.io.DataOutput
java.io.IOException
- if an I/O error occurs.public final boolean readBoolean() throws java.io.IOException
readBoolean
method of DataInput
.
Bytes for this operation are read from the contained input stream.
readBoolean
in interface java.io.DataInput
boolean
value read.
java.io.EOFException
- if this input stream has reached the end.
java.io.IOException
public final byte readByte() throws java.io.IOException
readByte
method of DataInput
.
Bytes for this operation are read from the contained input stream.
readByte
in interface java.io.DataInput
byte
.
java.io.EOFException
- if this input stream has reached the end.
java.io.IOException
- if an I/O error occurs.public final int readUnsignedByte() throws java.io.IOException
readUnsignedByte
method of DataInput
.
Bytes for this operation are read from the contained input stream.
readUnsignedByte
in interface java.io.DataInput
java.io.EOFException
- if this input stream has reached the end.
java.io.IOException
- if an I/O error occurs.public final short readShort() throws java.io.IOException
readShort
method of DataInput
.
Bytes for this operation are read from the contained input stream.
readShort
in interface java.io.DataInput
java.io.EOFException
- if this input stream reaches the end before
reading two bytes.
java.io.IOException
- if an I/O error occurs.public final int readUnsignedShort() throws java.io.IOException
readUnsignedShort
method of DataInput
.
Bytes for this operation are read from the contained input stream.
readUnsignedShort
in interface java.io.DataInput
java.io.EOFException
- if this input stream reaches the end before
reading two bytes.
java.io.IOException
- if an I/O error occurs.public final char readChar() throws java.io.IOException
readChar
method of DataInput
.
Bytes for this operation are read from the contained input stream.
readChar
in interface java.io.DataInput
java.io.EOFException
- if this input stream reaches the end before
reading two bytes.
java.io.IOException
- if an I/O error occurs.public final int readInt() throws java.io.IOException
readInt
method of DataInput
.
Bytes for this operation are read from the contained input stream.
readInt
in interface java.io.DataInput
int
.
java.io.EOFException
- if this input stream reaches the end before
reading four bytes.
java.io.IOException
- if an I/O error occurs.public final long readLong() throws java.io.IOException
readLong
method of DataInput
.
Bytes for this operation are read from the contained input stream.
readLong
in interface java.io.DataInput
long
.
java.io.EOFException
- if this input stream reaches the end before
reading eight bytes.
java.io.IOException
- if an I/O error occurs.public final java.lang.String readUTF() throws java.io.IOException
readUTF
method of DataInput
.
Bytes for this operation are read from the contained input stream.
readUTF
in interface java.io.DataInput
java.io.EOFException
- if this input stream reaches the end before
reading all the bytes.
java.io.IOException
- if an I/O error occurs.DataInputStream.readUTF(java.io.DataInput)
public final void write(int b) throws java.io.IOException
b
.
The 24 high-order bits of b
are ignored.
write
in interface java.io.DataOutput
b
- the byte to be written.
java.io.IOException
- if an I/O error occurs.public void write(byte[] b) throws java.io.IOException
b
.
If b
is null
,
a NullPointerException
is thrown.
If b.length
is zero, then
no bytes are written. Otherwise, the byte
b[0]
is written first, then
b[1]
, and so on; the last byte
written is b[b.length-1]
.
write
in interface java.io.DataOutput
b
- the data.
java.io.IOException
- if an I/O error occurs.public final void write(byte[] b, int off, int len) throws java.io.IOException
len
bytes from array
b
, in order, to
the output stream. If b
is null
, a NullPointerException
is thrown. If off
is negative,
or len
is negative, or off+len
is greater than the length of the array
b
, then an IndexOutOfBoundsException
is thrown. If len
is zero,
then no bytes are written. Otherwise, the
byte b[off]
is written first,
then b[off+1]
, and so on; the
last byte written is b[off+len-1]
.
write
in interface java.io.DataOutput
b
- the data.off
- the start offset in the data.len
- the number of bytes to write.
java.io.IOException
- if an I/O error occurs.public void writeBoolean(boolean v) throws java.io.IOException
boolean
value to this output stream.
If the argument v
is true
, the value (byte)1
is written; if v
is false
,
the value (byte)0
is written.
The byte written by this method may
be read by the readBoolean
method of interface DataInput
,
which will then return a boolean
equal to v
.
writeBoolean
in interface java.io.DataOutput
v
- the boolean to be written.
java.io.IOException
- if an I/O error occurs.public void writeByte(int v) throws java.io.IOException
v
.
The 24 high-order bits of v
are ignored. (This means that writeByte
does exactly the same thing as write
for an integer argument.) The byte written
by this method may be read by the readByte
method of interface DataInput
,
which will then return a byte
equal to (byte)v
.
writeByte
in interface java.io.DataOutput
v
- the byte value to be written.
java.io.IOException
- if an I/O error occurs.public void writeShort(int v) throws java.io.IOException
(byte)(0xff & (v >> 8))
(byte)(0xff & v)
The bytes written by this method may be
read by the readShort
method
of interface DataInput
, which
will then return a short
equal
to (short)v
.
writeShort
in interface java.io.DataOutput
v
- the short
value to be written.
java.io.IOException
- if an I/O error occurs.public void writeChar(int v) throws java.io.IOException
char
value, wich
is comprised of two bytes, to the
output stream.
The byte values to be written, in the order
shown, are:
(byte)(0xff & (v >> 8))
(byte)(0xff & v)
The bytes written by this method may be
read by the readChar
method
of interface DataInput
, which
will then return a char
equal
to (char)v
.
writeChar
in interface java.io.DataOutput
v
- the char
value to be written.
java.io.IOException
- if an I/O error occurs.public void writeInt(int v) throws java.io.IOException
int
value, which is
comprised of four bytes, to the output stream.
The byte values to be written, in the order
shown, are:
(byte)(0xff & (v >> 24))
(byte)(0xff & (v >> 16))
(byte)(0xff & (v >> 8))
(byte)(0xff & v)
The bytes written by this method may be read
by the readInt
method of interface
DataInput
, which will then
return an int
equal to v
.
writeInt
in interface java.io.DataOutput
v
- the int
value to be written.
java.io.IOException
- if an I/O error occurs.public void writeLong(long v) throws java.io.IOException
long
value, which is
comprised of four bytes, to the output stream.
The byte values to be written, in the order
shown, are:
(byte)(0xff & (v >> 48))
(byte)(0xff & (v >> 40))
(byte)(0xff & (v >> 32))
(byte)(0xff & (v >> 24))
(byte)(0xff & (v >> 16))
(byte)(0xff & (v >> 8))
(byte)(0xff & v)
The bytes written by this method may be
read by the readLong
method
of interface DataInput
, which
will then return a long
equal
to v
.
writeLong
in interface java.io.DataOutput
v
- the long
value to be written.
java.io.IOException
- if an I/O error occurs.public void writeChars(java.lang.String s) throws java.io.IOException
s
,
to the output stream, in order,
two bytes per character. If s
is null
, a NullPointerException
is thrown. If s.length
is zero, then no characters are written.
Otherwise, the character s[0]
is written first, then s[1]
,
and so on; the last character written is
s[s.length-1]
. For each character,
two bytes are actually written, high-order
byte first, in exactly the manner of the
writeChar
method.
writeChars
in interface java.io.DataOutput
s
- the string value to be written.
java.io.IOException
- if an I/O error occurs.public void writeUTF(java.lang.String str) throws java.io.IOException
s
.
If s
is null
,
a NullPointerException
is thrown.
Each character in the string s
is converted to a group of one, two, or
three bytes, depending on the value of the
character.
If a character c
is in the range \u0001
through
\u007f
, it is represented
by one byte:
(byte)c
If a character c
is \u0000
or is in the range \u0080
through \u07ff
, then it is
represented by two bytes, to be written
in the order shown:
(byte)(0xc0 | (0x1f & (c >> 6)))
(byte)(0x80 | (0x3f & c))
If a character
c
is in the range \u0800
through uffff
, then it is
represented by three bytes, to be written
in the order shown:
(byte)(0xe0 | (0x0f & (c >> 12)))
(byte)(0x80 | (0x3f & (c >> 6)))
(byte)(0x80 | (0x3f & c))
First,
the total number of bytes needed to represent
all the characters of s
is
calculated. If this number is larger than
65535
, then a UTFDataFormatError
is thrown. Otherwise, this length is written
to the output stream in exactly the manner
of the writeShort
method;
after this, the one-, two-, or three-byte
representation of each character in the
string s
is written.
The
bytes written by this method may be read
by the readUTF
method of interface
DataInput
, which will then
return a String
equal to s
.
writeUTF
in interface java.io.DataOutput
str
- the string value to be written.
java.io.IOException
- if an I/O error occurs.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |