com.ibm.jusb
Class UsbPipeImp

java.lang.Object
  extended by com.ibm.jusb.UsbPipeImp
All Implemented Interfaces:
UsbIrpImp.UsbIrpImpListener, java.util.EventListener, UsbPipe
Direct Known Subclasses:
UsbControlPipeImp

public class UsbPipeImp
extends java.lang.Object
implements UsbPipe, UsbIrpImp.UsbIrpImpListener

UsbPipe platform-independent implementation.

This must be set up before use.

Author:
Dan Streetman

Field Summary
static java.lang.String CREATE_SHORT_PACKET_EXCEPTION_POLICY_KEY
           
static java.lang.String PIPE_BULK_QUEUE_POLICY_KEY
           
static java.lang.String PIPE_CONTROL_QUEUE_POLICY_KEY
           
static java.lang.String PIPE_INTERRUPT_QUEUE_POLICY_KEY
           
static java.lang.String PIPE_ISOCHRONOUS_QUEUE_POLICY_KEY
           
 
Constructor Summary
UsbPipeImp()
          Constructor.
UsbPipeImp(UsbEndpointImp ep)
          Constructor.
UsbPipeImp(UsbEndpointImp ep, UsbPipeOsImp pipe)
          Constructor.
UsbPipeImp(UsbPipeOsImp pipe)
          Constructor.
 
Method Summary
 void abortAllSubmissions()
          Stop all submissions in progress.
 void addUsbPipeListener(UsbPipeListener listener)
          Register's the listener object for UsbPipeEvent
 UsbIrp asyncSubmit(byte[] data)
          Asynchonously submits this byte[] array to the UsbPipe.
 void asyncSubmit(java.util.List list)
          Asynchronous submission using a List of UsbIrps.
 void asyncSubmit(UsbIrp usbIrp)
          Asynchronous submission using a UsbIrp.
 void close()
          Closes this UsbPipe.
 UsbControlIrp createUsbControlIrp(byte bmRequestType, byte bRequest, short wValue, short wIndex)
          Create a UsbControlIrp.
 UsbIrp createUsbIrp()
          Create a UsbIrp.
 UsbEndpoint getUsbEndpoint()
          Get this pipe's UsbEndpoint.
 UsbEndpointImp getUsbEndpointImp()
           
 UsbPipeOsImp getUsbPipeOsImp()
           
 boolean isActive()
          If this pipe is active.
 boolean isOpen()
          If this pipe is open.
 void open()
          Opens this UsbPipe.
 void removeUsbPipeListener(UsbPipeListener listener)
          Removes the listener object from the listener list
 void setupUsbIrpImp(UsbIrpImp irp)
           
 void setUsbEndpointImp(UsbEndpointImp ep)
          Set the UsbEndpointImp.
 void setUsbPipeOsImp(UsbPipeOsImp pipe)
           
 int syncSubmit(byte[] data)
          Synchonously submits this byte[] array to the UsbPipe.
 void syncSubmit(java.util.List list)
          Synchronous submission using a List of UsbIrps.
 void syncSubmit(UsbIrp usbIrp)
          Synchronous submission using a UsbIrp.
 void usbIrpImpComplete(UsbIrpImp irp)
          Indicate that a specific UsbIrpImp has completed.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PIPE_CONTROL_QUEUE_POLICY_KEY

public static final java.lang.String PIPE_CONTROL_QUEUE_POLICY_KEY
See Also:
Constant Field Values

PIPE_INTERRUPT_QUEUE_POLICY_KEY

public static final java.lang.String PIPE_INTERRUPT_QUEUE_POLICY_KEY
See Also:
Constant Field Values

PIPE_ISOCHRONOUS_QUEUE_POLICY_KEY

public static final java.lang.String PIPE_ISOCHRONOUS_QUEUE_POLICY_KEY
See Also:
Constant Field Values

PIPE_BULK_QUEUE_POLICY_KEY

public static final java.lang.String PIPE_BULK_QUEUE_POLICY_KEY
See Also:
Constant Field Values

CREATE_SHORT_PACKET_EXCEPTION_POLICY_KEY

public static final java.lang.String CREATE_SHORT_PACKET_EXCEPTION_POLICY_KEY
See Also:
Constant Field Values
Constructor Detail

UsbPipeImp

public UsbPipeImp()
Constructor.


UsbPipeImp

public UsbPipeImp(UsbEndpointImp ep)
Constructor.

Parameters:
ep - The UsbEndpointImp.

UsbPipeImp

public UsbPipeImp(UsbPipeOsImp pipe)
Constructor.

