public abstract class PacketHandler
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected PacketHandler |
lowerHandler |
Constructor and Description |
---|
PacketHandler() |
PacketHandler(PacketHandler handler) |
Modifier and Type | Method and Description |
---|---|
void |
close()
Close this packet handler and all lower layers.
|
int |
getError()
Get the last error.
|
boolean |
isAckAvailable()
Check if an ack is available
|
abstract boolean |
isPacketAvailable()
Check if a packet is available
|
void |
open(byte source,
byte destination)
Set the source and destination for this connection.
|
int |
receiveAck(byte[] buffer) |
abstract int |
receivePacket(byte[] buffer)
Receive a packet.
|
void |
reset()
Reset sequence numbers for this handler
|
abstract boolean |
sendPacket(byte[] packet,
int len)
Send a packet.
|
void |
setListen(boolean listen)
Set or unset the listen flag to keep a PC serial tower alive
|
protected PacketHandler lowerHandler
public PacketHandler()
public PacketHandler(PacketHandler handler)
public void open(byte source, byte destination)
public void reset()
public void setListen(boolean listen)
listen
- true to set listen mode, else falsepublic abstract boolean sendPacket(byte[] packet, int len)
packet
- the bytes to sendlen
- the number of bytes to sendpublic abstract int receivePacket(byte[] buffer)
buffer
- the buffer to receive the packet intopublic int receiveAck(byte[] buffer)
public abstract boolean isPacketAvailable()
public boolean isAckAvailable()
public void close()
public int getError()