|
||||||||||
| 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 |
claim(int iface,
boolean force)
Claims an interface |
UsbDevice |
findDevice(int vid,
int pid)
Finds a USB device and sets it as current |
UsbDevice |
findDevice(int vid,
int pid,
int index)
Finds a USB device and sets it as current |
UsbDevice |
findDevice(int vid,
int pid,
String serial)
Finds a USB device and sets it as current |
UsbDevice |
findDevice(int vid,
int pid,
String serial,
int index)
Finds a USB device and sets it as current |
static List |
findDevices(int vid,
int pid,
String serial)
Finds USB devices |
UsbConfiguration |
getConfiguration()
Gets the active USB configuration for the current device |
UsbDevice |
getDevice()
Gets the current USB device |
static UsbEndpoint |
getEndpoint(UsbInterface iface,
int epAddr)
Gets a USB endpoint for the specified interface. |
static List |
getEndpoints(UsbInterface iface)
Gets all USB endpoints for the specified interface. |
UsbInterface |
getInterface(int iface)
Gets the active setting of the specified USB interface of the current device |
static UsbInterface |
getInterface(UsbDevice device,
int iface)
Gets the active setting of the specified USB interface of the specified device. |
int |
getSpeed()
Gets the speed of the current device *** Re-do *** |
static int |
getSpeed(UsbDevice device)
Gets the speed of a device *** Deprecated *** |
UsbCommPipe |
open(int iface,
int epAddr)
Opens a connection to a device's endpoint |
int |
read(int type,
int rqst,
int value,
int index,
byte[] data,
int timeout)
Reads data from the control endpoint |
int |
read(int type,
int rqst,
int value,
int index,
byte[] data,
int offs,
int leng,
int timeout)
Reads data from the control endpoint |
void |
release(int iface)
Releases an interface |
void |
setConfiguration(int cfgNum)
Sets the active USB configuration for the current device |
void |
setDevice(UsbDevice device)
Sets the current USB device |
void |
setInterface(int iface,
int setting)
Sets the active setting of the specified USB interface of the current device |
int |
write(int type,
int rqst,
int value,
int index,
byte[] data)
Writes data to the control endpoint |
int |
write(int type,
int rqst,
int value,
int index,
byte[] data,
int offs,
int leng)
Writes data to the control endpoint |
| 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 List findDevices(int vid,
int pid,
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.
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)
throws UsbException
The tree of USB devices is searched, looking for the first device whose vendor & product IDs match the ones specified. The current device is set to the resultant device, possibly null.
vid - The vendor IDpid - The product ID
UsbException - if a device is already open.
public UsbDevice findDevice(int vid,
int pid,
String serial)
throws UsbException
The tree of USB devices is searched, looking for the first device whose vendor & product IDs, and serial number, match the ones specified. The serial number may be null to indicate that any serial number will match. 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 findDevice(int vid,
int pid,
int index)
throws UsbException
The tree of USB devices is searched, looking for devices whose vendor & product IDs match the ones specified. From this list of matches, the one with the specified index, starting at 0, is selected. The current device is set to the resultant device, possibly null.
vid - The vendor IDpid - The product IDindex - The index, starting at 0, of the instance of matching
devices to select.
UsbException - if a device is already open.
public UsbDevice findDevice(int vid,
int pid,
String serial,
int index)
throws UsbException
The tree of USB devices is searched, looking for devices whose vendor & product IDs, and serial number, match the ones specified. From this list of matches, the one with the specified index, starting at 0, is selected. The serial number may be null to indicate that any serial number will match. 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.index - The index, starting at 0, of the instance of matching
devices to select.
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 void setConfiguration(int cfgNum)
throws UsbException
Note: fails if an interface has been claimed
cfgNum - The number of the configuration to set
UsbException - if no device set, configuration number is
invalid, or interface claimedpublic 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 void setInterface(int iface,
int setting)
throws UsbException
Note: fails if the interface has not been claimed
iface - The number, starting from 0, of the interface.setting - The setting number, starting from 0, to use.
UsbException - if no device set, setting or interface number is
invalid, or interface not claimed
public static UsbEndpoint getEndpoint(UsbInterface iface,
int epAddr)
iface - The USB interface to useepAddr - The address of the endpoint to get.
public static List getEndpoints(UsbInterface iface)
iface - The USB interface to use
public int getSpeed()
public static int getSpeed(UsbDevice device)
device - The USB device
public void claim(int iface,
boolean force)
throws UsbException
iface - The number, starting from 0, of the interface.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 no device set, device not configured,
interface number invalid, etc
public void release(int iface)
throws UsbException
UsbException
public UsbCommPipe open(int iface,
int epAddr)
throws UsbException
The device is assumed to be configured, and the specified interface is used.
iface - The number of the interface to use, starting at 0.epaddr - The address of the endpoint to be opened.
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 int write(int type,
int rqst,
int value,
int index,
byte[] data)
throws UsbException
type - The request typerqst - The requestvalue - The valueindex - The indexdata - Byte array of data to be written.
UsbException - if the out endpoint is not open.
public int write(int type,
int rqst,
int value,
int index,
byte[] data,
int offs,
int leng)
throws UsbException
type - The request typerqst - The requestvalue - The valueindex - The indexdata - 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(int type,
int rqst,
int value,
int index,
byte[] data,
int timeout)
throws UsbException,
UsbTimeoutException
type - The request typerqst - The requestvalue - The valueindex - The indexdata - 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(int type,
int rqst,
int value,
int index,
byte[] data,
int offs,
int leng,
int timeout)
throws UsbException,
UsbTimeoutException
type - The request typerqst - The requestvalue - The valueindex - The indexdata - 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.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||