usb.windows
Class DeviceImpl

java.lang.Object
  |
  +--usb.core.Device
        |
        +--usb.windows.DeviceImpl
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
JUSB, NonJUSB

public class DeviceImpl
extends Device

Provides access to all USB devices on a bus in limited fashion.
The device descriptor and configuration descriptor provides more information to the devices which are attached to the bus.
The devices itself are instances of the subclass NonJUSB when not using the jUSB driver and of the subclass JUSB when using the jUSB driver.

See Also:
Serialized Form

Field Summary
 Configuration configuration
          The configuration descriptor
 DeviceDescriptor descriptor
          The device descriptor
static int EXTERNAL_HUB
          Corresponds to a hub port and indicates that an external hub is connected to that port.
static int NO_DEVICE_CONNECTED
          Corresponds to a hub port and indicates that no device is connected to that port.
static int USB_DEVICE
          Corresponds to a hub port and indicates that a device is connected to that port.
 
Fields inherited from class usb.core.Device
DEVICE_REMOTE_WAKEUP, DEVICE_SELFPOWERED
 
Method Summary
 int closeHandle(int devHandle)
          Native function that invokes the CloseFile WinAPI function with the given handle
 Device getChild(int port)
          Returns the device connected to this hub's specific port(origin one), or null
 Configuration getConfiguration()
          Returns the default configuration from the device.
 Configuration getConfiguration(int index)
          Not implemented for all devices.
 byte[] getConfigurationDescriptor(int hubHandle, int portIndex)
          Returns the byte stream for the DeviceDescriptor
 DeviceDescriptor getDeviceDescriptor()
          Returns the device dscriptor of the device
 byte[] getDeviceDescriptor(int hubHandle, int portIndex)
          Returns the byte stream for the DeviceDescriptor
 java.lang.String getDeviceFriendlyName()
          Returns the friendly device name
 java.lang.String getDevicePath()
          Returns the device path of that device
 java.lang.String getDriverKeyName()
          Returns the driver key name of that device
 java.lang.String getFriendlyDeviceName()
          The friendly device name of this device
 Device getHub()
          Returns the hub the device is connected to
 int getHubPortNum()
          Returns the port number of the hub where the device is connected to
 int getNumPorts()
          Returns the number of port the hub provides.
 java.lang.String getSpeed()
          Not implemented yet!
 java.lang.String getUniqueDeviceID()
          Returns the unique ID
 int openHandle(java.lang.String devicePath)
          Native function that invokes the CreateFile WinAPI function with the given device path
 void printByteArray(byte[] buf, java.lang.String title, int radix, int numOfBytesLine)
          print a Byte Array to String main purpose is for debugging matters name: The name of the array, just for clarifying the output radix: 0: decimal 2: binary (default 2) numOfByteLine: the number of Byte printed at one line
 
Methods inherited from class usb.core.Device
control, getAddress, getBus, getPortIdentifier, getSPI, getString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_DEVICE_CONNECTED

public static final int NO_DEVICE_CONNECTED
Corresponds to a hub port and indicates that no device is connected to that port.

See Also:
Constant Field Values

EXTERNAL_HUB

public static final int EXTERNAL_HUB
Corresponds to a hub port and indicates that an external hub is connected to that port.

See Also:
Constant Field Values

USB_DEVICE

public static final int USB_DEVICE
Corresponds to a hub port and indicates that a device is connected to that port.

See Also:
Constant Field Values

descriptor

public DeviceDescriptor descriptor
The device descriptor


configuration

public Configuration configuration
The configuration descriptor

Method Detail

openHandle

public int openHandle(java.lang.String devicePath)
Native function that invokes the CreateFile WinAPI function with the given device path

Parameters:
devicePath - A Windows specific device path for that device
Returns:
A Windows handle for that device
if failed it returns USBException.ERROR_INVALID_HANDLE

closeHandle

public int closeHandle(int devHandle)
Native function that invokes the CloseFile WinAPI function with the given handle

Parameters:
devHandle - A valid device handle. This value must correspond to a former call of openHandle
Returns:
1: when success and
-1: when failed to close the device

getDriverKeyName

public java.lang.String getDriverKeyName()
Returns the driver key name of that device


getDeviceDescriptor

public byte[] getDeviceDescriptor(int hubHandle,
                                  int portIndex)
Returns the byte stream for the DeviceDescriptor


getConfigurationDescriptor

public byte[] getConfigurationDescriptor(int hubHandle,
                                         int portIndex)
Returns the byte stream for the DeviceDescriptor


getChild

public Device getChild(int port)
                throws java.io.IOException
Returns the device connected to this hub's specific port(origin one), or null

Specified by:
getChild in class Device
Parameters:
port - The port number of the hub beginning at one to the number of ports the hub provides
java.io.IOException

getConfiguration

public Configuration getConfiguration()
                               throws java.io.IOException
Returns the default configuration from the device. The default configuration is is always configuration at index zero.

Specified by:
getConfiguration in class Device
java.io.IOException

getConfiguration

public Configuration getConfiguration(int index)
                               throws java.io.IOException
Not implemented for all devices. So far it will return always null!

Specified by:
getConfiguration in class Device
Returns:
Always null!
java.io.IOException

getDeviceDescriptor

public DeviceDescriptor getDeviceDescriptor()
Returns the device dscriptor of the device

Specified by:
getDeviceDescriptor in class Device

getHub

public Device getHub()
Returns the hub the device is connected to

Specified by:
getHub in class Device

getHubPortNum

public int getHubPortNum()
Returns the port number of the hub where the device is connected to

Specified by:
getHubPortNum in class Device
Returns:
The port number; value between 1..126

getNumPorts

public int getNumPorts()
Returns the number of port the hub provides.

Specified by:
getNumPorts in class Device
Returns:
The number of ports this hub supports
0 if it is a device

getFriendlyDeviceName

public java.lang.String getFriendlyDeviceName()
The friendly device name of this device

Returns:
The frinedly device name or null if it does not exist

getDevicePath

public java.lang.String getDevicePath()
Returns the device path of that device

Returns:
The device path or null

getDeviceFriendlyName

public java.lang.String getDeviceFriendlyName()
Returns the friendly device name

Returns:
The friendly device name or null

getUniqueDeviceID

public java.lang.String getUniqueDeviceID()
Returns the unique ID

Returns:
The unique ID String or null

printByteArray

public void printByteArray(byte[] buf,
                           java.lang.String title,
                           int radix,
                           int numOfBytesLine)
print a Byte Array to String main purpose is for debugging matters name: The name of the array, just for clarifying the output radix: 0: decimal 2: binary (default 2) numOfByteLine: the number of Byte printed at one line


getSpeed

public java.lang.String getSpeed()
Not implemented yet!
Returns always null!

Specified by:
getSpeed in class Device