lejos.rcxcomm
Class LLCHandler

java.lang.Object
  extended by lejos.rcxcomm.PacketHandler
      extended by lejos.rcxcomm.LLCHandler

public class LLCHandler
extends PacketHandler

Packet handler than implement the LLC packet protocol. Deals with packets and acks. Supports independent streams of data in both directions.

WARNING: THIS CLASS IS SHARED BETWEEN THE classes AND pccomms PROJECTS. DO NOT EDIT THE VERSION IN pccomms AS IT WILL BE OVERWRITTEN WHEN THE PROJECT IS BUILT.


Field Summary
 
Fields inherited from class lejos.rcxcomm.PacketHandler
lowerHandler
 
Constructor Summary
LLCHandler(SensorPort port)
           
 
Method Summary
 boolean isAckAvailable()
          Check if an Ack is available
 boolean isPacketAvailable()
          Check if a packet is available
 int receiveAck(byte[] buffer)
          Receive an ack.
 int receivePacket(byte[] buffer)
          Receive a packet.
 boolean sendPacket(byte[] packet, int len)
          Send a packet.
 
Methods inherited from class lejos.rcxcomm.PacketHandler
close, getError, open, reset, setListen
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LLCHandler

public LLCHandler(SensorPort port)
Method Detail

sendPacket

public boolean sendPacket(byte[] packet,
                          int len)
Send a packet.

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.

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

receiveAck

public int receiveAck(byte[] buffer)
Receive an ack.

Overrides:
receiveAck in class PacketHandler
Parameters:
buffer - the buffer to receive the ack 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

isAckAvailable

public boolean isAckAvailable()
Check if an Ack is available

Overrides:
isAckAvailable in class PacketHandler
Returns:
true if ack is available, else false