Parameters:
pipe - The platform-dependent pipe implementation.

UsbPipeImp

public UsbPipeImp(UsbEndpointImp ep,
                  UsbPipeOsImp pipe)
Constructor.

Parameters:
ep - The UsbEndpointImp.
pipe - The platform-dependent pipe implementation.
Method Detail

getUsbPipeOsImp

public UsbPipeOsImp getUsbPipeOsImp()
Returns:
the UsbPipeOsImp object

setUsbPipeOsImp

public void setUsbPipeOsImp(UsbPipeOsImp pipe)
Parameters:
pipe - The UsbPipeOsImp to use

isActive

public boolean isActive()
Description copied from interface: UsbPipe
If this pipe is active.

This pipe is active only if it belongs to an active configuration and interface setting, otherwise it is inactive. This UsbPipe cannot be used if inactive.

Specified by:
isActive in interface UsbPipe
Returns:
if this UsbPipe is active

isOpen

public boolean isOpen()
Description copied from interface: UsbPipe
If this pipe is open.

This is true after a sucessful open until a successful close.

If this pipe is not active, this returns false.

Specified by:
isOpen in interface UsbPipe
Returns:
if this UsbPipe is open

getUsbEndpoint

public UsbEndpoint getUsbEndpoint()
Description copied from interface: UsbPipe
Get this pipe's UsbEndpoint.

Specified by:
getUsbEndpoint in interface UsbPipe
Returns:
the UsbEndpoint associated with this UsbPipe

getUsbEndpointImp

public UsbEndpointImp getUsbEndpointImp()
Returns:
the UsbEndpointImp associated with this UsbPipeImp

setUsbEndpointImp

public void setUsbEndpointImp(UsbEndpointImp ep)
Set the UsbEndpointImp.

This will also set this on the parent UsbEndpointImp. This also sets up this pipe's queueing policy if the user defined one in the properties file.

Parameters:
ep - The UsbEndpointImp

open

public void open()
          throws UsbException,
                 UsbNotActiveException,
                 UsbNotClaimedException,
                 UsbDisconnectedException
Opens this UsbPipe.

Specified by:
open in interface UsbPipe
Throws:
UsbException - If the UsbPipe could not be opened.
UsbNotActiveException - If the config or interface setting is not active.
UsbNotClaimedException - If the interface is not claimed.
UsbDisconnectedException - If this pipe (device) has been disconnected.

close

public void close()
           throws UsbException,
                  UsbNotActiveException,
                  UsbNotOpenException,
                  UsbDisconnectedException
Closes this UsbPipe.

Specified by:
close in interface UsbPipe
Throws:
UsbException - If the UsbPipe could not be closed.
UsbNotActiveException - If the UsbPipe is not active.
UsbNotOpenException - If the UsbPipe is not open.
UsbDisconnectedException - If this pipe (device) has been disconnected.

syncSubmit

public int syncSubmit(byte[] data)
               throws UsbException,
                      java.lang.IllegalArgumentException,
                      UsbNotActiveException,
                      UsbNotOpenException,
                      UsbDisconnectedException
Synchonously submits this byte[] array to the UsbPipe.

Specified by:
syncSubmit in interface UsbPipe
Parameters:
data - The buffer to use.
Returns:
The number of bytes actually transferred.
Throws:
UsbException - If an error occurs.
java.lang.IllegalArgumentException - If the data is null.
UsbNotActiveException - If the pipe is not active.
UsbNotOpenException - If the pipe is not open.
UsbDisconnectedException - If this pipe (device) has been disconnected.

asyncSubmit

public UsbIrp asyncSubmit(byte[] data)
                   throws UsbException,
                          java.lang.IllegalArgumentException,
                          UsbNotActiveException,
                          UsbNotOpenException,
                          UsbDisconnectedException
Asynchonously submits this byte[] array to the UsbPipe.

Specified by:
asyncSubmit in interface UsbPipe
Parameters:
data - The buffer to use.
Returns:
A UsbIrp representing the submission.
Throws:
UsbException - If an error occurs.
java.lang.IllegalArgumentException - If the data is null.
UsbNotActiveException - If the pipe is not active.
UsbNotOpenException - If the pipe is not open.
UsbDisconnectedException - If this pipe (device) has been disconnected.

syncSubmit

public void syncSubmit(UsbIrp usbIrp)
                throws UsbException,
                       java.lang.IllegalArgumentException,
                       UsbNotActiveException,
                       UsbNotOpenException,
                       UsbDisconnectedException
Synchronous submission using a UsbIrp.

