Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## lejos.rcxcomm
Class PacketHandler

    java.lang.Object
      lejos.rcxcomm.PacketHandler

Direct Known Subclasses:
  LLCHandler, LLCReliableHandler

    public abstract class PacketHandler

extends Object

Abstract packet handler. Implementations must include sendPacket, receivePacket and isPacketAvailable(). The other methods are optional.

Field Summary
`protected PacketHandler` | `lowerHandler`

Constructor Summary
`PacketHandler()`
`PacketHandler(PacketHandler handler)`

Method Summary
`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

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait`

Field Detail

### lowerHandler

    protected PacketHandler lowerHandler

Constructor Detail

### PacketHandler

    public PacketHandler()

### PacketHandler

    public PacketHandler(PacketHandler handler)

Method Detail

### open

    public void open(byte source,
                     byte destination)

  Set the source and destination for this connection.

### reset

    public void reset()

  Reset sequence numbers for this handler

### setListen

    public void setListen(boolean listen)

  Set or unset the listen flag to keep a PC serial tower alive

  Parameters:
    `listen` - true to set listen mode, else false

### sendPacket

    public abstract boolean sendPacket(byte[] packet,
                                       int len)

  Send a packet.

  Parameters:
    `packet` - the bytes to send
    `len` - the number of bytes to send
  Returns:
    true if the send was successful, else false

### receivePacket

    public abstract int receivePacket(byte[] buffer)

  Receive a packet.

  Parameters:
    `buffer` - the buffer to receive the packet into
  Returns:
    the number of bytes received

### receiveAck

    public int receiveAck(byte[] buffer)

### isPacketAvailable

    public abstract boolean isPacketAvailable()

  Check if a packet is available

  Returns:
    true if a Packet is available, else false

### isAckAvailable

    public boolean isAckAvailable()

  Check if an ack is available

  Returns:
    true if a ack is available, else false

### close

    public void close()

  Close this packet handler and all lower layers.

### getError

    public int getError()

  Get the last error.

  Returns:
    the error number, or zero for success

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD