jSyncManager

org.jSyncManager.API.Protocol
Class CMP_DLP

java.lang.Object
  |
  +--org.jSyncManager.API.Protocol.CMP_DLP

public class CMP_DLP
extends java.lang.Object

CMP_DLP class. This class provides the black-box for handling CMP and DLP packets.

Version:
$Revision: 1.7 $
Author:
Brad BARCLAY <bbarclay@jsyncmanager.org>
Last modified by: $Author: yaztromo $ on $Date: 2003/04/23 03:20:16 $.

Field Summary
protected  boolean connected
          The connection state.
protected  CMPDLPTransferInterface padpHandler
          The underlying CMPDLPTransferInterface object to use for packet I/O.
protected  int speed
          The speed to use for serial synchronization.
 
Constructor Summary
protected CMP_DLP()
          Construct an instance of the CMP_DLP class with no parameters.
  CMP_DLP(CMPDLPTransferInterface padp)
          Construct an instance of the CMP_DLP class using the specified underlying CMPDLPTransferInterface protocol handler.
 
Method Summary
 void connect()
          Attempt to listen for a connection to the remote CMP/DLP enabled device.
protected  boolean determinePacketType(GenericPacket genericpacket)
          A method to determine the type of incoming packet.
 void disconnect()
          A method to cause the protocol stack issue a disconnect request.
 void disconnect(char c)
          A method to cause the protocol stack issue a disconnect request with the specified disconnect reason code.
 DLP_Packet getDLPPacket(DLP_Packet dlp_packet)
          Retreives a DLP packet from the underlying protocol in the stack.
 int getSpeed()
          Retreives the speed of the connection.
 boolean isConnected()
          Returns the connection status of this protocol layer.
protected  void rxHandshake()
          USB Receive Handshake.
 void setSpeed(int newValue)
          Sets the speed that this protocol should attempt to use for serial synchronization sessions.
 void suspend()
          Suspends the synchronization.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

padpHandler

protected CMPDLPTransferInterface padpHandler
The underlying CMPDLPTransferInterface object to use for packet I/O.

connected

protected boolean connected
The connection state. Set to true if the protocol stack is connected to the remote end, otherwise set to false.

speed

protected int speed
The speed to use for serial synchronization. This field is ignored for non-serial synchronizations. The default is 9600bps.
Constructor Detail

CMP_DLP

protected CMP_DLP()
Construct an instance of the CMP_DLP class with no parameters. This method is protected for use by subclasses.

CMP_DLP

public CMP_DLP(CMPDLPTransferInterface padp)
Construct an instance of the CMP_DLP class using the specified underlying CMPDLPTransferInterface protocol handler.
Parameters:
padp - the underlying CMPDLPTransferInterface protocol handler to use for I/O.
Method Detail

connect

public void connect()
             throws NotConnectedException
Attempt to listen for a connection to the remote CMP/DLP enabled device. This method will block until a connection is initiated, so it's safe to call and wait until a connection occurs. Interactive applications should call this method in a seperate thread to allow the user to continue interacting with the application.
Throws:
NotConnectedException - thrown if the connection is lost during connection initialization.

determinePacketType

protected boolean determinePacketType(GenericPacket genericpacket)
A method to determine the type of incoming packet.
Returns:
true if this packet is a PADP packet, false otherwise.

disconnect

public void disconnect()
A method to cause the protocol stack issue a disconnect request. This method simply calls disconnect(char) with a disconnect reason code of 0.

disconnect

public void disconnect(char c)
A method to cause the protocol stack issue a disconnect request with the specified disconnect reason code.
Parameters:
c - the reason code for the disconnect.

getDLPPacket

public DLP_Packet getDLPPacket(DLP_Packet dlp_packet)
                        throws NotConnectedException,
                               DLPError
Retreives a DLP packet from the underlying protocol in the stack. This method uses a request/response format, so in order to get a packet of data, you have to request the packet via a DLP Request packet.
Parameters:
DLP_Packet - the packet containing the DLP request.
Returns:
the DLP_Packet containing the response from the remote end.
Throws:
NotConnectedException - thrown if the connection is lost during request/responce processing, or if this method was called prior to a connection being initialized via connect().
DLPError - if the request resulted in an error on the remote end, a DLPError is thrown.

getSpeed

public int getSpeed()
Retreives the speed of the connection. This value is only valid for serial based connections. Other connections will return the default speed value of 9600bps, and should be ignored.
Returns:
the speed of the serial connection.

isConnected

public boolean isConnected()
Returns the connection status of this protocol layer.
Returns:
true if we're connected to the remote device still, false otherwise.

setSpeed

public void setSpeed(int newValue)
Sets the speed that this protocol should attempt to use for serial synchronization sessions. This method has no effect for non-serial synchronization.
Parameters:
newValue - the speed that the synchronization should be attempted at.

suspend

public void suspend()
             throws NotConnectedException
Suspends the synchronization. Calling this method closes down the current synchronization session, while leaving the protocol stack in tact so it can begin another synchronization session as soon as this method returns. This method will alsa attempt to suspend the protocol layer beneath it.
Throws:
NotConnectedException - thrown if the connection to the remote end is lost.

rxHandshake

protected void rxHandshake()
                    throws java.lang.Exception
USB Receive Handshake.

jSyncManager

Copyright (c) 1999 - 2003 Brad BARCLAY and others. All Rights Reserved.