Package org.deepjava.runtime.util
Class IntPacket
- java.lang.Object
-
- org.deepjava.runtime.util.IntPacket
-
public class IntPacket extends Object
Interface for the RN131 driver to send and receive integer values.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
IntPacket.Type
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte
getHeader()
Returns the header of the last received integer.int
getInt()
Returns the last received integer.IntPacket.Type
readInt()
Reads an integer from the receive buffer.boolean
writeInt(byte header, int val)
Writes an integer with a specified header to the send buffer.boolean
writeInt(int val)
Writes an integer with the default header to the send buffer.boolean
writeInt(IntPacket.Type type, int val)
Writes an integer of the specified type to the send buffer.
-
-
-
Constructor Detail
-
IntPacket
public IntPacket(SLIP slip)
Creates a IntPacket object on top of the SLIP interface.- Parameters:
slip
- slip interface to use
-
-
Method Detail
-
writeInt
public boolean writeInt(int val)
Writes an integer with the default header to the send buffer.- Parameters:
val
- integer to send- Returns:
- false if buffer is full, true otherwise
-
writeInt
public boolean writeInt(IntPacket.Type type, int val)
Writes an integer of the specified type to the send buffer.- Parameters:
type
- type of the integerval
- integer to send- Returns:
- false if buffer is full, true otherwise
-
writeInt
public boolean writeInt(byte header, int val)
Writes an integer with a specified header to the send buffer.- Parameters:
header
- header of the integerval
- integer to send- Returns:
- false if buffer is full, true otherwise
-
readInt
public IntPacket.Type readInt()
Reads an integer from the receive buffer. The value of the integer can be retrieved with the getCmd method. The value of the header can be retrieved with the getHeader method.- Returns:
- Type.Int or Type.None if data was received. Type.Illegal if a corrupted packet was received and Type.None if buffer is empty.
-
getHeader
public byte getHeader()
Returns the header of the last received integer.- Returns:
- header of the last received integer
-
getInt
public int getInt()
Returns the last received integer.- Returns:
- last received integer
-
-