1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190
|
/*
* Java libusb wrapper
* Copyright (c) 2005-2006 Andreas Schlaepfer <spandi at users.sourceforge.net>
*
* http://libusbjava.sourceforge.net
* This library is covered by the LGPL, read LGPL.txt for details.
*/
package ch.ntb.usb;
/**
* 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}.
*
*/
public class Usb_Device_Descriptor extends Usb_Descriptor {
/**
* Device and/or interface class codes.
*/
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;
private short bcdUSB;
private byte bDeviceClass;
private byte bDeviceSubClass;
private byte bDeviceProtocol;
private byte bMaxPacketSize0;
private short idVendor;
private short idProduct;
private short bcdDevice;
private byte iManufacturer;
private byte iProduct;
private byte iSerialNumber;
private byte bNumConfigurations;
/**
* Returns the device release number.<br>
* Assigned by the manufacturer of the device.
*
* @return the device release number
*/
public short getBcdDevice() {
return bcdDevice;
}
/**
* Returns the 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
*
* @return the USB specification number to which the device complies to
*/
public short getBcdUSB() {
return bcdUSB;
}
/**
* Returns the 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.
*
* @return the class code
*/
public byte getBDeviceClass() {
return bDeviceClass;
}
/**
* Returns the protocol code (Assigned by <a
* href="http://www.usb.org">www.usb.org</a>)<br>
*
* @return the protocol code
*/
public byte getBDeviceProtocol() {
return bDeviceProtocol;
}
/**
* Returns the subclass code (Assigned by <a
* href="http://www.usb.org">www.usb.org</a>)<br>
*
* @return the subclass code
*/
public byte getBDeviceSubClass() {
return bDeviceSubClass;
}
/**
* Returns the maximum packet size for endpoint zero.<br>
* Valid sizes are 8, 16, 32, 64.
*
* @return the maximum packet size for endpoint zero
*/
public byte getBMaxPacketSize0() {
return bMaxPacketSize0;
}
/**
* Returns the number of possible configurations supported at its current
* speed.<br>
*
* @return the number of possible configurations supported at its current
* speed
*/
public byte getBNumConfigurations() {
return bNumConfigurations;
}
/**
* Returns the product ID (Assigned by <a
* href="http://www.usb.org">www.usb.org</a>)<br>
*
* @return the product ID
*/
public short getIdProduct() {
return idProduct;
}
/**
* Returns the Vendor ID (Assigned by <a
* href="http://www.usb.org">www.usb.org</a>)<br>
*
* @return the Vendor ID
*/
public short getIdVendor() {
return idVendor;
}
/**
* Returns the index of the manufacturer string descriptor.<br>
* If this value is 0, no string descriptor is used.
*
* @return the index of the manufacturer string descriptor
*/
public byte getIManufacturer() {
return iManufacturer;
}
/**
* Returns the index of the product string descriptor.<br>
* If this value is 0, no string descriptor is used.
*
* @return the index of the product string descriptor
*/
public byte getIProduct() {
return iProduct;
}
/**
* Returns the index of serial number string descriptor.<br>
* If this value is 0, no string descriptor is used.
*
* @return the index of serial number string descriptor
*/
public byte getISerialNumber() {
return iSerialNumber;
}
@Override
public String toString() {
StringBuffer sb = new StringBuffer();
sb.append("Usb_Device_Descriptor idVendor: 0x"
+ Integer.toHexString(idVendor & 0xFFFF) + ", idProduct: 0x"
+ Integer.toHexString(idProduct & 0xFFFF));
return sb.toString();
}
}
|