rcx.josx.rcxcomm
Class F7DeliveryHandler

java.lang.Object
  extended by rcx.josx.rcxcomm.PacketHandler
      extended by rcx.josx.rcxcomm.F7DeliveryHandler

public class F7DeliveryHandler
extends PacketHandler

A packet handler that attempts (but doesn't fully succeed in) reliable delivery for F7 Lego firmware opcode packets. It implements acks, and checks packet validity, but has no sequence number checking. Packets are not guaranteed to get through, and duplicates can occur undetected. See F7Handler for more information.


Constructor Summary
F7DeliveryHandler(PacketHandler handler)
           
 
Method Summary
 boolean isPacketAvailable()
          Check if a packet is available
 int receivePacket(byte[] buffer)
          Receive a packet, and send an ack.
 boolean sendPacket(byte[] packet, int len)
          Send a packet, checking for returned ack.
 
Methods inherited from class rcx.josx.rcxcomm.PacketHandler
close, getError, isAckAvailable, open, receiveAck, reset, setListen
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

F7DeliveryHandler

public F7DeliveryHandler(PacketHandler handler)
Method Detail

sendPacket

public boolean sendPacket(byte[] packet,
                          int len)
Send a packet, checking for returned ack.

Specified by:
sendPacket in class PacketHandler
Parameters:
packet - the bytes to send
len - the number of bytes to send
Returns:
true if the send was successful, else false

receivePacket

public int receivePacket(byte[] buffer)
Receive a packet, and send an ack.

Specified by:
receivePacket in class PacketHandler
Parameters:
buffer - the buffer to receive the packet into
Returns:
the number of bytes received

isPacketAvailable

public boolean isPacketAvailable()
Check if a packet is available

Specified by:
isPacketAvailable in class PacketHandler
Returns:
true if a Packet is available, else false