From a162e33044822c5fabe57370400eb6075004e5eb Mon Sep 17 00:00:00 2001 From: Klaus Reimer Date: Sun, 16 Feb 2014 13:23:59 +0100 Subject: [PATCH] Add method documentation --- .../org/libusb4java/ConfigDescriptor.java | 43 ++++++++++ .../org/libusb4java/DeviceDescriptor.java | 79 ++++++++++++++++++- .../org/libusb4java/EndpointDescriptor.java | 40 ++++++++++ .../org/libusb4java/InterfaceDescriptor.java | 51 ++++++++++++ 4 files changed, 212 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/libusb4java/ConfigDescriptor.java b/src/main/java/org/libusb4java/ConfigDescriptor.java index 74a9ce4..433c39d 100644 --- a/src/main/java/org/libusb4java/ConfigDescriptor.java +++ b/src/main/java/org/libusb4java/ConfigDescriptor.java @@ -57,20 +57,63 @@ public final class ConfigDescriptor return this.configDescriptorPointer; } + /** + * Returns the size of this descriptor (in bytes). + * + * @return The size of this descriptor (in bytes). + */ public native byte bLength(); + /** + * Returns the descriptor type. Will have value {@link LibUsb#DT_CONFIG} + * in this context. + * + * @return The descriptor type. + */ public native byte bDescriptorType(); + /** + * Returns the total length of data returned for this configuration. + * + * @return The total length of data. + */ public native short wTotalLength(); + /** + * Returns the number of interfaces supported by this configuration. + * + * @return The number of supported interfaces. + */ public native byte bNumInterfaces(); + /** + * Returns the identifier value for this configuration. + * + * @return The identifier value. + */ public native byte bConfigurationValue(); + /** + * Returns the index of string descriptor describing this configuration. + * + * @return The string descriptor index. + */ public native byte iConfiguration(); + /** + * Returns the configuration characteristics. + * + * @return The configuration characteristics. + */ public native byte bmAttributes(); + /** + * Returns the maximum power consumption of the USB device from this bus + * in this configuration when the device is fully operation. Expressed in + * units of 2 mA. + * + * @return The maximum power consumption. + */ public native byte bMaxPower(); /** diff --git a/src/main/java/org/libusb4java/DeviceDescriptor.java b/src/main/java/org/libusb4java/DeviceDescriptor.java index e03b119..c087006 100644 --- a/src/main/java/org/libusb4java/DeviceDescriptor.java +++ b/src/main/java/org/libusb4java/DeviceDescriptor.java @@ -48,7 +48,8 @@ public final class DeviceDescriptor public DeviceDescriptor() { // Assign new buffer. - this.deviceDescriptorBuffer = BufferUtils.allocateByteBuffer(LibUsb.deviceDescriptorStructSize()); + this.deviceDescriptorBuffer = BufferUtils.allocateByteBuffer( + LibUsb.deviceDescriptorStructSize()); } /** @@ -61,32 +62,108 @@ public final class DeviceDescriptor return this.deviceDescriptorPointer; } + /** + * Returns the size of this descriptor (in bytes). + * + * @return The size of this descriptor (in bytes). + */ public native byte bLength(); + /** + * Returns the descriptor type. Will have value {@link LibUsb#DT_DEVICE} + * in this context. + * + * @return The descriptor type. + */ public native byte bDescriptorType(); + /** + * Returns the USB specification release number in binary-coded decimal. + * A value of 0x0200 indicates USB 2.0, 0x0110 indicates USB 1.1, etc. + * + * @return The USB specification release number. + */ public native short bcdUSB(); + /** + * Returns the USB-IF class code for the device. See LibUSB.CLASS_* + * constants. + * + * @return The USB-IF class code. + */ public native byte bDeviceClass(); + /** + * Returns the USB-IF subclass code for the device, qualified by the + * bDeviceClass value. + * + * @return The USB-IF subclass code. + */ public native byte bDeviceSubClass(); + /** + * Returns the USB-IF protocol code for the device, qualified by the + * bDeviceClass and bDeviceSubClass values. + * + * @return The USB-IF protocol code. + */ public native byte bDeviceProtocol(); + /** + * Returns the maximum packet size for endpoint 0. + * + * @return The maximum packet site for endpoint 0. + */ public native byte bMaxPacketSize0(); + /** + * Returns the USB-IF vendor ID. + * + * @return The vendor ID + */ public native short idVendor(); + /** + * Returns the USB-IF product ID. + * + * @return The product ID. + */ public native short idProduct(); + /** + * Returns the device release number in binary-coded decimal. + * + * @return The device release number. + */ public native short bcdDevice(); + /** + * Returns the index of the string descriptor describing manufacturer. + * + * @return The manufacturer string descriptor index. + */ public native byte iManufacturer(); + /** + * Returns the index of the string descriptor describing product. + * + * @return The product string descriptor index. + */ public native byte iProduct(); + /** + * Returns the index of the string descriptor containing device serial + * number. + * + * @return The serial number string descriptor index. + */ public native byte iSerialNumber(); + /** + * Returns the number of possible configurations. + * + * @return The number of possible configurations. + */ public native byte bNumConfigurations(); /** diff --git a/src/main/java/org/libusb4java/EndpointDescriptor.java b/src/main/java/org/libusb4java/EndpointDescriptor.java index 79f8858..e417015 100644 --- a/src/main/java/org/libusb4java/EndpointDescriptor.java +++ b/src/main/java/org/libusb4java/EndpointDescriptor.java @@ -56,16 +56,56 @@ public final class EndpointDescriptor return this.endpointDescriptorPointer; } + /** + * Returns the size of this descriptor (in bytes). + * + * @return The size of this descriptor (in bytes). + */ public native byte bLength(); + /** + * Returns the descriptor type. Will have value {@link LibUsb#DT_ENDPOINT} + * in this context. + * + * @return The descriptor type. + */ public native byte bDescriptorType(); + /** + * The address of the endpoint described by this descriptor. Bits 0:3 are + * the endpoint number. Bits 4:6 are reserved. Bit 7 indicates direction + * (Either {@link LibUsb#ENDPOINT_IN} or {@link LibUsb#ENDPOINT_OUT}). + * + * @return The endpoint address. + */ public native byte bEndpointAddress(); + /** + * Attributes which apply to the endpoint when it is configured using the + * bConfigurationValue. Bits 0:1 determine the transfer type and correspond + * to the LibUsb.TRANSFER_TYPE_* constants. Bits 2:3 are only used for + * isochronous endpoints and correspond to the LibUsb.ISO_SYNC_TYPE_* + * constants. Bits 4:5 are also only used for isochronous endpoints and + * correspond to the LibUsb.ISO_USAGE_TYPE_* constants. Bits 6:7 are + * reserved. + * + * @return The attributes. + */ public native byte bmAttributes(); + /** + * Returns the maximum packet size this endpoint is capable of + * sending/receiving. + * + * @return The maximum packet size. + */ public native short wMaxPacketSize(); + /** + * Returns the interval for polling endpoint for data transfers. + * + * @return The polling interval. + */ public native byte bInterval(); /** diff --git a/src/main/java/org/libusb4java/InterfaceDescriptor.java b/src/main/java/org/libusb4java/InterfaceDescriptor.java index a05f444..3cab011 100644 --- a/src/main/java/org/libusb4java/InterfaceDescriptor.java +++ b/src/main/java/org/libusb4java/InterfaceDescriptor.java @@ -56,22 +56,73 @@ public final class InterfaceDescriptor return this.interfaceDescriptorPointer; } + /** + * Returns the size of this descriptor (in bytes). + * + * @return The size of this descriptor (in bytes). + */ public native byte bLength(); + /** + * Returns the descriptor type. Will have value {@link LibUsb#DT_INTERFACE} + * in this context. + * + * @return The descriptor type. + */ public native byte bDescriptorType(); + /** + * Returns the number of this interface. + * + * @return The interface number. + */ public native byte bInterfaceNumber(); + /** + * Returns the value used to select this alternate setting for this + * interface. + * + * @return The alternate setting value. + */ public native byte bAlternateSetting(); + /** + * Returns the number of endpoints used by this interface (excluding the + * control endpoint). + * + * @return The number of endpoints. + */ public native byte bNumEndpoints(); + /** + * Returns the USB-IF class code for this interface. See LibUSB.CLASS_* + * constants. + * + * @return The USB-IF class code. + */ public native byte bInterfaceClass(); + /** + * Returns the USB-IF subclass code for this interface, qualified by the + * bInterfaceClass value. + * + * @return The USB-IF subclass code. + */ public native byte bInterfaceSubClass(); + /** + * Returns the USB-IF protocol code for this interface, qualified by the + * bInterfaceClass and bInterfaceSubClass values. + * + * @return The USB-IF protocol code. + */ public native byte bInterfaceProtocol(); + /** + * Returns the index of string descriptor describing this interface. + * + * @return The string descriptor index. + */ public native byte iInterface(); /**