org.jSyncManager.API.Protocol

Class USB_Packet

Implemented Interfaces:
Serializable

public class USB_Packet
extends java.lang.Object
implements Serializable

USB_Packet class. This class holds a USB packet.

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.
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.
static byte
TICKLE
A value to denote that this packet is a tickle packet.
byte[]
data
A byte array to hold this packets data portion.
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.
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(headerPkt[] , dataPkt[] )
Convert two arrays of bytes representing a USB packet header and data to a USB_Packet instance.
static USB_Packet
bytes2Packet(pkt[] )
Convert an array of bytes representing a USB packet to a USB_Packet instance.
byte[]
packet2Bytes()
Converts this USB_Packet instance into a byte array suitable for transmission to a handheld device.
String
toString()
Converts this object to a human-readable String.

Field Details

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.
Field Value:
8

ACK

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

DATA

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

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.
Field Value:
3

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.
Field Value:
4

data

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

packetSize

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

packetType

public byte packetType
The packet type of the USB packet.

sent

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

transactionID

public byte transactionID
This packets transaction ID.

Constructor Details

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 Details

bytes2Packet

public static USB_Packet bytes2Packet(headerPkt[] ,
                                      dataPkt[] )
Convert two arrays of bytes representing a USB packet header and data to a USB_Packet instance.
Parameters:
Returns:
a USB_Packet representing the packet passed.

bytes2Packet

public static USB_Packet bytes2Packet(pkt[] )
Convert an array of bytes representing a USB packet to a USB_Packet instance.
Parameters:
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.

toString

public String toString()
Converts this object to a human-readable String.
Returns:
this object to a human-readable String.