diff --git a/java/src/ch/ntb/usb/LibusbWin.java b/java/src/ch/ntb/usb/LibusbWin.java
index 82e84cd..cae176d 100644
--- a/java/src/ch/ntb/usb/LibusbWin.java
+++ b/java/src/ch/ntb/usb/LibusbWin.java
@@ -1,7 +1,8 @@
package ch.ntb.usb;
/**
- * This class represents the Java Native Interface to the LibUsbWin.dll.
+ * This class represents the Java Native Interface to the LibUsbWin.dll which is
+ * (with some exceptions) a one-to-one representation of the libusb API.
*
*
Project Description
* Java LibUsb-Win32 is a Java wrapper for the LibUsb-Win32 USB library. libusb to the
* Windows operating systems. The library allows user space applications to
* access any USB device on Windows in a generic way without writing any line of
- * kernel driver code.
+ * kernel driver code.
+ *
+ * The API description of this class has been copied from the libusb documentation.
*
* @author schlaepfer
+ * @version DLL: 00.02.00
*
*/
public class LibusbWin {
@@ -184,12 +189,10 @@ public class LibusbWin {
* The handle to the device.
* @param index
* @param langid
- * @param buf
- * @param buflen
- * @return the number of bytes returned in buf or < 0 on error.
+ * @return the descriptor String or null
*/
- public static native int usb_get_string(int dev_handle, int index,
- int langid, String buf, int buflen);
+ public static native String usb_get_string(int dev_handle, int index,
+ int langid);
/**
* usb_get_string_simple is a wrapper around
@@ -199,30 +202,28 @@ public class LibusbWin {
* @param dev_handle
* The handle to the device.
* @param index
- * @param buf
- * @param buflen
- * @return the number of bytes returned in buf or < 0 on error.
+ * @return the descriptor String or null
*/
- public static native int usb_get_string_simple(int dev_handle, int index,
- String buf, int buflen);
+ public static native String usb_get_string_simple(int dev_handle, int index);
/**
* Retrieves a descriptor from the device identified by the type and index
* of the descriptor from the default control pipe.
*
- * See usb_get_descriptor_by_endpoint for a function that
- * allows the control endpoint to be specified.
+ * See {@link #usb_get_descriptor_by_endpoint(int, int, byte, byte, int)}
+ * for a function that allows the control endpoint to be specified.
*
* @param dev_handle
* The handle to the device.
* @param type
* @param index
- * @param buf
* @param size
- * @return the number of bytes read for the descriptor or < 0 on error.
+ * number of charactes which will be retrieved (the length of the
+ * resulting String)
+ * @return the descriptor String or null
*/
- public static native int usb_get_descriptor(int dev_handle, byte type,
- byte index, String buf, int size);
+ public static native String usb_get_descriptor(int dev_handle, byte type,
+ byte index, int size);
/**
* Retrieves a descriptor from the device identified by the type and index
@@ -233,12 +234,13 @@ public class LibusbWin {
* @param ep
* @param type
* @param index
- * @param buf
* @param size
- * @return the number of bytes read for the descriptor or < 0 on error.
+ * number of charactes which will be retrieved (the length of the
+ * resulting String)
+ * @return the descriptor String or null
*/
- public static native int usb_get_descriptor_by_endpoint(int dev_handle,
- int ep, byte type, byte index, String buf, int size);
+ public static native String usb_get_descriptor_by_endpoint(int dev_handle,
+ int ep, byte type, byte index, int size);
// Bulk Transfers
/**
diff --git a/java/src/ch/ntb/usb/USB.java b/java/src/ch/ntb/usb/USB.java
index 26a1622..77b37d7 100644
--- a/java/src/ch/ntb/usb/USB.java
+++ b/java/src/ch/ntb/usb/USB.java
@@ -7,7 +7,7 @@ import ch.ntb.usb.logger.LogUtil;
import ch.ntb.usb.logger.UsbLogger;
/**
- * This class manages all USB devices and defines some USB specific constants.
+ * This class manages all USB devices and defines some USB specific constants.
*
* @author schlaepfer
*
diff --git a/java/src/ch/ntb/usb/Usb_Bus.java b/java/src/ch/ntb/usb/Usb_Bus.java
index 4dbbcf0..b6e6742 100644
--- a/java/src/ch/ntb/usb/Usb_Bus.java
+++ b/java/src/ch/ntb/usb/Usb_Bus.java
@@ -1,23 +1,38 @@
package ch.ntb.usb;
+/**
+ * Represents an USB bus.
+ * This is the root class for the representation of the libusb USB structure.
+ * Zero or more devices may be connected to an USB bus.
+ *
+ * @author schlaepfer
+ *
+ */
public class Usb_Bus {
+ /**
+ * The next and previous bus object
+ */
public Usb_Bus next, prev;
+ /**
+ * Systems String representation of the bus
+ */
public String dirname;
+ /**
+ * Device objects attached to this bus
+ */
public Usb_Device devices;
+ /**
+ * Location in the USB bus linked list
+ */
public long location;
public Usb_Device root_dev;
-
- public String toString() {
- StringBuffer sb = new StringBuffer();
- sb.append("** Usb_Bus **\n");
- sb.append("\tdirname: " + dirname + "\n");
- sb.append("\tlocation: " + location + "\n");
- return sb.toString();
- }
+ public String toString() {
+ return "Usb_Bus " + dirname;
+ }
}
\ No newline at end of file
diff --git a/java/src/ch/ntb/usb/Usb_Config_Descriptor.java b/java/src/ch/ntb/usb/Usb_Config_Descriptor.java
index d6fcace..8ff6c5f 100644
--- a/java/src/ch/ntb/usb/Usb_Config_Descriptor.java
+++ b/java/src/ch/ntb/usb/Usb_Config_Descriptor.java
@@ -1,44 +1,78 @@
package ch.ntb.usb;
-public class Usb_Config_Descriptor {
+/**
+ * Represents the descriptor of a USB configuration.
+ * A USB device can have several different configuration.
+ *
+ * The length of the configuration descriptor is
+ * {@link ch.ntb.usb.Usb_Descriptor#USB_DT_CONFIG_SIZE} and the type is
+ * {@link ch.ntb.usb.Usb_Descriptor#USB_DT_CONFIG}.
+ *
+ * @author schlaepfer
+ *
+ */
+public class Usb_Config_Descriptor extends Usb_Descriptor {
+
+ /**
+ * Maximum number of configuration per device
+ */
public static final int USB_MAXCONFIG = 8;
- public byte bLength;
-
- public byte bDescriptorType;
-
+ /**
+ * Total length in bytes of data returned.
+ * When the configuration descriptor is read, it returns the entire
+ * configuration hierarchy which includes all related interface and endpoint
+ * descriptors. The wTotalLength field reflects the number of
+ * bytes in the hierarchy.
+ */
public short wTotalLength;
+ /**
+ * Number of interfaces
+ */
public byte bNumInterfaces;
+ /**
+ * Value to use as an argument to select this configuration ({@link LibusbWin#usb_set_configuration(int, int)}).
+ */
public byte bConfigurationValue;
+ /**
+ * Index of String descriptor describing this configuration
+ */
public byte iConfiguration;
+ /**
+ * Specifies power parameters for this configuration
+ *
+ * Bit 7: Reserved, set to 1 (USB 1.0 Bus Powered)
+ * Bit 6: Self Powered
+ * Bit 5: Remote Wakeup
+ * Bit 4..0: Reserved, set to 0
+ */
public byte bmAttributes;
+ /**
+ * Maximum power consumption in 2mA units
+ */
public byte MaxPower;
+ /**
+ * USB interface descriptors
+ */
public Usb_Interface[] interface_;
- // TODO: Extra descriptors are not interpreted because of their unknown
- // structure
+ /**
+ * Extra descriptors are currently not interpreted because of their unknown
+ * structure.
+ */
public Usb_Config_Descriptor extra; /* Extra descriptors */
+ // TODO
public int extralen;
public String toString() {
- StringBuffer sb = new StringBuffer();
- sb.append("** Usb_Config_Descriptor **\n");
- sb.append("\tblenght: " + bLength + "\n");
- sb.append("\tbDescriptorType: " + bDescriptorType + "\n");
- sb.append("\tbNumInterfaces: " + bNumInterfaces + "\n");
- sb.append("\tbConfigurationValue: " + bConfigurationValue + "\n");
- sb.append("\tiConfiguration: " + iConfiguration + "\n");
- sb.append("\tbmAttributes: 0x"
- + Integer.toHexString(bmAttributes & 0xFF) + "\n");
- sb.append("\tMaxPower [mA]: " + MaxPower + "\n");
- return sb.toString();
+ return "Usb_Config_Descriptor bNumInterfaces: 0x"
+ + Integer.toHexString(bNumInterfaces);
}
-
}
\ No newline at end of file
diff --git a/java/src/ch/ntb/usb/Usb_Descriptor.java b/java/src/ch/ntb/usb/Usb_Descriptor.java
new file mode 100644
index 0000000..881ac2f
--- /dev/null
+++ b/java/src/ch/ntb/usb/Usb_Descriptor.java
@@ -0,0 +1,42 @@
+package ch.ntb.usb;
+
+/**
+ * Common USB descriptor values.
+ *
+ * @author schlaepfer
+ *
+ */
+public class Usb_Descriptor {
+
+ /**
+ * Descriptor types ({@link #bDescriptorType}).
+ */
+ public static final int USB_DT_DEVICE = 0x01, USB_DT_CONFIG = 0x02,
+ USB_DT_STRING = 0x03, USB_DT_INTERFACE = 0x04,
+ USB_DT_ENDPOINT = 0x05;
+
+ /**
+ * Descriptor types ({@link #bDescriptorType}).
+ */
+ public static final int USB_DT_HID = 0x21, USB_DT_REPORT = 0x22,
+ USB_DT_PHYSICAL = 0x23, USB_DT_HUB = 0x29;
+
+ /**
+ * Descriptor sizes per descriptor type ({@link #bLength}).
+ */
+ public static final int USB_DT_DEVICE_SIZE = 18, USB_DT_CONFIG_SIZE = 9,
+ USB_DT_INTERFACE_SIZE = 9, USB_DT_ENDPOINT_SIZE = 7,
+ USB_DT_ENDPOINT_AUDIO_SIZE = 9 /* Audio extension */,
+ USB_DT_HUB_NONVAR_SIZE = 7;
+
+ /**
+ * Size of descriptor in bytes.
+ */
+ public byte bLength;
+
+ /**
+ * Type of descriptor.
+ */
+ public byte bDescriptorType;
+
+}
diff --git a/java/src/ch/ntb/usb/Usb_Device.java b/java/src/ch/ntb/usb/Usb_Device.java
index f0771b5..b19f5f7 100644
--- a/java/src/ch/ntb/usb/Usb_Device.java
+++ b/java/src/ch/ntb/usb/Usb_Device.java
@@ -1,29 +1,57 @@
package ch.ntb.usb;
+/**
+ * Represents an USB device.
+ * An USB device has one device descriptor and it may have multiple
+ * configuration descriptors.
+ *
+ * @author schlaepfer
+ *
+ */
public class Usb_Device {
+
+ /**
+ * Pointers to the next and previous device
+ */
public Usb_Device next, prev;
+ /**
+ * Systems String representation
+ */
public String filename;
+ /**
+ * Reference to the bus to which this device is connected
+ */
public Usb_Bus bus;
+ /**
+ * USB device descriptor
+ */
public Usb_Device_Descriptor descriptor;
+ /**
+ * USB config descriptors
+ */
public Usb_Config_Descriptor[] config;
+ /**
+ * Number assigned to this device
+ */
public byte devnum;
+ /**
+ * Number of children of this device
+ */
public byte num_children;
+ /**
+ * Reference to the first child
+ */
public Usb_Device children;
public String toString() {
- StringBuffer sb = new StringBuffer();
- sb.append("** Usb_Device **\n");
- sb.append("\tfilename: " + filename + "\n");
- sb.append("\tdevnum: " + devnum + "\n");
- sb.append("\tnum_children: " + num_children + "\n");
- return sb.toString();
+ return "Usb_Device " + filename;
}
}
\ No newline at end of file
diff --git a/java/src/ch/ntb/usb/Usb_Device_Descriptor.java b/java/src/ch/ntb/usb/Usb_Device_Descriptor.java
index 5105e28..58b8e5d 100644
--- a/java/src/ch/ntb/usb/Usb_Device_Descriptor.java
+++ b/java/src/ch/ntb/usb/Usb_Device_Descriptor.java
@@ -1,91 +1,105 @@
package ch.ntb.usb;
-public class Usb_Device_Descriptor {
- /*
- * Device and/or Interface Class codes
+/**
+ * Represents the descriptor of a USB device.
+ * A USB device can only have one device descriptor. It specifies some basic,
+ * yet important information about the device.
+ *
+ * The length of the device descriptor is
+ * {@link ch.ntb.usb.Usb_Descriptor#USB_DT_DEVICE_SIZE} and the type is
+ * {@link ch.ntb.usb.Usb_Descriptor#USB_DT_DEVICE}.
+ *
+ * @author schlaepfer
+ *
+ */
+public class Usb_Device_Descriptor extends Usb_Descriptor {
+ /**
+ * Device and/or interface class codes.
*/
- public static final int USB_CLASS_PER_INTERFACE = 0;
- public static final int USB_CLASS_AUDIO = 1;
- public static final int USB_CLASS_COMM = 2;
- public static final int USB_CLASS_HID = 3;
- public static final int USB_CLASS_PRINTER = 7;
- public static final int USB_CLASS_MASS_STORAGE = 8;
- public static final int USB_CLASS_HUB = 9;
- public static final int USB_CLASS_DATA = 10;
- public static final int USB_CLASS_VENDOR_SPEC = 0xff;
+ public static final int USB_CLASS_PER_INTERFACE = 0, USB_CLASS_AUDIO = 1,
+ USB_CLASS_COMM = 2, USB_CLASS_HID = 3, USB_CLASS_PRINTER = 7,
+ USB_CLASS_MASS_STORAGE = 8, USB_CLASS_HUB = 9, USB_CLASS_DATA = 10,
+ USB_CLASS_VENDOR_SPEC = 0xff;
- /*
- * Descriptor types
+ /**
+ * USB Specification number to which the device complies to.
+ * This field reports the highest version of USB the device supports. The
+ * value is in binary coded decimal with a format of 0xJJMN where JJ is the
+ * major version number, M is the minor version number and N is the sub
+ * minor version number.
+ * Examples: USB 2.0 is reported as 0x0200, USB 1.1 as 0x0110 and USB 1.0 as
+ * 0x100
*/
- public static final int USB_DT_DEVICE = 0x01;
- public static final int USB_DT_CONFIG = 0x02;
- public static final int USB_DT_STRING = 0x03;
- public static final int USB_DT_INTERFACE = 0x04;
- public static final int USB_DT_ENDPOINT = 0x05;
-
- public static final int USB_DT_HID = 0x21;
- public static final int USB_DT_REPORT = 0x22;
- public static final int USB_DT_PHYSICAL = 0x23;
- public static final int USB_DT_HUB = 0x29;
-
- /*
- * Descriptor sizes per descriptor type
- */
- public static final int USB_DT_DEVICE_SIZE = 18;
- public static final int USB_DT_CONFIG_SIZE = 9;
- public static final int USB_DT_INTERFACE_SIZE = 9;
- public static final int USB_DT_ENDPOINT_SIZE = 7;
- public static final int USB_DT_ENDPOINT_AUDIO_SIZE = 9; /* Audio extension */
- public static final int USB_DT_HUB_NONVAR_SIZE = 7;
-
- public byte bLength;
-
- public byte bDescriptorType;
-
public short bcdUSB;
+ /**
+ * Class code (Assigned by www.usb.org)
+ * If equal to zero, each interface specifies it's own class code. If equal
+ * to 0xFF, the class code is vendor specified. Otherwise the field is a
+ * valid class code.
+ */
public byte bDeviceClass;
+ /**
+ * Subclass code (Assigned by www.usb.org)
+ */
public byte bDeviceSubClass;
+ /**
+ * Protocol code (Assigned by www.usb.org)
+ */
public byte bDeviceProtocol;
+ /**
+ * Maximum packet size for endpoint zero.
+ * Valid sizes are 8, 16, 32, 64.
+ */
public byte bMaxPacketSize0;
+ /**
+ * Vendor ID (Assigned by www.usb.org)
+ */
public short idVendor;
+ /**
+ * Product ID (Assigned by www.usb.org)
+ */
public short idProduct;
+ /**
+ * Device release number
+ * Assigned by the manufacturer of the device.
+ */
public short bcdDevice;
+ /**
+ * Index of manufacturer string descriptor
+ * If this value is 0, no string descriptor is used.
+ */
public byte iManufacturer;
+ /**
+ * Index of product string descriptor
+ * If this value is 0, no string descriptor is used.
+ */
public byte iProduct;
+ /**
+ * Index of serial number string descriptor
+ * If this value is 0, no string descriptor is used.
+ */
public byte iSerialNumber;
+ /**
+ * Number of possible configurations supported at its current speed
+ */
public byte bNumConfigurations;
public String toString() {
StringBuffer sb = new StringBuffer();
- sb.append("** Usb_Device_Descriptor **\n");
- sb.append("\tblenght: " + bLength + "\n");
- sb.append("\tbDescriptorType: " + bDescriptorType + "\n");
- sb.append("\tbcdUSB: 0x" + Integer.toHexString(bcdUSB) + "\n");
- sb.append("\tbDeviceClass: " + bDeviceClass + "\n");
- sb.append("\tbDeviceSubClass: " + bDeviceSubClass + "\n");
- sb.append("\tbDeviceProtocol: " + bDeviceProtocol + "\n");
- sb.append("\tbMaxPacketSize0: " + bMaxPacketSize0 + "\n");
- sb.append("\tidVendor: 0x" + Integer.toHexString(idVendor & 0xFFFF)
- + "\n");
- sb.append("\tidProduct: 0x" + Integer.toHexString(idProduct & 0xFFFF)
- + "\n");
- sb.append("\tbcdDevice: " + bcdDevice + "\n");
- sb.append("\tiManufacturer: " + iManufacturer + "\n");
- sb.append("\tiProduct: " + iProduct + "\n");
- sb.append("\tiSerialNumber: " + iSerialNumber + "\n");
- sb.append("\tbNumConfigurations: " + bNumConfigurations + "\n");
+ sb.append("Usb_Device_Descriptor idVendor: 0x"
+ + Integer.toHexString(idVendor & 0xFFFF) + ", idProduct: 0x"
+ + Integer.toHexString(idProduct & 0xFFFF));
return sb.toString();
}
-
};
\ No newline at end of file
diff --git a/java/src/ch/ntb/usb/Usb_Endpoint_Descriptor.java b/java/src/ch/ntb/usb/Usb_Endpoint_Descriptor.java
index f8720da..6392076 100644
--- a/java/src/ch/ntb/usb/Usb_Endpoint_Descriptor.java
+++ b/java/src/ch/ntb/usb/Usb_Endpoint_Descriptor.java
@@ -1,54 +1,102 @@
package ch.ntb.usb;
-public class Usb_Endpoint_Descriptor {
+/**
+ * Represents the descriptor of a USB endpoint.
+ * Endpoint descriptors are used to describe endpoints other than endpoint zero.
+ * Endpoint zero is always assumed to be a control endpoint and is configured
+ * before any descriptors are even requested. The host will use the information
+ * returned from these descriptors to determine the bandwidth requirements of
+ * the bus.
+ *
+ * The length of the configuration descriptor is
+ * {@link ch.ntb.usb.Usb_Descriptor#USB_DT_ENDPOINT_SIZE} and the type is
+ * {@link ch.ntb.usb.Usb_Descriptor#USB_DT_ENDPOINT}.
+ *
+ * @author schlaepfer
+ *
+ */
+public class Usb_Endpoint_Descriptor extends Usb_Descriptor {
+
+ /**
+ * Maximum number of endpoints
+ */
public static final int USB_MAXENDPOINTS = 32;
- /* in bEndpointAddress */
- public static final int USB_ENDPOINT_ADDRESS_MASK = 0x0f;
- public static final int USB_ENDPOINT_DIR_MASK = 0x80;
+ /**
+ * Endpoint address mask (in bEndpointAddress).
+ */
+ public static final int USB_ENDPOINT_ADDRESS_MASK = 0x0f,
+ USB_ENDPOINT_DIR_MASK = 0x80;
- /* in bmAttributes */
+ /**
+ * Endpoint type mask (in bmAttributes).
+ */
public static final int USB_ENDPOINT_TYPE_MASK = 0x03;
- public static final int USB_ENDPOINT_TYPE_CONTROL = 0;
- public static final int USB_ENDPOINT_TYPE_ISOCHRONOUS = 1;
- public static final int USB_ENDPOINT_TYPE_BULK = 2;
- public static final int USB_ENDPOINT_TYPE_INTERRUPT = 3;
-
- public byte bLength;
-
- public byte bDescriptorType;
+
+ /**
+ * Possible endpoint types (in bmAttributes).
+ */
+ public static final int USB_ENDPOINT_TYPE_CONTROL = 0,
+ USB_ENDPOINT_TYPE_ISOCHRONOUS = 1, USB_ENDPOINT_TYPE_BULK = 2,
+ USB_ENDPOINT_TYPE_INTERRUPT = 3;
+ /**
+ * Endpoint Address
+ *
+ * Bits 3..0: Endpoint number
+ * Bits 6..4: Reserved. Set to zero
+ * Bit 7: Direction. 0 = Out, 1 = In (ignored for control endpoints)
+ */
public byte bEndpointAddress;
+ /**
+ * Bits 1..0: Transfer Type (see USB_ENDPOINT_TYPE_XXX).
+ * Bits 7..2: Reserved.
+ *
+ *
+ * If isochronous endpoint:
+ * Bits 3..2: Synchronisation type
+ * 00 = No synchronisation
+ * 01 = Asynchronous
+ * 10 = Adaptive
+ * 11 = Synchronous
+ * Bits 5..4: Usage Type
+ * 00 = Data endpoint
+ * 01 = Feedback endpoint
+ * 10 = Explicit feedback data endpoint
+ * 11 = Reserved
+ *
+ */
public byte bmAttributes;
+ /**
+ * Maximum packet size this endpoint is capable of sending or receiving
+ */
public short wMaxPacketSize;
+ /**
+ * Intervall for polling endpoint data transfers.
+ * Value in frame counts. Ignored for Bulk & Control eEndpoints. Isochronous
+ * endpoints must equal 1 and field may range from 1 to 255 for interrupt
+ * endpoints.
+ */
public byte bInterval;
public byte bRefresh;
public byte bSynchAddress;
- // TODO: Extra descriptors are not interpreted because of their unknown
- // structure
+ /**
+ * Extra descriptors are currently not interpreted because of their unknown
+ * structure.
+ */
public Usb_Endpoint_Descriptor extra; /* Extra descriptors */
+ // TODO
public int extralen;
public String toString() {
- StringBuffer sb = new StringBuffer();
- sb.append("**Usb_Endpoint_Descriptor**\n");
- sb.append("\tblenght: " + bLength + "\n");
- sb.append("\tbDescriptorType: " + bDescriptorType + "\n");
- sb.append("\tbEndpointAddress: 0x"
- + Integer.toHexString(bEndpointAddress & 0xFF) + "\n");
- sb.append("\tbmAttributes: 0x"
- + Integer.toHexString(bmAttributes & 0xFF) + "\n");
- sb.append("\twMaxPacketSize: " + wMaxPacketSize + "\n");
- sb.append("\tbInterval: " + bInterval + "\n");
- sb.append("\tbRefresh: " + bRefresh + "\n");
- sb.append("\tbSynchAddress: " + bSynchAddress + "\n");
- return sb.toString();
+ return "Usb_Endpoint_Descriptor bEndpointAddress: 0x"
+ + Integer.toHexString(bEndpointAddress);
}
}
diff --git a/java/src/ch/ntb/usb/Usb_Interface.java b/java/src/ch/ntb/usb/Usb_Interface.java
index bcf8066..5726f08 100644
--- a/java/src/ch/ntb/usb/Usb_Interface.java
+++ b/java/src/ch/ntb/usb/Usb_Interface.java
@@ -1,17 +1,32 @@
package ch.ntb.usb;
+/**
+ * Represents an USB interface.
+ * An interface is a group of alternate settings of a configuration.
+ *
+ * @author schlaepfer
+ *
+ */
public class Usb_Interface {
+
+ /**
+ * Maximal number of alternate settings
+ */
public static final int USB_MAXALTSETTING = 128; /* Hard limit */
+ /**
+ * Interface descriptors
+ */
public Usb_Interface_Descriptor[] altsetting;
+ /**
+ * Number of alternate settings
+ */
public int num_altsetting;
public String toString() {
- StringBuffer sb = new StringBuffer();
- sb.append("** Usb_Interface **\n");
- sb.append("\tnum_altsetting: " + num_altsetting + "\n");
- return sb.toString();
+ return "Usb_Interface num_altsetting: 0x"
+ + Integer.toHexString(num_altsetting);
}
}
diff --git a/java/src/ch/ntb/usb/Usb_Interface_Descriptor.java b/java/src/ch/ntb/usb/Usb_Interface_Descriptor.java
index ad70235..df47c57 100644
--- a/java/src/ch/ntb/usb/Usb_Interface_Descriptor.java
+++ b/java/src/ch/ntb/usb/Usb_Interface_Descriptor.java
@@ -1,49 +1,75 @@
package ch.ntb.usb;
-public class Usb_Interface_Descriptor {
+/**
+ * Represents the descriptor of a USB interface.
+ * The interface descriptor could be seen as a header or grouping of the
+ * endpoints into a functional group performing a single feature of the device.
+ *
+ * The length of the interface descriptor is
+ * {@link ch.ntb.usb.Usb_Descriptor#USB_DT_INTERFACE_SIZE} and the type is
+ * {@link ch.ntb.usb.Usb_Descriptor#USB_DT_INTERFACE}.
+ *
+ * @author schlaepfer
+ *
+ */
+public class Usb_Interface_Descriptor extends Usb_Descriptor {
+
+ /**
+ * Maximal number of interfaces
+ */
public static final int USB_MAXINTERFACES = 32;
- public byte bLength;
-
- public byte bDescriptorType;
-
+ /**
+ * Number of interface
+ */
public byte bInterfaceNumber;
+ /**
+ * Value used to select alternate setting ({@link LibusbWin#usb_set_altinterface(int, int)}).
+ */
public byte bAlternateSetting;
+ /**
+ * Number of Endpoints used for this interface
+ */
public byte bNumEndpoints;
+ /**
+ * Class code (Assigned by www.usb.org)
+ */
public byte bInterfaceClass;
+ /**
+ * Subclass code (Assigned by www.usb.org)
+ */
public byte bInterfaceSubClass;
+ /**
+ * Protocol code (Assigned by www.usb.org)
+ */
public byte bInterfaceProtocol;
+ /**
+ * Index of String descriptor describing this interface
+ */
public byte iInterface;
+ /**
+ * Endpoint descriptors
+ */
public Usb_Endpoint_Descriptor[] endpoint;
- // TODO: Extra descriptors are not interpreted because of their unknown
- // structure
+ /**
+ * Extra descriptors are currently not interpreted because of their unknown
+ * structure.
+ */
public Usb_Interface_Descriptor extra; /* Extra descriptors */
+ // TODO
public int extralen;
public String toString() {
- StringBuffer sb = new StringBuffer();
- sb.append("** Usb_Interface_Descriptor **\n");
- sb.append("\tblenght: " + bLength + "\n");
- sb.append("\tbDescriptorType: " + bDescriptorType + "\n");
- sb.append("\tbInterfaceNumber: " + bInterfaceNumber + "\n");
- sb.append("\tbAlternateSetting: " + bAlternateSetting + "\n");
- sb.append("\tbNumEndpoints: " + bNumEndpoints + "\n");
- sb.append("\tbInterfaceClass: 0x"
- + Integer.toHexString(bInterfaceClass & 0xFF) + "\n");
- sb.append("\tbInterfaceSubClass: 0x"
- + Integer.toHexString(bInterfaceSubClass & 0xFF) + "\n");
- sb.append("\tbInterfaceProtocol: 0x"
- + Integer.toHexString(bInterfaceProtocol & 0xFF) + "\n");
- sb.append("\tiInterface: " + iInterface + "\n");
- return sb.toString();
+ return "Usb_Interface_Descriptor bNumEndpoints: 0x"
+ + Integer.toHexString(bNumEndpoints);
}
}