jSyncManager

org.jSyncManager.API.Protocol
Class USB_Packet

java.lang.Object
  |
  +--org.jSyncManager.API.Protocol.USB_Packet
All Implemented Interfaces:
java.io.Serializable

public class USB_Packet
extends java.lang.Object
implements java.io.Serializable

USB_Packet class. This class holds a USB packet.

Version:
$Revision: 1.6 $
Author:
Brad BARCLAY <bbarclay@jsyncmanager.org>, Last modified by: $Author: yaztromo $ on $Date: 2003/04/24 05:12:24 $.
See Also:
Serialized Form

Field Summary
static byte ABORT
          A value to denote that this packet is an abort packet.
static byte ACK
          A value to denote that this packet is an ACKnowledgement packet.
 byte[] data
          A byte array to hold this packets data portion.
static byte DATA
          A value to denote that this packet is a data packet.
static byte NACK
          A value to denote that this packet is a Negative ACKnowledgement packet.
 int packetSize
          The size of this packet, in bytes.
 byte packetType
          The packet type of the USB packet.
 boolean sent
          A flag to denote wether or not this packet has been sent to the remote end.
static byte TICKLE
          A value to denote that this packet is a tickle packet.
 byte transactionID
          This packets transaction ID.
 
Constructor Summary
USB_Packet(byte type, byte transID, byte[] data)
          Create a new USB_Packet instance with the specified packet type, transaction ID, and data.
 
Method Summary
static USB_Packet bytes2Packet(byte[] pkt)
          Convert an array of bytes representing a USB packet to a USB_Packet instance.
static USB_Packet bytes2Packet(byte[] headerPkt, byte[] dataPkt)
          Convert two arrays of bytess representing a USB packet header and data to a USB_Packet instance.
 byte[] packet2Bytes()
          Converts this USB_Packet instance into a byte array suitable for transmission to a handheld device.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

packetType

public byte packetType
The packet type of the USB packet.
See Also:
DATA, ACK, NACK, TICKLE, ABORT

transactionID

public byte transactionID
This packets transaction ID.

packetSize

public int packetSize
The size of this packet, in bytes.

DATA

public static final byte DATA
A value to denote that this packet is a data packet.

ACK

public static final byte ACK
A value to denote that this packet is an ACKnowledgement packet.

NACK

public static final byte NACK
A value to denote that this packet is a Negative ACKnowledgement packet. Note that this type should not be used, as NACKs are unreliable, and are not used by any handheld devices. It is provided here merely for the sake of completeness.

TICKLE

public static final byte TICKLE
A value to denote that this packet is a tickle packet. Tickle packets are used to keep the synchronization connection alive during lengthy periods of processing. When received, the inter-packet timer is reset and the tickle packet is discarded.

ABORT

public static final byte ABORT
A value to denote that this packet is an abort packet. Abort packets are used to terminate the synchronization operation.

data

public byte[] data
A byte array to hold this packets data portion.

sent

public boolean sent
A flag to denote wether or not this packet has been sent to the remote end.
Constructor Detail

USB_Packet

public USB_Packet(byte type,
                  byte transID,
                  byte[] data)
Create a new USB_Packet instance with the specified packet type, transaction ID, and data.
Parameters:
type - the packet type.
transID - the transaction ID for this packet.
data - the data to be encapsulated within this packet.
Method Detail

bytes2Packet

public static USB_Packet bytes2Packet(byte[] pkt)
Convert an array of bytes representing a USB packet to a USB_Packet instance.
Parameters:
pkt - an array of bytes representing a USB packet.
Returns:
a USB_Packet representing the packet passed.

bytes2Packet

public static USB_Packet bytes2Packet(byte[] headerPkt,
                                      byte[] dataPkt)
Convert two arrays of bytess representing a USB packet header and data to a USB_Packet instance.
Parameters:
headerPkt - the byte array containing the packet header.
dataPkt - the data that is encapsulated inside this packet.
Returns:
a USB_Packet representing the packet passed.

packet2Bytes

public byte[] packet2Bytes()
Converts this USB_Packet instance into a byte array suitable for transmission to a handheld device.
Returns:
an array of bytes containing this packet instances data.

jSyncManager

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