- 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:
@@ -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.<br>
|
||||
* A USB device can only have one device descriptor. It specifies some basic,
|
||||
* yet important information about the device.<br>
|
||||
* <br>
|
||||
* 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.<br>
|
||||
* 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.<br>
|
||||
* 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 <a href="http://www.usb.org">www.usb.org</a>)<br>
|
||||
* 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 <a href="http://www.usb.org">www.usb.org</a>)<br>
|
||||
*/
|
||||
public byte bDeviceSubClass;
|
||||
|
||||
/**
|
||||
* Protocol code (Assigned by <a href="http://www.usb.org">www.usb.org</a>)<br>
|
||||
*/
|
||||
public byte bDeviceProtocol;
|
||||
|
||||
/**
|
||||
* Maximum packet size for endpoint zero. <br>
|
||||
* Valid sizes are 8, 16, 32, 64.
|
||||
*/
|
||||
public byte bMaxPacketSize0;
|
||||
|
||||
/**
|
||||
* Vendor ID (Assigned by <a href="http://www.usb.org">www.usb.org</a>)<br>
|
||||
*/
|
||||
public short idVendor;
|
||||
|
||||
/**
|
||||
* Product ID (Assigned by <a href="http://www.usb.org">www.usb.org</a>)<br>
|
||||
*/
|
||||
public short idProduct;
|
||||
|
||||
/**
|
||||
* Device release number<br>
|
||||
* Assigned by the manufacturer of the device.
|
||||
*/
|
||||
public short bcdDevice;
|
||||
|
||||
/**
|
||||
* Index of manufacturer string descriptor<br>
|
||||
* If this value is 0, no string descriptor is used.
|
||||
*/
|
||||
public byte iManufacturer;
|
||||
|
||||
/**
|
||||
* Index of product string descriptor<br>
|
||||
* If this value is 0, no string descriptor is used.
|
||||
*/
|
||||
public byte iProduct;
|
||||
|
||||
/**
|
||||
* Index of serial number string descriptor<br>
|
||||
* 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();
|
||||
}
|
||||
|
||||
};
|
||||
Reference in New Issue
Block a user