|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.lsst.ccs.drivers.usb.UsbComm
public class UsbComm
Communicates with a USB device
| Field Summary | |
|---|---|
static int |
CFG_ATTR_REMOTE_WAKE
Configuration attribute - remote wakeup |
static int |
CFG_ATTR_SELF_POWER
Configuration attribute - self-powered |
static int |
DEV_CLASS_CDC_CTRL
Device class - CDC control |
static int |
DEV_CLASS_DIAGNOSTIC
Device class - diagnostic |
static int |
DEV_CLASS_HUB
Device class - hub |
static int |
DEV_CLASS_INTERFACE
Device class - see interface |
static int |
DEV_CLASS_MISC
Device class - miscellaneous |
static int |
DEV_CLASS_VENDOR_SPEC
Device class - vendor specific |
static int |
DEV_SPEED_FULL
Device speed - full |
static int |
DEV_SPEED_LOW
Device speed - low |
static int |
DEV_SPEED_UNDEFINED
Device speed - undefined |
static int |
DEV_SPEED_UNKNOWN
Device speed - unknown |
static int |
EP_ATTR_BULK
Endpoint attribute - bulk data |
static int |
EP_ATTR_CONTROL
Endpoint attribute - control |
static int |
EP_ATTR_INTERRUPT
Endpoint attribute - interrupt |
static int |
EP_ATTR_ISOCHRONOUS
Endpoint attribute - isochronous |
static int |
IFC_CLASS_APP_SPEC
Interface class - application specific |
static int |
IFC_CLASS_AUDIO
Interface class - audio |
static int |
IFC_CLASS_CDC_CTRL
Interface class - CDC control |
static int |
IFC_CLASS_CDC_DATA
Interface class - CDC data |
static int |
IFC_CLASS_CONTENT_SEC
Interface class security x |
static int |
IFC_CLASS_DIAGNOSTIC
Interface class - diagnostic |
static int |
IFC_CLASS_HEALTHCARE
Interface class - personal healthcare |
static int |
IFC_CLASS_HID
Interface class - human interface |
static int |
IFC_CLASS_IMAGE
Interface class - still image |
static int |
IFC_CLASS_MASS_STORE
Interface class - mass storage |
static int |
IFC_CLASS_MISC
Interface class - miscellaneous |
static int |
IFC_CLASS_PHYSICAL
Interface class - physical |
static int |
IFC_CLASS_PRINTER
Interface class - printer |
static int |
IFC_CLASS_SMART_CARD
Interface class - smart card |
static int |
IFC_CLASS_VENDOR_SPEC
Interface class - vendor specific |
static int |
IFC_CLASS_VIDEO
Interface class - video |
static int |
IFC_CLASS_WIRELESS
Interface class - wireless |
| Constructor Summary | |
|---|---|
UsbComm()
Constructor |
|
| Method Summary | |
|---|---|
void |
close()
Closes the connection to the device |
UsbDevice |
findDevice(int vid,
int pid,
java.lang.String serial)
Finds a USB device and sets it |
static java.util.List |
findDevices(int vid,
int pid,
java.lang.String serial)
Finds USB devices |
int |
flush()
Flushes any pending read data |
UsbConfiguration |
getConfiguration()
Gets the current USB configuration |
UsbDevice |
getDevice()
Gets the USB device |
UsbEndpoint |
getEndpoint(int epnum)
Gets a USB endpoint for the current open device |
static UsbEndpoint |
getEndpoint(UsbInterface iface,
int epnum)
Gets a USB endpoint for the specified interface |
UsbInterface |
getInterface()
Gets the USB interface being used |
UsbInterface |
getInterface(int iface)
Gets the specified USB interface of the current device |
static UsbInterface |
getInterface(UsbDevice device,
int iface)
Gets the specified USB interface of the specified device |
int |
getSpeed()
Gets the speed of the current device |
static int |
getSpeed(UsbDevice devc)
Gets the speed of a device |
void |
open(int iface,
int ends,
boolean force)
Opens a connection to a device |
int |
read(byte[] data,
int timeout)
Reads data from the device |
int |
read(byte[] data,
int offs,
int leng,
int timeout)
Reads data from the device |
void |
setDevice(UsbDevice device)
Sets the USB device |
int |
write(byte[] data)
Writes data to the device |
int |
write(byte[] data,
int offs,
int leng)
Writes data to the device |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int DEV_SPEED_UNDEFINED
public static final int DEV_SPEED_UNKNOWN
public static final int DEV_SPEED_LOW
public static final int DEV_SPEED_FULL
public static final int DEV_CLASS_INTERFACE
public static final int DEV_CLASS_CDC_CTRL
public static final int DEV_CLASS_HUB
public static final int DEV_CLASS_DIAGNOSTIC
public static final int DEV_CLASS_MISC
public static final int DEV_CLASS_VENDOR_SPEC
public static final int CFG_ATTR_SELF_POWER
public static final int CFG_ATTR_REMOTE_WAKE
public static final int IFC_CLASS_AUDIO
public static final int IFC_CLASS_CDC_CTRL
public static final int IFC_CLASS_HID
public static final int IFC_CLASS_PHYSICAL
public static final int IFC_CLASS_IMAGE
public static final int IFC_CLASS_PRINTER
public static final int IFC_CLASS_MASS_STORE
public static final int IFC_CLASS_CDC_DATA
public static final int IFC_CLASS_SMART_CARD
public static final int IFC_CLASS_CONTENT_SEC
public static final int IFC_CLASS_VIDEO
public static final int IFC_CLASS_HEALTHCARE
public static final int IFC_CLASS_DIAGNOSTIC
public static final int IFC_CLASS_WIRELESS
public static final int IFC_CLASS_MISC
public static final int IFC_CLASS_APP_SPEC
public static final int IFC_CLASS_VENDOR_SPEC
public static final int EP_ATTR_CONTROL
public static final int EP_ATTR_ISOCHRONOUS
public static final int EP_ATTR_BULK
public static final int EP_ATTR_INTERRUPT
| Constructor Detail |
|---|
public UsbComm()
throws UsbException
UsbException| Method Detail |
|---|
public static java.util.List findDevices(int vid,
int pid,
java.lang.String serial)
throws UsbException
The tree of USB devices is searched, looking for devices whose vendor and product IDs match the ones specified. If a non-null serial number is provided, this must be matched as well; otherwise the first ID match is used.
vid - The vendor ID, or -1 if any vendor ID matches.pid - The product ID, or -1 if any product ID matches.serial - The serial number, or null if the serial number is
not to be matched.
UsbException
public UsbDevice findDevice(int vid,
int pid,
java.lang.String serial)
throws UsbException
The tree of USB devices is searched, looking for devices whose vendor and product IDs match the ones specified. If a non-null serial number is provided, this must be matched as well; otherwise the first ID match is used. The current device is set to the resultant device, possibly null.
vid - The vendor IDpid - The product IDserial - The serial number, or null if the serial number is
not to be matched.
UsbException - if a device is already open.public UsbDevice getDevice()
public void setDevice(UsbDevice device)
throws UsbException
device - The UsbDevice object to set. Can be null.
UsbException - if a device is already open.public UsbConfiguration getConfiguration()
public UsbInterface getInterface()
public UsbInterface getInterface(int iface)
iface - The number, starting from 0, of the interface .
public static UsbInterface getInterface(UsbDevice device,
int iface)
device - The USB deviceiface - The number, starting from 0, of the interface .
public UsbEndpoint getEndpoint(int epnum)
epnum - The endpoint to get: 0 = in, 1 = out.
public static UsbEndpoint getEndpoint(UsbInterface iface,
int epnum)
iface - The USB interface to useepnum - The endpoint to get: 0 = in, anything else = out.
public int getSpeed()
public static int getSpeed(UsbDevice devc)
public void open(int iface,
int ends,
boolean force)
throws UsbException
The device is assumed to be configured, and the specified interface is used. The interface must have an endpoint of each requested type.
iface - The number of the interface to use, starting at 0.ends - The endpoints to be opened: 0 = in and out, 1 = in,
2 = out, otherwise in and out.force - Set to true if claiming the device interface is to be
forced, allowing the use of devices claimed by another
driver or user.
UsbException - if the device has not been set or the requested
interface or endpoints do not exist.
UsbClaimException - if the interface cannot be claimed.
public void close()
throws UsbException
UsbException - if the device is not open.
public int write(byte[] data)
throws UsbException
data - Byte array of data to be written.
UsbException - if the out endpoint is not open.
public int write(byte[] data,
int offs,
int leng)
throws UsbException
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.
UsbException - if the out endpoint is not open.
public int read(byte[] data,
int timeout)
throws UsbException,
UsbTimeoutException
data - Byte array to receive the read data.timeout - The maximum time, in milliseconds, to wait for data.
UsbException - if the in endpoint is not open.
UsbTimeoutException - if the read times out.
public int read(byte[] data,
int offs,
int leng,
int timeout)
throws UsbException,
UsbTimeoutException
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.
UsbException - if the in endpoint is not open.
UsbTimeoutException - if the read times out.
public int flush()
throws UsbException
UsbException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||