- descriptors extended from Usb_Descriptor

- toString()
- javadoc added
- interface changes (Strings, dll)

git-svn-id: https://svn.code.sf.net/p/libusbjava/code/trunk@147 94ad28fe-ef68-46b1-9651-e7ae4fcf1c4c
This commit is contained in:
schlaepfer
2006-05-10 13:15:33 +00:00
parent 5d69fa84bf
commit 2ae9ca02d7
10 changed files with 391 additions and 167 deletions

View File

@@ -1,44 +1,78 @@
package ch.ntb.usb;
public class Usb_Config_Descriptor {
/**
* Represents the descriptor of a USB configuration.<br>
* A USB device can have several different configuration.<br>
* <br>
* 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.<br>
* When the configuration descriptor is read, it returns the entire
* configuration hierarchy which includes all related interface and endpoint
* descriptors. The <code>wTotalLength</code> 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<br>
* <br>
* Bit 7: Reserved, set to 1 (USB 1.0 Bus Powered)<br>
* Bit 6: Self Powered<br>
* Bit 5: Remote Wakeup<br>
* 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);
}
}