org.lsst.ccs.drivers.usb
Class UsbCommPipe

java.lang.Object
  extended by org.lsst.ccs.drivers.usb.UsbCommPipe

public class UsbCommPipe
extends Object

Performs I/O operations on a UsbPipe

Author:
Owen Saxton

Constructor Summary
UsbCommPipe(UsbPipe pipe)
          Constructor
 
Method Summary
 void close()
          Closes the pipe
 int flush()
          Flushes any pending read data
 int read(byte[] data, int timeout)
          Reads data from the pipe
 int read(byte[] data, int offs, int leng, int timeout)
          Reads data from the pipe
 int write(byte[] data)
          Writes data to the pipe
 int write(byte[] data, int offs, int leng)
          Writes data to the pipe
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UsbCommPipe

public UsbCommPipe(UsbPipe pipe)
            throws UsbException
Constructor

Throws:
UsbException
Method Detail

close

public void close()
           throws UsbException
Closes the pipe

Throws:
UsbException - if the device is not open.

write

public int write(byte[] data)
          throws UsbException
Writes data to the pipe

Parameters:
data - Byte array of data to be written.
Returns:
The number of bytes of data actually written.
Throws:
UsbException - if the out endpoint is not open.

write

public int write(byte[] data,
                 int offs,
                 int leng)
          throws UsbException
Writes data to the pipe

Parameters:
data - Byte array containing the data to be written.
offs - The offset of the first byte to be written.
leng - The number of bytes to be written.
Returns:
The number of bytes of data actually written.
Throws:
UsbException - if the out endpoint is not open.

read

public int read(byte[] data,
                int timeout)
         throws UsbException,
                UsbTimeoutException
Reads data from the pipe

Parameters:
data - Byte array to receive the read data.
timeout - The maximum time, in milliseconds, to wait for data.
Returns:
The number of bytes read.
Throws:
UsbException - if the in endpoint is not open.
UsbTimeoutException - if the read times out.

read

public int read(byte[] data,
                int offs,
                int leng,
                int timeout)
         throws UsbException,
                UsbTimeoutException
Reads data from the pipe

Parameters:
data - Byte array to receive the read data.
offs - The offset in data where the read data is to start.
leng - The number of bytes of data to read.
timeout - The maximum time, in milliseconds, to wait for data.
Returns:
The number of bytes read.
Throws:
UsbException - if the in endpoint is not open.
UsbTimeoutException - if the read times out.

flush

public int flush()
          throws UsbException
Flushes any pending read data

Returns:
The number of bytes flushed.
Throws:
UsbException


Copyright © 2013 LSST. All Rights Reserved.