Specified by:
syncSubmit in interface UsbPipe
Parameters:
usbIrp - A UsbIrp to use for the submission.
Throws:
UsbException - If an error occurs.
java.lang.IllegalArgumentException - If the UsbIrp is not valid.
UsbNotActiveException - If the pipe is not active.
UsbNotOpenException - If the pipe is not open.
UsbDisconnectedException - If this pipe (device) has been disconnected.

asyncSubmit

public void asyncSubmit(UsbIrp usbIrp)
                 throws UsbException,
                        java.lang.IllegalArgumentException,
                        UsbNotActiveException,
                        UsbNotOpenException,
                        UsbDisconnectedException
Asynchronous submission using a UsbIrp.

Specified by:
asyncSubmit in interface UsbPipe
Parameters:
usbIrp - The UsbIrp to use for the submission.
Throws:
UsbException - If an error occurs.
java.lang.IllegalArgumentException - If the UsbIrp is not valid.
UsbNotActiveException - If the pipe is not active.
UsbNotOpenException - If the pipe is not open.
UsbDisconnectedException - If this pipe (device) has been disconnected.

syncSubmit

public void syncSubmit(java.util.List list)
                throws UsbException,
                       java.lang.IllegalArgumentException,
                       UsbNotActiveException,
                       UsbNotOpenException,
                       UsbDisconnectedException
Synchronous submission using a List of UsbIrps.

Specified by:
syncSubmit in interface UsbPipe
Parameters:
list - The List of UsbIrps.
Throws:
UsbException - If an error occurs.
java.lang.IllegalArgumentException - If the list is empty or contains any non-UsbIrp objects, or those UsbIrp(s) are invalid.
UsbNotActiveException - If the pipe is not active.
UsbNotOpenException - If the pipe is not open.
UsbDisconnectedException - If this pipe (device) has been disconnected.

asyncSubmit

public void asyncSubmit(java.util.List list)
                 throws UsbException,
                        java.lang.IllegalArgumentException,
                        UsbNotActiveException,
                        UsbNotOpenException,
                        UsbDisconnectedException
Asynchronous submission using a List of UsbIrps.

Specified by:
asyncSubmit in interface UsbPipe
Parameters:
list - The List of UsbIrps.
Throws:
UsbException - If an error occurs.
java.lang.IllegalArgumentException - If the list is empty or contains any non-UsbIrp objects, or those UsbIrp(s) are invalid.
UsbNotActiveException - If the pipe is not active.
UsbNotOpenException - If the pipe is not open.
UsbDisconnectedException - If this pipe (device) has been disconnected.

abortAllSubmissions

public void abortAllSubmissions()
                         throws UsbNotActiveException,
                                UsbNotOpenException,
                                UsbDisconnectedException
Stop all submissions in progress.

Specified by:
abortAllSubmissions in interface UsbPipe
Throws:
UsbNotActiveException - If the pipe is not active.
UsbNotOpenException - If the pipe is not open.
UsbDisconnectedException - If this pipe (device) has been disconnected.

createUsbIrp

public UsbIrp createUsbIrp()
Create a UsbIrp.

Specified by:
createUsbIrp in interface UsbPipe
Returns:
A UsbIrp ready for use.

createUsbControlIrp

public UsbControlIrp createUsbControlIrp(byte bmRequestType,
                                         byte bRequest,
                                         short wValue,
                                         short wIndex)
Create a UsbControlIrp.

Specified by:
createUsbControlIrp in interface UsbPipe
Parameters:
bmRequestType - The bmRequestType.
bRequest - The bRequest.
wValue - The wValue.
wIndex - The wIndex.
Returns:
A UsbControlIrp ready for use.

usbIrpImpComplete

public void usbIrpImpComplete(UsbIrpImp irp)
Indicate that a specific UsbIrpImp has completed.

This is called after isComplete() is set to true.

Specified by:
usbIrpImpComplete in interface UsbIrpImp.UsbIrpImpListener
Parameters:
irp - The UsbIrpImp that completed.

addUsbPipeListener

public void addUsbPipeListener(UsbPipeListener listener)
Register's the listener object for UsbPipeEvent

Specified by:
addUsbPipeListener in interface UsbPipe
Parameters:
listener - the UsbPipeListener instance

removeUsbPipeListener

public void removeUsbPipeListener(UsbPipeListener listener)
Removes the listener object from the listener list

Specified by:
removeUsbPipeListener in interface UsbPipe
Parameters:
listener - the UsbPipeListener instance

setupUsbIrpImp

public void setupUsbIrpImp(UsbIrpImp irp)