From 2bb24448a15b2e096c92e2b86d5915712e9435bc Mon Sep 17 00:00:00 2001 From: Luca Longinotti Date: Mon, 15 Jul 2013 16:31:55 +0200 Subject: [PATCH] Fix formatting properly and remove trailing white-spaces. --- .../ailis/usb4java/libusb/BosDescriptor.java | 32 +- .../libusb/BosDevCapabilityDescriptor.java | 40 +- .../usb4java/libusb/ConfigDescriptor.java | 20 +- .../libusb/ContainerIdDescriptor.java | 38 +- .../de/ailis/usb4java/libusb/Context.java | 10 +- .../java/de/ailis/usb4java/libusb/Device.java | 14 +- .../usb4java/libusb/DeviceDescriptor.java | 14 +- .../ailis/usb4java/libusb/DeviceHandle.java | 12 +- .../de/ailis/usb4java/libusb/DeviceList.java | 12 +- .../usb4java/libusb/DeviceListIterator.java | 4 +- .../usb4java/libusb/EndpointDescriptor.java | 24 +- .../de/ailis/usb4java/libusb/Interface.java | 18 +- .../usb4java/libusb/InterfaceDescriptor.java | 20 +- .../usb4java/libusb/IsoPacketDescriptor.java | 2 +- .../java/de/ailis/usb4java/libusb/LibUsb.java | 518 +++++++++--------- .../usb4java/libusb/LibUsbException.java | 10 +- .../java/de/ailis/usb4java/libusb/Loader.java | 26 +- .../usb4java/libusb/LoaderException.java | 6 +- .../ailis/usb4java/libusb/PollfdListener.java | 12 +- .../libusb/SsEndpointCompanionDescriptor.java | 34 +- .../SsUsbDeviceCapabilityDescriptor.java | 44 +- .../de/ailis/usb4java/libusb/Transfer.java | 62 +-- .../libusb/Usb20ExtensionDescriptor.java | 28 +- .../de/ailis/usb4java/libusb/Version.java | 18 +- 24 files changed, 509 insertions(+), 509 deletions(-) diff --git a/src/main/java/de/ailis/usb4java/libusb/BosDescriptor.java b/src/main/java/de/ailis/usb4java/libusb/BosDescriptor.java index 2478ef3..eb6137c 100644 --- a/src/main/java/de/ailis/usb4java/libusb/BosDescriptor.java +++ b/src/main/java/de/ailis/usb4java/libusb/BosDescriptor.java @@ -1,9 +1,9 @@ /* * Copyright 2013 Klaus Reimer * See LICENSE.md for licensing information. - * + * * Based on libusb : - * + * * Copyright 2001 Johannes Erdfelt * Copyright 2007-2009 Daniel Drake * Copyright 2010-2012 Peter Stuge @@ -23,10 +23,10 @@ import org.apache.commons.lang3.builder.HashCodeBuilder; /** * A structure representing the Binary Device Object Store (BOS) descriptor. - * + * * This descriptor is documented in section 9.6.2 of the USB 3.0 specification. * All multiple-byte fields are represented in host-endian format. - * + * * @author Klaus Reimer (k@ailis.de) */ public final class BosDescriptor @@ -45,7 +45,7 @@ public final class BosDescriptor /** * Returns the native pointer. - * + * * @return The native pointer. */ public long getPointer() @@ -55,42 +55,42 @@ public final class BosDescriptor /** * Returns the size of this descriptor (in bytes). - * + * * @return The descriptor size in bytes; */ public native byte bLength(); /** * Returns the descriptor type. - * + * * @return The descriptor type. */ public native byte bDescriptorType(); /** * Returns the length of this descriptor and all of its sub descriptors. - * + * * @return The total descriptor length. */ public native short wTotalLength(); /** * Returns the number of separate device capability descriptors in the BOS. - * + * * @return The number of device capability descriptors. */ public native byte bNumDeviceCaps(); /** * Returns the array with the device capability descriptors. - * + * * @return The array with device capability descriptors. */ public native BosDevCapabilityDescriptor[] devCapability(); /** * Returns a dump of this descriptor. - * + * * @return The descriptor dump. */ public String dump() @@ -125,11 +125,11 @@ public final class BosDescriptor } final BosDescriptor other = (BosDescriptor) obj; return new EqualsBuilder() - .append(this.bDescriptorType(), other.bDescriptorType()) - .append(this.bLength(), other.bLength()) - .append(this.wTotalLength(), other.wTotalLength()) - .append(this.bNumDeviceCaps(), other.bNumDeviceCaps()) - .append(this.devCapability(), other.devCapability()).isEquals(); + .append(this.bDescriptorType(), other.bDescriptorType()) + .append(this.bLength(), other.bLength()) + .append(this.wTotalLength(), other.wTotalLength()) + .append(this.bNumDeviceCaps(), other.bNumDeviceCaps()) + .append(this.devCapability(), other.devCapability()).isEquals(); } @Override diff --git a/src/main/java/de/ailis/usb4java/libusb/BosDevCapabilityDescriptor.java b/src/main/java/de/ailis/usb4java/libusb/BosDevCapabilityDescriptor.java index 22ed037..9250fc4 100644 --- a/src/main/java/de/ailis/usb4java/libusb/BosDevCapabilityDescriptor.java +++ b/src/main/java/de/ailis/usb4java/libusb/BosDevCapabilityDescriptor.java @@ -1,9 +1,9 @@ /* * Copyright 2013 Klaus Reimer * See LICENSE.md for licensing information. - * + * * Based on libusb : - * + * * Copyright 2001 Johannes Erdfelt * Copyright 2007-2009 Daniel Drake * Copyright 2010-2012 Peter Stuge @@ -27,10 +27,10 @@ import de.ailis.usb4java.utils.DescriptorUtils; /** * A generic representation of a BOS Device Capability descriptor. - * + * * It is advised to check bDevCapabilityType and call the matching * get*Descriptor method to get a structure fully matching the type. - * + * * @author Klaus Reimer (k@ailis.de) */ public final class BosDevCapabilityDescriptor @@ -49,7 +49,7 @@ public final class BosDevCapabilityDescriptor /** * Returns the native pointer. - * + * * @return The native pointer. */ public long getPointer() @@ -59,35 +59,35 @@ public final class BosDevCapabilityDescriptor /** * Returns the size of this descriptor (in bytes). - * + * * @return The descriptor size in bytes; */ public native byte bLength(); /** * Returns the descriptor type. - * + * * @return The descriptor type. */ public native byte bDescriptorType(); /** * Returns the device capability type. - * + * * @return The device capability type. */ public native byte bDevCapabilityType(); /** * Returns the device capability data (bLength - 3 bytes). - * + * * @return The device capability data. */ public native ByteBuffer devCapabilityData(); /** * Returns a dump of this descriptor. - * + * * @return The descriptor dump. */ public String dump() @@ -96,11 +96,11 @@ public final class BosDevCapabilityDescriptor "BOS Device Capability Descriptor:%n" + " bLength %18d%n" + " bDescriptorType %10d%n" + " bDevCapabilityType %7s%n" + " devCapabilityData:%n%s%n", - this.bLength() & 0xff, - this.bDescriptorType() & 0xff, - this.bDevCapabilityType() & 0xff, - DescriptorUtils.dump(this.devCapabilityData()).replaceAll("(?m)^", - " ")); + this.bLength() & 0xff, + this.bDescriptorType() & 0xff, + this.bDevCapabilityType() & 0xff, + DescriptorUtils.dump(this.devCapabilityData()).replaceAll("(?m)^", + " ")); } @@ -121,11 +121,11 @@ public final class BosDevCapabilityDescriptor } final BosDevCapabilityDescriptor other = (BosDevCapabilityDescriptor) obj; return new EqualsBuilder() - .append(this.bDescriptorType(), other.bDescriptorType()) - .append(this.bLength(), other.bLength()) - .append(this.bDevCapabilityType(), other.bDevCapabilityType()) - .append(this.devCapabilityData().array(), - other.devCapabilityData().array()).isEquals(); + .append(this.bDescriptorType(), other.bDescriptorType()) + .append(this.bLength(), other.bLength()) + .append(this.bDevCapabilityType(), other.bDevCapabilityType()) + .append(this.devCapabilityData().array(), + other.devCapabilityData().array()).isEquals(); } @Override diff --git a/src/main/java/de/ailis/usb4java/libusb/ConfigDescriptor.java b/src/main/java/de/ailis/usb4java/libusb/ConfigDescriptor.java index e2ebba6..e835543 100644 --- a/src/main/java/de/ailis/usb4java/libusb/ConfigDescriptor.java +++ b/src/main/java/de/ailis/usb4java/libusb/ConfigDescriptor.java @@ -1,9 +1,9 @@ /* * Copyright 2013 Klaus Reimer * See LICENSE.md for licensing information. - * + * * Based on libusb : - * + * * Copyright 2001 Johannes Erdfelt * Copyright 2007-2009 Daniel Drake * Copyright 2010-2012 Peter Stuge @@ -29,10 +29,10 @@ import de.ailis.usb4java.utils.DescriptorUtils; /** * A structure representing the standard USB configuration descriptor. - * + * * This descriptor is documented in section 9.6.3 of the USB 3.0 specification. * All multiple-byte fields are represented in host-endian format. - * + * * @author Klaus Reimer (k@ailis.de) */ public final class ConfigDescriptor implements UsbConfigurationDescriptor @@ -51,7 +51,7 @@ public final class ConfigDescriptor implements UsbConfigurationDescriptor /** * Returns the native pointer. - * + * * @return The native pointer. */ public long getPointer() @@ -85,31 +85,31 @@ public final class ConfigDescriptor implements UsbConfigurationDescriptor /** * Returns the array with interfaces supported by this configuration. - * + * * @return The array with interfaces. */ public native Interface[] iface(); /** * Extra descriptors. - * + * * If libusb encounters unknown interface descriptors, it will store them * here, should you wish to parse them. - * + * * @return The extra descriptors. */ public native ByteBuffer extra(); /** * Length of the extra descriptors, in bytes. - * + * * @return The extra descriptors length. */ public native int extraLength(); /** * Returns a dump of this descriptor. - * + * * @return The descriptor dump. */ public String dump() diff --git a/src/main/java/de/ailis/usb4java/libusb/ContainerIdDescriptor.java b/src/main/java/de/ailis/usb4java/libusb/ContainerIdDescriptor.java index 0780974..f347fb9 100644 --- a/src/main/java/de/ailis/usb4java/libusb/ContainerIdDescriptor.java +++ b/src/main/java/de/ailis/usb4java/libusb/ContainerIdDescriptor.java @@ -1,9 +1,9 @@ /* * Copyright 2013 Klaus Reimer * See LICENSE.md for licensing information. - * + * * Based on libusb : - * + * * Copyright 2001 Johannes Erdfelt * Copyright 2007-2009 Daniel Drake * Copyright 2010-2012 Peter Stuge @@ -27,11 +27,11 @@ import de.ailis.usb4java.utils.DescriptorUtils; /** * A structure representing the Container ID descriptor. - * + * * This descriptor is documented in section 9.6.2.3 of the USB 3.0 * specification. All multiple-byte fields, except UUIDs, are represented in * host-endian format. - * + * * @author Klaus Reimer (k@ailis.de) */ public final class ContainerIdDescriptor @@ -51,7 +51,7 @@ public final class ContainerIdDescriptor /** * Returns the native pointer. - * + * * @return The native pointer. */ public long getPointer() @@ -61,42 +61,42 @@ public final class ContainerIdDescriptor /** * Returns the size of this descriptor (in bytes). - * + * * @return The descriptor size in bytes; */ public native byte bLength(); /** * Returns the descriptor type. - * + * * @return The descriptor type. */ public native byte bDescriptorType(); /** * Returns the device capability type. - * + * * @return The device capability type. */ public native byte bDevCapabilityType(); /** * Returns the reserved field. - * + * * @return The reserved field. */ public native byte bReserved(); /** * Returns the 128 bit UUID. - * + * * @return The 128 bit UUID. */ public native ByteBuffer containerId(); /** * Returns a dump of this descriptor. - * + * * @return The descriptor dump. */ public String dump() @@ -105,9 +105,9 @@ public final class ContainerIdDescriptor + " bDescriptorType %10d%n" + " bDevCapabilityType %7d%n" + " bReserved %16d%n" + " containerId:%n%s%n", this.bLength() & 0xff, this.bDescriptorType() & 0xff, this - .bDevCapabilityType() & 0xff, this.bReserved() & 0xff, + .bDevCapabilityType() & 0xff, this.bReserved() & 0xff, DescriptorUtils.dump(this.containerId()) - .replaceAll("(?m)^", " ")); + .replaceAll("(?m)^", " ")); } @Override @@ -127,12 +127,12 @@ public final class ContainerIdDescriptor } final ContainerIdDescriptor other = (ContainerIdDescriptor) obj; return new EqualsBuilder() - .append(this.bDescriptorType(), other.bDescriptorType()) - .append(this.bLength(), other.bLength()) - .append(this.bDevCapabilityType(), other.bDevCapabilityType()) - .append(this.bReserved(), other.bReserved()) - .append(this.containerId().array(), other.containerId().array()) - .isEquals(); + .append(this.bDescriptorType(), other.bDescriptorType()) + .append(this.bLength(), other.bLength()) + .append(this.bDevCapabilityType(), other.bDevCapabilityType()) + .append(this.bReserved(), other.bReserved()) + .append(this.containerId().array(), other.containerId().array()) + .isEquals(); } @Override diff --git a/src/main/java/de/ailis/usb4java/libusb/Context.java b/src/main/java/de/ailis/usb4java/libusb/Context.java index cf88a21..ea86eb9 100644 --- a/src/main/java/de/ailis/usb4java/libusb/Context.java +++ b/src/main/java/de/ailis/usb4java/libusb/Context.java @@ -1,9 +1,9 @@ /* * Copyright 2013 Klaus Reimer * See LICENSE.md for licensing information. - * + * * Based on libusb : - * + * * Copyright 2001 Johannes Erdfelt * Copyright 2007-2009 Daniel Drake * Copyright 2010-2012 Peter Stuge @@ -26,13 +26,13 @@ package de.ailis.usb4java.libusb; * {@link LibUsb#setDebug(Context, int)} will not affect the other user of the * library, and {@link LibUsb#exit(Context)} will not destroy resources that the * other user is still using. - * + * * Sessions are created by {@link LibUsb#init(Context)} and destroyed through * {@link LibUsb#exit(Context)}. If your application is guaranteed to only ever * include a single libusb user (i.e. you), you do not have to worry about * contexts: pass NULL in every function call where a context is required. The * default context will be used. - * + * * @author Klaus Reimer (k@ailis.de) */ public final class Context @@ -51,7 +51,7 @@ public final class Context /** * Returns the native pointer to the context structure. - * + * * @return The native pointer to the context structure. */ public long getPointer() diff --git a/src/main/java/de/ailis/usb4java/libusb/Device.java b/src/main/java/de/ailis/usb4java/libusb/Device.java index bae5305..f55a302 100644 --- a/src/main/java/de/ailis/usb4java/libusb/Device.java +++ b/src/main/java/de/ailis/usb4java/libusb/Device.java @@ -1,9 +1,9 @@ /* * Copyright 2013 Klaus Reimer * See LICENSE.md for licensing information. - * + * * Based on libusb : - * + * * Copyright 2001 Johannes Erdfelt * Copyright 2007-2009 Daniel Drake * Copyright 2010-2012 Peter Stuge @@ -20,14 +20,14 @@ package de.ailis.usb4java.libusb; /** * Structure representing a USB device detected on the system. - * + * * This is an opaque type for which you are only ever provided with a pointer, * usually originating from {@link LibUsb#getDeviceList(Context, DeviceList)}. - * + * * Certain operations can be performed on a device, but in order to do any I/O * you will have to first obtain a device handle using * {@link LibUsb#open(Device, DeviceHandle)}. - * + * * Devices are reference counted with {@link LibUsb#refDevice(Device)} and * {@link LibUsb#unrefDevice(Device)}, and are freed when the reference count * reaches 0. New devices presented by @@ -36,7 +36,7 @@ package de.ailis.usb4java.libusb; * decrease the reference count on all devices in the list. * {@link LibUsb#open(Device, DeviceHandle)} adds another reference which is * later destroyed by {@link LibUsb#close(DeviceHandle)}. - * + * * @author Klaus Reimer (k@ailis.de) */ public final class Device @@ -55,7 +55,7 @@ public final class Device /** * Returns the native pointer to the device structure. - * + * * @return The native pointer to the device structure. */ public long getPointer() diff --git a/src/main/java/de/ailis/usb4java/libusb/DeviceDescriptor.java b/src/main/java/de/ailis/usb4java/libusb/DeviceDescriptor.java index 04c1ce7..6cc97be 100644 --- a/src/main/java/de/ailis/usb4java/libusb/DeviceDescriptor.java +++ b/src/main/java/de/ailis/usb4java/libusb/DeviceDescriptor.java @@ -1,9 +1,9 @@ /* * Copyright 2013 Klaus Reimer * See LICENSE.md for licensing information. - * + * * Based on libusb : - * + * * Copyright 2001 Johannes Erdfelt * Copyright 2007-2009 Daniel Drake * Copyright 2010-2012 Peter Stuge @@ -27,10 +27,10 @@ import de.ailis.usb4java.utils.DescriptorUtils; /** * A structure representing the standard USB device descriptor. - * + * * This descriptor is documented in section 9.6.1 of the USB 3.0 specification. * All multiple-byte fields are represented in host-endian format. - * + * * @author Klaus Reimer (k@ailis.de) */ public final class DeviceDescriptor implements UsbDeviceDescriptor @@ -49,7 +49,7 @@ public final class DeviceDescriptor implements UsbDeviceDescriptor /** * Returns the native pointer. - * + * * @return The native pointer. */ public long getPointer() @@ -101,7 +101,7 @@ public final class DeviceDescriptor implements UsbDeviceDescriptor /** * Returns a dump of this descriptor. - * + * * @return The descriptor dump. */ public String dump() @@ -111,7 +111,7 @@ public final class DeviceDescriptor implements UsbDeviceDescriptor /** * Returns a dump of this descriptor. - * + * * @param handle * The USB device handle for resolving string descriptors. If * null then no strings are resolved. diff --git a/src/main/java/de/ailis/usb4java/libusb/DeviceHandle.java b/src/main/java/de/ailis/usb4java/libusb/DeviceHandle.java index 9dc5c73..efa075b 100644 --- a/src/main/java/de/ailis/usb4java/libusb/DeviceHandle.java +++ b/src/main/java/de/ailis/usb4java/libusb/DeviceHandle.java @@ -1,9 +1,9 @@ /* * Copyright 2013 Klaus Reimer * See LICENSE.md for licensing information. - * + * * Based on libusb : - * + * * Copyright 2001 Johannes Erdfelt * Copyright 2007-2009 Daniel Drake * Copyright 2010-2012 Peter Stuge @@ -20,13 +20,13 @@ package de.ailis.usb4java.libusb; /** * Structure representing a handle on a USB device. - * + * * This is an opaque type for which you are only ever provided with a pointer, * usually originating from {@link LibUsb#open(Device, DeviceHandle)}. - * + * * A device handle is used to perform I/O and other operations. When finished * with a device handle, you should call {@link LibUsb#close(DeviceHandle)}. - * + * * @author Klaus Reimer (k@ailis.de) */ public final class DeviceHandle @@ -46,7 +46,7 @@ public final class DeviceHandle /** * Returns the native pointer to the device handle structure. - * + * * @return The native pointer to the device handle structure. */ public long getPointer() diff --git a/src/main/java/de/ailis/usb4java/libusb/DeviceList.java b/src/main/java/de/ailis/usb4java/libusb/DeviceList.java index 20d97af..815e809 100644 --- a/src/main/java/de/ailis/usb4java/libusb/DeviceList.java +++ b/src/main/java/de/ailis/usb4java/libusb/DeviceList.java @@ -1,9 +1,9 @@ /* * Copyright 2013 Klaus Reimer * See LICENSE.md for licensing information. - * + * * Based on libusb : - * + * * Copyright 2001 Johannes Erdfelt * Copyright 2007-2009 Daniel Drake * Copyright 2010-2012 Peter Stuge @@ -23,7 +23,7 @@ import java.util.Iterator; /** * List of devices as returned by * {@link LibUsb#getDeviceList(Context, DeviceList)}. - * + * * @author Klaus Reimer (k@ailis.de) */ public final class DeviceList implements Iterable @@ -45,7 +45,7 @@ public final class DeviceList implements Iterable /** * Returns the native pointer. - * + * * @return The native pointer. */ public long getPointer() @@ -55,7 +55,7 @@ public final class DeviceList implements Iterable /** * Returns the number of devices in the list. - * + * * @return The number of devices in the list. */ public int getSize() @@ -65,7 +65,7 @@ public final class DeviceList implements Iterable /** * Returns the device with the specified index. - * + * * @param index * The device index. * @return The device or null when index is out of bounds. diff --git a/src/main/java/de/ailis/usb4java/libusb/DeviceListIterator.java b/src/main/java/de/ailis/usb4java/libusb/DeviceListIterator.java index 7deeacf..9e385d3 100644 --- a/src/main/java/de/ailis/usb4java/libusb/DeviceListIterator.java +++ b/src/main/java/de/ailis/usb4java/libusb/DeviceListIterator.java @@ -9,7 +9,7 @@ import java.util.Iterator; /** * Iterator for device list. - * + * * @author Klaus Reimer (k@ailis.de) */ final class DeviceListIterator implements Iterator @@ -22,7 +22,7 @@ final class DeviceListIterator implements Iterator /** * Constructor. - * + * * @param devices * The devices list. */ diff --git a/src/main/java/de/ailis/usb4java/libusb/EndpointDescriptor.java b/src/main/java/de/ailis/usb4java/libusb/EndpointDescriptor.java index 00fb06b..0e8f5f1 100644 --- a/src/main/java/de/ailis/usb4java/libusb/EndpointDescriptor.java +++ b/src/main/java/de/ailis/usb4java/libusb/EndpointDescriptor.java @@ -1,9 +1,9 @@ /* * Copyright 2013 Klaus Reimer * See LICENSE.md for licensing information. - * + * * Based on libusb : - * + * * Copyright 2001 Johannes Erdfelt * Copyright 2007-2009 Daniel Drake * Copyright 2010-2012 Peter Stuge @@ -29,10 +29,10 @@ import de.ailis.usb4java.utils.DescriptorUtils; /** * A structure representing the standard USB endpoint descriptor. - * + * * This descriptor is documented in section 9.6.6 of the USB 3.0 specification. * All multiple-byte fields are represented in host-endian format. - * + * * @author Klaus Reimer (k@ailis.de) */ public final class EndpointDescriptor implements UsbEndpointDescriptor @@ -51,7 +51,7 @@ public final class EndpointDescriptor implements UsbEndpointDescriptor /** * Returns the native pointer. - * + * * @return The native pointer. */ public long getPointer() @@ -80,45 +80,45 @@ public final class EndpointDescriptor implements UsbEndpointDescriptor /** * For audio devices only: the rate at which synchronization feedback is * provided. - * + * * @return The synchronization feedback rate. */ public native byte bRefresh(); /** * For audio devices only: the address of the synch endpoint. - * + * * @return The synch endpoint address. */ public native byte bSynchAddress(); /** * Extra descriptors. - * + * * If libusb encounters unknown endpoint descriptors, it will store them * here, should you wish to parse them. - * + * * @return The extra descriptors. */ public native ByteBuffer extra(); /** * Length of the extra descriptors, in bytes. - * + * * @return The extra descriptors length. */ public native int extraLength(); /** * Returns a dump of this descriptor. - * + * * @return The descriptor dump. */ public String dump() { return String.format( "%s%n" + " extralen %17d%n" + " extra:%n" + "%s", DescriptorUtils - .dump(this), this.extraLength(), + .dump(this), this.extraLength(), DescriptorUtils.dump(this.extra()).replaceAll("(?m)^", " ")); } diff --git a/src/main/java/de/ailis/usb4java/libusb/Interface.java b/src/main/java/de/ailis/usb4java/libusb/Interface.java index 2fe8354..942b308 100644 --- a/src/main/java/de/ailis/usb4java/libusb/Interface.java +++ b/src/main/java/de/ailis/usb4java/libusb/Interface.java @@ -1,9 +1,9 @@ /* * Copyright 2013 Klaus Reimer * See LICENSE.md for licensing information. - * + * * Based on libusb : - * + * * Copyright 2001 Johannes Erdfelt * Copyright 2007-2009 Daniel Drake * Copyright 2010-2012 Peter Stuge @@ -23,7 +23,7 @@ import org.apache.commons.lang3.builder.HashCodeBuilder; /** * A collection of alternate settings for a particular USB interface. - * + * * @author Klaus Reimer (k@ailis.de) */ public final class Interface @@ -42,7 +42,7 @@ public final class Interface /** * Returns the native pointer. - * + * * @return The native pointer. */ public long getPointer() @@ -53,21 +53,21 @@ public final class Interface /** * Returns the array with interface descriptors. The length of this array is * determined by the {@link #numAltsetting()} field. - * + * * @return The array with interface descriptors. */ public native InterfaceDescriptor[] altsetting(); /** * Returns the number of alternate settings that belong to this interface. - * + * * @return The number of alternate settings. */ public native int numAltsetting(); /** * Returns a dump of this interface. - * + * * @return The interface dump. */ public String dump() @@ -111,8 +111,8 @@ public final class Interface final Interface other = (Interface) obj; return new EqualsBuilder() - .append(this.altsetting(), other.altsetting()) - .append(this.numAltsetting(), other.numAltsetting()).isEquals(); + .append(this.altsetting(), other.altsetting()) + .append(this.numAltsetting(), other.numAltsetting()).isEquals(); } @Override diff --git a/src/main/java/de/ailis/usb4java/libusb/InterfaceDescriptor.java b/src/main/java/de/ailis/usb4java/libusb/InterfaceDescriptor.java index 5b7ecb3..6778109 100644 --- a/src/main/java/de/ailis/usb4java/libusb/InterfaceDescriptor.java +++ b/src/main/java/de/ailis/usb4java/libusb/InterfaceDescriptor.java @@ -1,9 +1,9 @@ /* * Copyright 2013 Klaus Reimer * See LICENSE.md for licensing information. - * + * * Based on libusb : - * + * * Copyright 2001 Johannes Erdfelt * Copyright 2007-2009 Daniel Drake * Copyright 2010-2012 Peter Stuge @@ -29,10 +29,10 @@ import de.ailis.usb4java.utils.DescriptorUtils; /** * A structure representing the standard USB interface descriptor. - * + * * This descriptor is documented in section 9.6.5 of the USB 3.0 specification. * All multiple-byte fields are represented in host-endian format. - * + * * @author Klaus Reimer (k@ailis.de) */ public final class InterfaceDescriptor implements UsbInterfaceDescriptor @@ -51,7 +51,7 @@ public final class InterfaceDescriptor implements UsbInterfaceDescriptor /** * Returns the native pointer. - * + * * @return The native pointer. */ public long getPointer() @@ -88,31 +88,31 @@ public final class InterfaceDescriptor implements UsbInterfaceDescriptor /** * Returns the array with endpoints. - * + * * @return The array with endpoints. */ public native EndpointDescriptor[] endpoint(); /** * Extra descriptors. - * + * * If libusb encounters unknown interface descriptors, it will store them * here, should you wish to parse them. - * + * * @return The extra descriptors. */ public native ByteBuffer extra(); /** * Length of the extra descriptors, in bytes. - * + * * @return The extra descriptors length. */ public native int extraLength(); /** * Returns a dump of this descriptor. - * + * * @return The descriptor dump. */ public String dump() diff --git a/src/main/java/de/ailis/usb4java/libusb/IsoPacketDescriptor.java b/src/main/java/de/ailis/usb4java/libusb/IsoPacketDescriptor.java index c153ef8..fee336b 100644 --- a/src/main/java/de/ailis/usb4java/libusb/IsoPacketDescriptor.java +++ b/src/main/java/de/ailis/usb4java/libusb/IsoPacketDescriptor.java @@ -16,7 +16,7 @@ public final class IsoPacketDescriptor /** * Returns the native pointer. - * + * * @return The native pointer. */ public long getPointer() diff --git a/src/main/java/de/ailis/usb4java/libusb/LibUsb.java b/src/main/java/de/ailis/usb4java/libusb/LibUsb.java index 9d8dd4d..d921a4b 100644 --- a/src/main/java/de/ailis/usb4java/libusb/LibUsb.java +++ b/src/main/java/de/ailis/usb4java/libusb/LibUsb.java @@ -1,9 +1,9 @@ /* * Copyright 2013 Klaus Reimer * See LICENSE.md for licensing information. - * + * * Based on libusb : - * + * * Copyright 2001 Johannes Erdfelt * Copyright 2007-2009 Daniel Drake * Copyright 2010-2012 Peter Stuge @@ -31,7 +31,7 @@ import de.ailis.usb4java.utils.BufferUtils; /** * Static class providing the constants and functions of libusb. - * + * * @author Klaus Reimer (k@ailis.de) */ public final class LibUsb @@ -330,14 +330,14 @@ public final class LibUsb /** * Device descriptor. - * + * * @see DeviceDescriptor */ public static final byte DT_DEVICE = 0x01; /** * Configuration descriptor. - * + * * @see ConfigDescriptor */ public static final byte DT_CONFIG = 0x02; @@ -347,28 +347,28 @@ public final class LibUsb /** * Interface descriptor. - * + * * @see InterfaceDescriptor */ public static final byte DT_INTERFACE = 0x04; /** * Endpoint descriptor. - * + * * @see EndpointDescriptor */ public static final byte DT_ENDPOINT = 0x05; /** * BOS descriptor. - * + * * @see BosDescriptor */ public static final byte DT_BOS = 0x0F; /** * Device Capability descriptor. - * + * * @see BosDevCapabilityDescriptor */ public static final byte DT_DEVICE_CAPABILITY = 0x10; @@ -390,7 +390,7 @@ public final class LibUsb /** * SuperSpeed Endpoint Companion descriptor. - * + * * @see SsEndpointCompanionDescriptor */ public static final byte DT_SS_ENDPOINT_COMPANION = 0x30; @@ -488,7 +488,7 @@ public final class LibUsb /** * Automatically free transfer buffer during {@link #freeTransfer(Transfer)} - * + * * Please note that this flag is effectively a no-op (set to zero) here in * the Java wrapper, since the ByteBuffer that acts as a buffer for * transfers is allocated by the JVM and is subject to garbage collection @@ -501,7 +501,7 @@ public final class LibUsb /** * Automatically call {@link #freeTransfer(Transfer)} after callback * returns. - * + * * If this flag is set, it is illegal to call * {@link #freeTransfer(Transfer)} from your transfer callback, as this will * result in a double-free when this flag is acted upon. @@ -511,21 +511,21 @@ public final class LibUsb /** * Terminate transfers that are a multiple of the endpoint's wMaxPacketSize * with an extra zero length packet. - * + * * This is useful when a device protocol mandates that each logical request * is terminated by an incomplete packet (i.e. the logical requests are not * separated by other means). - * + * * This flag only affects host-to-device transfers to bulk and interrupt * endpoints. In other situations, it is ignored. - * + * * This flag only affects transfers with a length that is a multiple of the * endpoint's wMaxPacketSize. On transfers of other lengths, this flag has * no effect. Therefore, if you are working with a device that needs a ZLP * whenever the end of the logical request falls on a packet boundary, then * it is sensible to set this flag on every transfer (you do not have to * worry about only setting it on transfers that end on the boundary). - * + * * This flag is currently only supported on Linux. On other systems, * libusb_submit_transfer() will return {@link #ERROR_NOT_SUPPORTED} for * every transfer where this flag is set. @@ -582,20 +582,20 @@ public final class LibUsb /** * Returns the API version of the underlying libusb library. It is defined * as follows: (major << 24) | (minor << 16) | (16 bit incremental) - * + * * @return The API version of the underlying libusb library. */ public static native int getApiVersion(); /** * Initialize libusb. - * + * * This function must be called before calling any other libusb function. - * + * * If you do not provide an output location for a {@link Context}, a default * context will be created. If there was already a default context, it will * be reused (and nothing will be initialized/reinitialized). - * + * * @param context * Optional output location for context pointer. Null to use * default context. Only valid on return code 0. @@ -605,10 +605,10 @@ public final class LibUsb /** * Deinitialize libusb. - * + * * Should be called after closing all open devices and before your * application terminates. - * + * * @param context * The {@link Context} to deinitialize, or NULL for the default * context. @@ -617,27 +617,27 @@ public final class LibUsb /** * Set log message verbosity. - * + * * The default level is {@link #LOG_LEVEL_NONE}, which means no messages are * ever printed. If you choose to increase the message verbosity level, * ensure that your application does not close the stdout/stderr file * descriptors. - * + * * You are advised to use level {@link #LOG_LEVEL_WARNING}. libusb is * conservative with its message logging and most of the time, will only log * messages that explain error conditions and other oddities. This will help * you debug your software. - * + * * If the {@link #LOG_LEVEL_DEBUG} environment variable was set when libusb * was initialized, this function does nothing: the message verbosity is * fixed to the value in the environment variable. - * + * * If libusb was compiled without any message logging, this function does * nothing: you'll never get any messages. - * + * * If libusb was compiled with verbose debug message logging, this function * does nothing: you'll always get messages from all levels. - * + * * @param context * The {@link Context} to operate on, or NULL for the default * context. @@ -648,23 +648,23 @@ public final class LibUsb /** * Returns the version of the libusb runtime. - * + * * @return The version of the libusb runtime. */ public static native Version getVersion(); /** * Returns a list of USB devices currently attached to the system. - * + * * This is your entry point into finding a USB device to operate. - * + * * You are expected to unreference all the devices when you are done with * them, and then free the list with * {@link #freeDeviceList(DeviceList, boolean)}. Note that * {@link #freeDeviceList(DeviceList, boolean)} can unref all the devices * for you. Be careful not to unreference a device you are about to open * until after you have opened it. - * + * * @param context * The context to operate on, or NULL for the default context. * @param list @@ -679,10 +679,10 @@ public final class LibUsb /** * Frees a list of devices previously discovered using * {@link #getDeviceList(Context, DeviceList)}. - * + * * If the unref_devices parameter is set, the reference count of each device * in the list is decremented by 1. - * + * * @param list * The list to free. * @param unrefDevices @@ -693,7 +693,7 @@ public final class LibUsb /** * Get the number of the bus that a device is connected to. - * + * * @param device * A device. * @return The bus number @@ -702,7 +702,7 @@ public final class LibUsb /** * Get the number of the port that a device is connected to. - * + * * @param device * A device * @return The port number (0 if not available). @@ -711,7 +711,7 @@ public final class LibUsb /** * Get the list of all port numbers from root for the specified device. - * + * * @param device * A device. * @param path @@ -725,10 +725,10 @@ public final class LibUsb /** * Get the list of all port numbers from root for the specified device. - * + * * @deprecated Please use {@link #getPortNumbers(Device, ByteBuffer)} * instead. - * + * * @param context * The context. * @param device @@ -746,13 +746,13 @@ public final class LibUsb return getPortNumbers(device, path); } - /** +/** * Get the the parent from the specified device [EXPERIMENTAL]. - * + * * Please note that the reference count of the returned device is not * increased. As such, do not *ever* call {@link #unrefDevice(Device)) * directly on the returned Device. - * + * * @param device * A device * @return The device parent or NULL if not available. You should issue a @@ -769,7 +769,7 @@ public final class LibUsb /** * Get the address of the device on the bus it is connected to. - * + * * @param device * A device. * @return The device address @@ -778,7 +778,7 @@ public final class LibUsb /** * Get the negotiated connection speed for a device. - * + * * @param device * A device. * @return A SPEED code, where {@link #SPEED_UNKNOWN} means that the OS @@ -789,13 +789,13 @@ public final class LibUsb /** * Convenience function to retrieve the wMaxPacketSize value for a * particular endpoint in the active device configuration. - * + * * This function was originally intended to be of assistance when setting up * isochronous transfers, but a design mistake resulted in this function * instead. It simply returns the wMaxPacketSize value without considering * its contents. If you're dealing with isochronous transfers, you probably * want {@link #getMaxIsoPacketSize(Device, int)} instead. - * + * * @param device * A device. * @param endpoint @@ -809,21 +809,21 @@ public final class LibUsb /** * Calculate the maximum packet size which a specific endpoint is capable * sending or receiving in the duration of 1 microframe. - * + * * Only the active configuration is examined. The calculation is based on * the wMaxPacketSize field in the endpoint descriptor as described in * section 9.6.6 in the USB 2.0 specifications. - * + * * If acting on an isochronous or interrupt endpoint, this function will * multiply the value found in bits 0:10 by the number of transactions per * microframe (determined by bits 11:12). Otherwise, this function just * returns the numeric value found in bits 0:10. - * + * * This function is useful for setting up isochronous transfers, for example * you might pass the return value from this function to * {@link #setIsoPacketLengths(Transfer, int)} in order to set the length * field of every isochronous packet in a transfer. - * + * * @param device * A device. * @param endpoint @@ -837,7 +837,7 @@ public final class LibUsb /** * Increment the reference count of a device. - * + * * @param device * The device to reference. * @return The same device. @@ -846,10 +846,10 @@ public final class LibUsb /** * Decrement the reference count of a device. - * + * * If the decrement operation causes the reference count to reach zero, the * device shall be destroyed. - * + * * @param device * the device to unreference. */ @@ -857,15 +857,15 @@ public final class LibUsb /** * Open a device and obtain a device handle. - * + * * A handle allows you to perform I/O on the device in question. - * + * * Internally, this function adds a reference to the device and makes it * available to you through {@link #getDevice(DeviceHandle)}. This reference * is removed during {@link #close(DeviceHandle)}. - * + * * This is a non-blocking function; no requests are sent over the bus. - * + * * @param device * The device to open. * @param handle @@ -881,16 +881,16 @@ public final class LibUsb /** * Convenience function for finding a device with a particular * idVendor/idProduct combination. - * + * * This function is intended for those scenarios where you are using libusb * to knock up a quick test application - it allows you to avoid calling * {@link #getDeviceList(Context, DeviceList)} and worrying about * traversing/freeing the list. - * + * * This function has limitations and is hence not intended for use in real * applications: if multiple devices have the same IDs it will only give you * the first one, etc. - * + * * @param context * The context to operate on, or NULL for the default context. * @param vendorId @@ -905,26 +905,26 @@ public final class LibUsb /** * Close a device handle. - * + * * Should be called on all open handles before your application exits. - * + * * Internally, this function destroys the reference that was added by * {@link #open(Device, DeviceHandle)} on the given device. - * + * * This is a non-blocking function; no requests are sent over the bus. - * + * * @param handle * The handle to close. */ public static native void close(final DeviceHandle handle); - /** +/** * Get the underlying device for a handle. - * + * * Please note that the reference count of the returned device is not * increased. As such, do not *ever* call {@link #unrefDevice(Device)) * directly on the returned Device. - * + * * @param handle * a device handle. * @return The underlying device. @@ -933,17 +933,17 @@ public final class LibUsb /** * Determine the bConfigurationValue of the currently active configuration. - * + * * You could formulate your own control request to obtain this information, * but this function has the advantage that it may be able to retrieve the * information from operating system caches (no I/O involved). - * + * * If the OS does not cache this information, then this function will block * while a control transfer is submitted to retrieve the information. - * + * * This function will return a value of 0 in the config output parameter if * the device is in unconfigured state. - * + * * @param handle * a device handle. * @param config @@ -957,34 +957,34 @@ public final class LibUsb /** * Set the active configuration for a device. - * + * * The operating system may or may not have already set an active * configuration on the device. It is up to your application to ensure the * correct configuration is selected before you attempt to claim interfaces * and perform other operations. - * + * * If you call this function on a device already configured with the * selected configuration, then this function will act as a lightweight * device reset: it will issue a SET_CONFIGURATION request using the current * configuration, causing most USB-related device state to be reset * (altsetting reset to zero, endpoint halts cleared, toggles reset). - * + * * You cannot change/reset configuration if your application has claimed * interfaces - you should free them with * {@link #releaseInterface(DeviceHandle, int)} first. You cannot * change/reset configuration if other applications or drivers have claimed * interfaces. - * + * * A configuration value of -1 will put the device in unconfigured state. * The USB specifications state that a configuration value of 0 does this, * however buggy devices exist which actually have a configuration 0. - * + * * You should always use this function rather than formulating your own * SET_CONFIGURATION control request. This is because the underlying * operating system needs to know when such changes happen. - * + * * This is a blocking function. - * + * * @param handle * a device handle. * @param config @@ -1001,20 +1001,20 @@ public final class LibUsb /** * Claim an interface on a given device handle. - * + * * You must claim the interface you wish to use before you can perform I/O * on any of its endpoints. - * + * * It is legal to attempt to claim an already-claimed interface, in which * case libusb just returns 0 without doing anything. - * + * * Claiming of interfaces is a purely logical operation; it does not cause * any requests to be sent over the bus. Interface claiming is used to * instruct the underlying operating system that your application wishes to * take ownership of the interface. - * + * * This is a non-blocking function. - * + * * @param handle * A device handle. * @param iface @@ -1030,12 +1030,12 @@ public final class LibUsb /** * Release an interface previously claimed with * {@link #claimInterface(DeviceHandle, int)}. - * + * * You should release all claimed interfaces before closing a device handle. - * + * * This is a blocking function. A SET_INTERFACE control request will be sent * to the device, resetting interface state to the first alternate setting. - * + * * @param handle * a device handle. * @param iface @@ -1049,16 +1049,16 @@ public final class LibUsb /** * Activate an alternate setting for an interface. - * + * * The interface must have been previously claimed with * {@link #claimInterface(DeviceHandle, int)}. - * + * * You should always use this function rather than formulating your own * SET_INTERFACE control request. This is because the underlying operating * system needs to know when such changes happen. - * + * * This is a blocking function. - * + * * @param handle * A device handle. * @param interfaceNumber @@ -1075,15 +1075,15 @@ public final class LibUsb /** * Clear the halt/stall condition for an endpoint. - * + * * Endpoints with halt status are unable to receive or transmit data until * the halt condition is stalled. - * + * * You should cancel all pending transfers before attempting to clear the * halt condition. - * + * * This is a blocking function. - * + * * @param handle * A device handle. * @param endpoint @@ -1097,18 +1097,18 @@ public final class LibUsb /** * Perform a USB port reset to reinitialize a device. - * + * * The system will attempt to restore the previous configuration and * alternate settings after the reset has completed. - * + * * If the reset fails, the descriptors change, or the previous state cannot * be restored, the device will appear to be disconnected and reconnected. * This means that the device handle is no longer valid (you should close * it) and rediscover the device. A return code of {@link #ERROR_NOT_FOUND} * indicates when this is the case. - * + * * This is a blocking function which usually incurs a noticeable delay. - * + * * @param handle * a handle of the device to reset * @return 0 on success, {@link #ERROR_NOT_FOUND} if re-enumeration is @@ -1119,12 +1119,12 @@ public final class LibUsb /** * Determine if a kernel driver is active on an interface. - * + * * If a kernel driver is active, you cannot claim the interface, and libusb * will be unable to perform I/O. - * + * * This functionality is not available on Windows. - * + * * @param handle * A device handle. * @param interfaceNumber @@ -1133,7 +1133,7 @@ public final class LibUsb * {@link #ERROR_NO_DEVICE} if the device has been disconnected, * {@link #ERROR_NOT_SUPPORTED} on platforms where the functionality * is not available, another ERROR code on other failure - * + * * @see #detachKernelDriver(DeviceHandle, int) */ public static native int kernelDriverActive(final DeviceHandle handle, @@ -1141,16 +1141,16 @@ public final class LibUsb /** * Detach a kernel driver from an interface. - * + * * If successful, you will then be able to claim the interface and perform * I/O. - * + * * This functionality is not available on Darwin or Windows. - * + * * Note that libusb itself also talks to the device through a special * kernel driver, if this driver is already attached to the device, this * call will not detach it and return {@link #ERROR_NOT_FOUND}. - * + * * @param handle * a device handle * @param interfaceNumber @@ -1161,7 +1161,7 @@ public final class LibUsb * disconnected, {@link #ERROR_NOT_SUPPORTED} on platforms where the * functionality is not available, another ERROR code on other * failure - * + * * @see #kernelDriverActive(DeviceHandle, int) */ public static native int detachKernelDriver(final DeviceHandle handle, @@ -1170,12 +1170,12 @@ public final class LibUsb /** * Re-attach an interface's kernel driver, which was previously detached * using {@link #detachKernelDriver(DeviceHandle, int)}. - * + * * This call is only effective on Linux and returns * {@link #ERROR_NOT_SUPPORTED} on all other platforms. - * + * * This functionality is not available on Darwin or Windows. - * + * * @param handle * A device handle * @param interfaceNumber @@ -1187,7 +1187,7 @@ public final class LibUsb * functionality is not available, {@link #ERROR_BUSY} if the driver * cannot be attached because the interface is claimed by a program * or driver, anotherERROR code on other failure - * + * * @see #kernelDriverActive(DeviceHandle, int) */ public static native int attachKernelDriver(final DeviceHandle handle, @@ -1195,18 +1195,18 @@ public final class LibUsb /** * Enable/disable libusb's automatic kernel driver detachment. - * + * * When this is enabled libusb will automatically detach the kernel driver * on an interface when claiming the interface, and attach it when releasing * the interface. - * + * * Automatic kernel driver detachment is disabled on newly opened device * handles by default. - * + * * On platforms which do not have {@link #CAP_SUPPORTS_DETACH_KERNEL_DRIVER} * this function will return {@link #ERROR_NOT_SUPPORTED}, and libusb will * continue as if this function was never called. - * + * * @param handle * A device handle. * @param enable @@ -1219,7 +1219,7 @@ public final class LibUsb /** * Check at runtime if the loaded library has a given capability. - * + * * @param capability * The capability to check for. * @return True if the running library has the capability, false otherwise. @@ -1229,7 +1229,7 @@ public final class LibUsb /** * Returns a string with the ASCII name of a libusb error or transfer status * code. - * + * * @param errorCode * The libusb error or libusb transfer status code to return the * name of. @@ -1241,7 +1241,7 @@ public final class LibUsb /** * Set the language, and only the language, not the encoding! used for * translatable libusb messages. - * + * * This takes a locale string in the default setlocale format: lang[-region] * or lang[_country_region][.codeset]. Only the lang part of the string is * used, and only 2 letter ISO 639-1 codes are accepted for it, such as @@ -1249,15 +1249,15 @@ public final class LibUsb * This means that functions which return translatable strings will NOT * honor the specified encoding. All strings returned are encoded as UTF-8 * strings. - * + * * If {@link #setLocale(String)} is not called, all messages will be in * English. - * + * * The following functions return translatable strings: libusb_strerror(). * Note that the libusb log messages controlled through * {@link #setDebug(Context, int)} are not translated, they are always in * English. - * + * * @param locale * locale-string in the form of lang[_country_region][.codeset] * or lang[-region], where lang is a 2 letter ISO 639-1 code. @@ -1272,9 +1272,9 @@ public final class LibUsb * Returns a string with a short description of the given error code, this * description is intended for displaying to the end user and will be in the * language set by {@link #setLocale(String)}. - * + * * The messages always start with a capital letter and end without any dot. - * + * * @param errcode * The error code whose description is desired. * @return A short description of the error code. @@ -1283,10 +1283,10 @@ public final class LibUsb /** * Convert a 16-bit value from little-endian to host-endian format. - * + * * On little endian systems, this function does nothing. On big endian * systems, the bytes are swapped. - * + * * @param x * The little-endian value to convert * @return the value in host-endian byte order @@ -1295,10 +1295,10 @@ public final class LibUsb /** * Convert a 16-bit value from host-endian to little-endian format. - * + * * On little endian systems, this function does nothing. On big endian * systems, the bytes are swapped. - * + * * @param x * The host-endian value to convert * @return the value in little-endian byte order @@ -1307,10 +1307,10 @@ public final class LibUsb /** * Get the USB device descriptor for a given device. - * + * * This is a non-blocking function; the device descriptor is cached in * memory. - * + * * @param device * the device * @param descriptor @@ -1323,14 +1323,14 @@ public final class LibUsb /** * Free a device descriptor obtained from * {@link #getDeviceDescriptor(Device, DeviceDescriptor)}. - * + * * It is safe to call this function with a NULL device parameter, in which * case the function simply returns. - * + * * This function is not present in the libusb-1.0 API, but since * getDeviceDescriptor() requires memory to be allocated manually, * a way to deallocate it from Java is required to avoid a memory leak. - * + * * @param descriptor * The device descriptor to free */ @@ -1339,7 +1339,7 @@ public final class LibUsb /** * Retrieve a string descriptor in C style ASCII. - * + * * @param handle * A device handle. * @param index @@ -1357,9 +1357,9 @@ public final class LibUsb * It simply returns the string (maximum length of 127) if possible. If not * possible (NULL handle or 0-index specified or error occured) then null is * returned. - * + * * This method is not part of libusb. - * + * * @param handle * The device handle. * @param index @@ -1387,10 +1387,10 @@ public final class LibUsb /** * Get the USB configuration descriptor for the currently active * configuration. - * + * * This is a non-blocking function which does not involve any requests being * sent to the device. - * + * * @param device * A device. * @param descriptor @@ -1399,7 +1399,7 @@ public final class LibUsb * {@link #freeConfigDescriptor(ConfigDescriptor)} after use. * @return 0 on success, {@link #ERROR_NOT_FOUND} if the device is in * unconfigured state another ERROR code on error - * + * * @see #getConfigDescriptor(Device, int, ConfigDescriptor) */ public static native int getActiveConfigDescriptor(final Device device, @@ -1407,10 +1407,10 @@ public final class LibUsb /** * Get a USB configuration descriptor based on its index. - * + * * This is a non-blocking function which does not involve any requests being * sent to the device. - * + * * @param device * A device. * @param index @@ -1421,7 +1421,7 @@ public final class LibUsb * {@link #freeConfigDescriptor(ConfigDescriptor)} after use. * @return 0 on success {@link #ERROR_NOT_FOUND} if the configuration does * not exist another ERROR code on error. - * + * * @see #getActiveConfigDescriptor(Device, ConfigDescriptor) * @see #getConfigDescriptorByValue(Device, int, ConfigDescriptor) */ @@ -1430,10 +1430,10 @@ public final class LibUsb /** * Get a USB configuration descriptor with a specific bConfigurationValue. - * + * * This is a non-blocking function which does not involve any requests being * sent to the device. - * + * * @param device * A device. * @param value @@ -1445,7 +1445,7 @@ public final class LibUsb * {@link #freeConfigDescriptor(ConfigDescriptor)} after use. * @return 0 on success {@link #ERROR_NOT_FOUND} if the configuration does * not exist another ERROR code on error See also: - * + * * @see #getActiveConfigDescriptor(Device, ConfigDescriptor) * @see #getConfigDescriptor(Device, int, ConfigDescriptor) */ @@ -1456,10 +1456,10 @@ public final class LibUsb * Free a configuration descriptor obtained from * {@link #getConfigDescriptor(Device, int, ConfigDescriptor)} or * {@link #getActiveConfigDescriptor(Device, ConfigDescriptor)}. - * + * * It is safe to call this function with a NULL config parameter, in which * case the function simply returns. - * + * * @param descriptor * The configuration descriptor to free */ @@ -1468,7 +1468,7 @@ public final class LibUsb /** * Get an endpoints superspeed endpoint companion descriptor (if any). - * + * * @param context * The context to operate on, or NULL for the default context. * @param endpointDescriptor @@ -1490,10 +1490,10 @@ public final class LibUsb * Free a superspeed endpoint companion descriptor obtained from * {@link #getSsEndpointCompanionDescriptor(Context, EndpointDescriptor, SsEndpointCompanionDescriptor)} * . - * + * * It is safe to call this function with a NULL parameter, in which case the * function simply returns. - * + * * @param companionDescriptor * The superspeed endpoint companion descriptor to free */ @@ -1503,7 +1503,7 @@ public final class LibUsb /** * Get a Binary Object Store (BOS) descriptor. This is a BLOCKING function, * which will send requests to the device. - * + * * @param handle * The handle of an open libusb device. * @param descriptor @@ -1519,10 +1519,10 @@ public final class LibUsb /** * Free a BOS descriptor obtained from * {@link #getBosDescriptor(DeviceHandle, BosDescriptor)}. - * + * * It is safe to call this function with a NULL parameter, in which case the * function simply returns. - * + * * @param descriptor * The BOS descriptor to free. */ @@ -1530,7 +1530,7 @@ public final class LibUsb /** * Get an USB 2.0 Extension descriptor. - * + * * @param context * The context to operate on, or NULL for the default context. * @param devCapDescriptor @@ -1551,10 +1551,10 @@ public final class LibUsb * Free a USB 2.0 Extension descriptor obtained from * {@link #getUsb20ExtensionDescriptor(Context, BosDevCapabilityDescriptor, Usb20ExtensionDescriptor)} * . - * + * * It is safe to call this function with a NULL parameter, in which case * the function simply returns. - * + * * @param extensionDescriptor * The USB 2.0 Extension descriptor to free. */ @@ -1563,7 +1563,7 @@ public final class LibUsb /** * Get a SuperSpeed USB Device Capability descriptor. - * + * * @param context * The context to operate on, or NULL for the default context. * @param devCapDescriptor @@ -1586,10 +1586,10 @@ public final class LibUsb * Free a SuperSpeed USB Device Capability descriptor obtained from * {@link #getSsUsbDeviceCapabilityDescriptor(Context, BosDevCapabilityDescriptor, SsUsbDeviceCapabilityDescriptor)} * . - * + * * It is safe to call this function with a NULL parameter, * in which case the function simply returns. - * + * * @param ssUsbDeviceCapabilityDescriptor * The descriptor to free. */ @@ -1598,7 +1598,7 @@ public final class LibUsb /** * Get a Container ID descriptor. - * + * * @param context * The context to operate on, or NULL for the default context. * @param devCapDescriptor @@ -1619,10 +1619,10 @@ public final class LibUsb * Free a Container ID descriptor obtained from * {@link #getContainerIdDescriptor(Context, BosDevCapabilityDescriptor, ContainerIdDescriptor)} * . - * + * * It is safe to call this function with a NULL parameter, in which case * the function simply returns. - * + * * @param containerIdDescriptor * The descriptor to free. */ @@ -1631,10 +1631,10 @@ public final class LibUsb /** * Retrieve a descriptor from the default control pipe. - * + * * This is a convenience function which formulates the appropriate control * message to retrieve the descriptor. - * + * * @param handle * A device handle. * @param type @@ -1644,7 +1644,7 @@ public final class LibUsb * @param data * Output buffer for descriptor * @return number of bytes returned in data, or ERROR code on failure - * + * */ public static int getDescriptor(final DeviceHandle handle, final byte type, final byte index, final ByteBuffer data) @@ -1655,11 +1655,11 @@ public final class LibUsb /** * Retrieve a descriptor from a device. - * + * * This is a convenience function which formulates the appropriate control * message to retrieve the descriptor. The string returned is Unicode, as * detailed in the USB specifications. - * + * * @param handle * A device handle. * @param index @@ -1680,13 +1680,13 @@ public final class LibUsb /** * Perform a USB control transfer. - * + * * The direction of the transfer is inferred from the bmRequestType field of * the setup packet. - * + * * The wValue, wIndex and wLength fields values should be given in * host-endian byte order. - * + * * @param handle * A handle for the device to communicate with. * @param bmRequestType @@ -1716,25 +1716,25 @@ public final class LibUsb /** * Perform a USB bulk transfer. - * + * * The direction of the transfer is inferred from the direction bits of the * endpoint address. - * + * * For bulk reads, the length field indicates the maximum length of data you * are expecting to receive. If less data arrives than expected, this * function will return that data, so be sure to check the transferred * output parameter. - * + * * You should also check the transferred parameter for bulk writes. Not all * of the data may have been written. - * + * * Also check transferred when dealing with a timeout error code. libusb * may have to split your transfer into a number of chunks to satisfy * underlying O/S requirements, meaning that the timeout may expire after * the first few chunks have completed. libusb is careful not to lose any * data that may have been transferred; do not assume that timeout * conditions indicate a complete lack of I/O. - * + * * @param handle * A handle for the device to communicate with. * @param endpoint @@ -1761,27 +1761,27 @@ public final class LibUsb /** * Perform a USB interrupt transfer. - * + * * The direction of the transfer is inferred from the direction bits of the * endpoint address. - * + * * For interrupt reads, the length field indicates the maximum length of * data you are expecting to receive. If less data arrives than expected, * this function will return that data, so be sure to check the transferred * output parameter. - * + * * You should also check the transferred parameter for interrupt writes. Not * all of the data may have been written. - * + * * Also check transferred when dealing with a timeout error code. libusb * may have to split your transfer into a number of chunks to satisfy * underlying O/S requirements, meaning that the timeout may expire after * the first few chunks have completed. libusb is careful not to lose any * data that may have been transferred; do not assume that timeout * conditions indicate a complete lack of I/O. - * + * * The default endpoint bInterval value is used as the polling interval. - * + * * @param handle * A handle for the device to communicate with. * @param endpoint @@ -1807,20 +1807,20 @@ public final class LibUsb /** * Attempt to acquire the event handling lock. - * + * * This lock is used to ensure that only one thread is monitoring libusb * event sources at any one time. - * + * * You only need to use this lock if you are developing an application which * calls poll() or select() on libusb's file descriptors directly. If you * stick to libusb's event handling loop functions (e.g. * {@link #handleEvents(Context)}) then you do not need to be concerned with * this locking. - * + * * While holding this lock, you are trusted to actually be handling events. * If you are no longer handling events, you must call * {@link #unlockEvents(Context)} as soon as possible. - * + * * @param context * The context to operate on, or NULL for the default context. * @return 0 if the lock was obtained successfully, 1 if the lock was not @@ -1831,20 +1831,20 @@ public final class LibUsb /** * Acquire the event handling lock, blocking until successful acquisition if * it is contended. - * + * * This lock is used to ensure that only one thread is monitoring libusb * event sources at any one time. - * + * * You only need to use this lock if you are developing an application which * calls poll() or select() on libusb's file descriptors directly. If you * stick to libusb's event handling loop functions (e.g. * {@link #handleEvents(Context)}) then you do not need to be concerned with * this locking. - * + * * While holding this lock, you are trusted to actually be handling events. * If you are no longer handling events, you must call * {@link #unlockEvents(Context)} as soon as possible. - * + * * @param context * The context to operate on, or NULL for the default context. */ @@ -1853,10 +1853,10 @@ public final class LibUsb /** * Release the lock previously acquired with {@link #tryLockEvents(Context)} * or {@link #lockEvents(Context)}. - * + * * Releasing this lock will wake up any threads blocked on * {@link #waitForEvent(Context, long)}. - * + * * @param context * The context to operate on, or NULL for the default context */ @@ -1864,21 +1864,21 @@ public final class LibUsb /** * Determine if it is still OK for this thread to be doing event handling. - * + * * Sometimes, libusb needs to temporarily pause all event handlers, and * this is the function you should use before polling file descriptors to * see if this is the case. - * + * * If this function instructs your thread to give up the events lock, you * should just continue the usual logic that is documented in Multi-threaded * applications and asynchronous I/O. On the next iteration, your thread * will fail to obtain the events lock, and will hence become an event * waiter. - * + * * This function should be called while the events lock is held: you don't * need to worry about the results of this function if your thread is not * the current event handler. - * + * * @param context * The context to operate on, or NULL for the default context. * @return 1 if event handling can start or continue, 0 if this thread must @@ -1889,7 +1889,7 @@ public final class LibUsb /** * Determine if an active thread is handling events (i.e. if anyone is * holding the event handling lock). - * + * * @param context * The context to operate on, or NULL for the default context. * @return 1 if a thread is handling events, 0 if there are no threads @@ -1899,21 +1899,21 @@ public final class LibUsb /** * Acquire the event waiters lock. - * + * * This lock is designed to be obtained under the situation where you want * to be aware when events are completed, but some other thread is event * handling so calling {@link #handleEvents(Context)} is not allowed. - * + * * You then obtain this lock, re-check that another thread is still handling * events, then call {@link #waitForEvent(Context, long)}. - * + * * You only need to use this lock if you are developing an application which * calls poll() or select() on libusb's file descriptors directly, and may * potentially be handling events from 2 threads simultaenously. If you * stick to libusb's event handling loop functions (e.g. * {@link #handleEvents(Context)}) then you do not need to be concerned with * this locking. - * + * * @param context * The context to operate on, or NULL for the default context. */ @@ -1921,7 +1921,7 @@ public final class LibUsb /** * Release the event waiters lock. - * + * * @param context * The context to operate on, or NULL for the default context. */ @@ -1929,12 +1929,12 @@ public final class LibUsb /** * Wait for another thread to signal completion of an event. - * + * * Must be called with the event waiters lock held, see * {@link #lockEventWaiters(Context)}. - * + * * This function will block until any of the following conditions are met: - * + * * The timeout expires A transfer completes A thread releases the event * handling lock through {@link #unlockEvents(Context)} Condition 1 is * obvious. Condition 2 unblocks your thread after the callback for the @@ -1942,16 +1942,16 @@ public final class LibUsb * the thread that was previously handling events is no longer doing so, so * if any events are to complete, another thread needs to step up and start * event handling. - * + * * This function releases the event waiters lock before putting your thread * to sleep, and reacquires the lock as it is being woken up. - * + * * @param context * The context to operate on, or NULL for the default context. * @param timeout * Maximum timeout for this blocking function. A 0 value * indicates unlimited timeout. - * + * * @return 0 after a transfer completes or another thread stops event * handling, 1 if the timeout expired */ @@ -1960,28 +1960,28 @@ public final class LibUsb /** * Handle any pending events. - * + * * libusb determines "pending events" by checking if any timeouts have * expired and by checking the set of file descriptors for activity. - * + * * If a zero timeval is passed, this function will handle any * already-pending events and then immediately return in non-blocking style. - * + * * If a non-zero timeval is passed and no events are currently pending, this * function will block waiting for events to handle up until the specified * timeout. If an event arrives or a signal is raised, this function will * return early. - * + * * If the parameter completed is not NULL then after obtaining the event * handling lock this function will return immediately if the integer * pointed to is not 0. This allows for race free waiting for the completion * of a specific transfer. - * + * * The only way to implement this in Java is by passing a direct buffer, and * then accessing memory directly. IntBuffers can be direct, if they are * created as a view of a direct ByteBuffer, as in the following code: * ByteBuffer.allocateDirect(Integer.SIZE / Byte.SIZE).asIntBuffer() - * + * * @param context * the context to operate on, or NULL for the default context * @param timeout @@ -1996,17 +1996,17 @@ public final class LibUsb /** * Handle any pending events. - * + * * Like {@link #handleEventsTimeoutCompleted(Context, long, IntBuffer)}, but * without the completed parameter, calling this function is equivalent to * calling {@link #handleEventsTimeoutCompleted(Context, long, IntBuffer)} * with a NULL completed parameter. - * + * * This function is kept primarily for backwards compatibility. All new code * should call {@link #handleEventsCompleted(Context, IntBuffer)} or * {@link #handleEventsTimeoutCompleted(Context, long, IntBuffer)} to avoid * race conditions. - * + * * @param context * The context to operate on, or NULL for the default context * @param timeout @@ -2019,17 +2019,17 @@ public final class LibUsb /** * Handle any pending events in blocking mode. - * + * * There is currently a timeout hardcoded at 60 seconds but we plan to make * it unlimited in future. For finer control over whether this function is * blocking or non-blocking, or for control over the timeout, use * {@link #handleEventsTimeoutCompleted(Context, long, IntBuffer)} instead. - * + * * This function is kept primarily for backwards compatibility. All new code * should call {@link #handleEventsCompleted(Context, IntBuffer)} or * {@link #handleEventsTimeoutCompleted(Context, long, IntBuffer)} to avoid * race conditions. - * + * * @param context * The context to operate on, or NULL for the default context. * @return 0 on success, or a ERROR code on failure. @@ -2038,14 +2038,14 @@ public final class LibUsb /** * Handle any pending events in blocking mode. - * + * * Like {@link #handleEvents(Context)}, with the addition of a completed * parameter to allow for race free waiting for the completion of a specific * transfer. - * + * * See {@link #handleEventsTimeoutCompleted(Context, long, IntBuffer)} for * details on the completed parameter. - * + * * @param context * The context to operate on, or NULL for the default context. * @param completed @@ -2058,17 +2058,17 @@ public final class LibUsb /** * Handle any pending events by polling file descriptors, without checking * if any other threads are already doing so. - * + * * Must be called with the event lock held, see {@link #lockEvents(Context)} * . - * + * * This function is designed to be called under the situation where you have * taken the event lock and are calling poll()/select() directly on * libusb's file descriptors (as opposed to using * {@link #handleEvents(Context)} or similar). You detect events on * libusb's descriptors, so you then call this function with a zero timeout * value (while still holding the event lock). - * + * * @param context * The context to operate on, or NULL for the default context. * @param timeout @@ -2082,24 +2082,24 @@ public final class LibUsb /** * Determines whether your application must apply special timing * considerations when monitoring libusb's file descriptors. - * + * * This function is only useful for applications which retrieve and poll * libusb's file descriptors in their own main loop (The more advanced * option). - * + * * Ordinarily, libusb's event handler needs to be called into at specific * moments in time (in addition to times when there is activity on the file * descriptor set). The usual approach is to use * {@link #getNextTimeout(Context, IntBuffer)} to learn about when the next * timeout occurs, and to adjust your poll()/select() timeout accordingly so * that you can make a call into the library at that time. - * + * * Some platforms supported by libusb do not come with this baggage - any * events relevant to timing will be represented by activity on the file * descriptor set, and {@link #getNextTimeout(Context, IntBuffer)} will * always return 0. This function allows you to detect whether you are * running on such a platform. - * + * * @param context * The context to operate on, or NULL for the default context * @return 0 if you must call into libusb at times determined by @@ -2111,30 +2111,30 @@ public final class LibUsb /** * Determine the next internal timeout that libusb needs to handle. - * + * * You only need to use this function if you are calling poll() or select() * or similar on libusb's file descriptors yourself - you do not need to * use it if you are calling {@link #handleEvents(Context)} or a variant * directly. - * + * * You should call this function in your main loop in order to determine how * long to wait for select() or poll() to return results. libusb needs to * be called into at this timeout, so you should use it as an upper bound on * your select() or poll() call. - * + * * When the timeout has expired, call into * {@link #handleEventsTimeout(Context, long)} (perhaps in non-blocking * mode) so that libusb can handle the timeout. - * + * * This function may return 1 (success) and an all-zero timeval. If this is * the case, it indicates that libusb has a timeout that has already * expired so you should call {@link #handleEventsTimeout(Context, long)} or * similar immediately. A return code of 0 indicates that there are no * pending timeouts. - * + * * On some platforms, this function will always returns 0 (no pending * timeouts). See Notes on time-based events. - * + * * @param context * The context to operate on, or NULL for the default context * @param timeout @@ -2149,21 +2149,21 @@ public final class LibUsb /** * Register notification functions for file descriptor additions/removals. - * + * * These functions will be invoked for every new or removed file descriptor * that libusb uses as an event source. - * + * * To remove notifiers, pass NULL values for the function pointers. - * + * * Note that file descriptors may have been added even before you register * these notifiers (e.g. at {@link #init(Context)} time). - * + * * Additionally, note that the removal notifier may be called during * {@link #exit(Context)} (e.g. when it is closing file descriptors that * were opened and added to the poll set at {@link #init(Context)} time). If * you don't want this, remove the notifiers immediately before calling * {@link #exit(Context)}. - * + * * @param context * The context to operate on, or NULL for the default context. * @param listener @@ -2204,7 +2204,7 @@ public final class LibUsb /** * Callback function, invoked when a new file descriptor should be added to * the set of file descriptors monitored for events. - * + * * @param fd * The new file descriptor, * @param events @@ -2226,7 +2226,7 @@ public final class LibUsb /** * Called internally from JNI when a pollfd was removed. - * + * * @param fd * The removed file descriptor. * @param contextId @@ -2247,7 +2247,7 @@ public final class LibUsb /** * Configures libusb to inform this class about pollfd additions and * removals. - * + * * @param context * The context to operate on, or NULL for the default context * @param contextId @@ -2259,7 +2259,7 @@ public final class LibUsb /** * Tells libusb to stop informing this class about pollfd additions and * removals. - * + * * @param context * The context to operate on, or NULL for the default context */ @@ -2267,11 +2267,11 @@ public final class LibUsb /** * Allocate a libusb transfer without support for isochronous transfers. - * + * * The returned transfer is pre-initialized for you. When the new transfer * is no longer needed, it should be freed with * {@link #freeTransfer(Transfer)}. - * + * * @return A newly allocated transfer, or NULL on error */ public static Transfer allocTransfer() @@ -2282,24 +2282,24 @@ public final class LibUsb /** * Allocate a libusb transfer with a specified number of isochronous packet * descriptors. - * + * * The returned transfer is pre-initialized for you. When the new transfer * is no longer needed, it should be freed with * {@link #freeTransfer(Transfer)}. - * + * * Transfers intended for non-isochronous endpoints (e.g. control, bulk, * interrupt) should specify an iso_packets count of zero. - * + * * For transfers intended for isochronous endpoints, specify an appropriate * number of packet descriptors to be allocated as part of the transfer. The * returned transfer is not specially initialized for isochronous I/O; you * are still required to call the {@link Transfer#setNumIsoPackets(int)} a * {@link Transfer#setType(int)} methods accordingly. - * + * * It is safe to allocate a transfer with some isochronous packets and then * use it on a non-isochronous endpoint. If you do this, ensure that at time * of submission, numIsoPackets is 0 and that type is set appropriately. - * + * * @param isoPackets * Number of isochronous packet descriptors to allocate. * @return A newly allocated transfer, or NULL on error @@ -2308,19 +2308,19 @@ public final class LibUsb /** * Free a transfer structure. - * + * * This should be called for all transfers allocated with * {@link #allocTransfer(int)}. - * + * * Please refer to {@link #TRANSFER_FREE_BUFFER} for an explanation * of how buffers are freed. - * + * * It is legal to call this function with a NULL transfer. In this case, the * function will simply return safely. - * + * * It is not legal to free an active transfer (one which has been submitted * and has not yet completed). - * + * * @param transfer * The transfer to free */ @@ -2328,9 +2328,9 @@ public final class LibUsb /** * Submit a transfer. - * + * * This function will fire off the USB transfer and then return immediately. - * + * * @param transfer * The transfer to submit * @return 0 on success, {@link #LIBUSB_ERROR_NO_DEVICE} if the device has @@ -2346,12 +2346,12 @@ public final class LibUsb /** * Asynchronously cancel a previously submitted transfer. - * + * * This function returns immediately, but this does not indicate * cancellation * is complete. Your callback function will be invoked at some later time * with a transfer status of {@link #LIBUSB_TRANSFER_CANCELLED}. - * + * * @param transfer * The transfer to cancel * @return 0 on success, {@link #LIBUSB_ERROR_NOT_FOUND} if the transfer is diff --git a/src/main/java/de/ailis/usb4java/libusb/LibUsbException.java b/src/main/java/de/ailis/usb4java/libusb/LibUsbException.java index 1785816..eda5622 100644 --- a/src/main/java/de/ailis/usb4java/libusb/LibUsbException.java +++ b/src/main/java/de/ailis/usb4java/libusb/LibUsbException.java @@ -1,9 +1,9 @@ /* * Copyright 2013 Klaus Reimer * See LICENSE.md for licensing information. - * + * * Based on libusb : - * + * * Copyright 2001 Johannes Erdfelt * Copyright 2007-2009 Daniel Drake * Copyright 2010-2012 Peter Stuge @@ -22,7 +22,7 @@ import javax.usb.UsbException; /** * libusb-specific USB exception. - * + * * @author Klaus Reimer (k@ailis.de) */ public final class LibUsbException extends UsbException @@ -35,7 +35,7 @@ public final class LibUsbException extends UsbException /** * Constructor. - * + * * @param message * The error message. * @param errorCode @@ -50,7 +50,7 @@ public final class LibUsbException extends UsbException /** * Returns the error code. - * + * * @return The error code */ public int getErrorCode() diff --git a/src/main/java/de/ailis/usb4java/libusb/Loader.java b/src/main/java/de/ailis/usb4java/libusb/Loader.java index 651b49e..0cf08e9 100644 --- a/src/main/java/de/ailis/usb4java/libusb/Loader.java +++ b/src/main/java/de/ailis/usb4java/libusb/Loader.java @@ -14,7 +14,7 @@ import java.net.URL; /** * Utility class to load native libraries from classpath. - * + * * @author Klaus Reimer (k@ailis.de) */ public final class Loader @@ -80,7 +80,7 @@ public final class Loader * "osx" or (for any other non-supported platform) the value of the * "os.name" property converted to lower case and with removed space * characters. - * + * * @return The operating system name. */ private static String getOS() @@ -103,7 +103,7 @@ public final class Loader * names i386 und amd64 are converted accordingly) or (when platform is * unsupported) the value of os.arch converted to lower-case and with * removed space characters. - * + * * @return The CPU architecture */ private static String getArch() @@ -123,7 +123,7 @@ public final class Loader /** * Returns the shared library extension name. - * + * * @return The shared library extension name. */ private static String getExt() @@ -155,7 +155,7 @@ public final class Loader /** * Creates the temporary directory used for unpacking the native libraries. * This directory is marked for deletion on exit. - * + * * @return The temporary directory for native libraries. */ private static File createTempDirectory() @@ -191,7 +191,7 @@ public final class Loader /** * Returns the platform name. This could be for example "linux-x86" or * "windows-x86_64". - * + * * @return The architecture name. Never null. */ private static String getPlatform() @@ -202,7 +202,7 @@ public final class Loader /** * Returns the name of the usb4java native library. This could be * "libusb4java.dll" for example. - * + * * @return The usb4java native library name. Never null. */ private static String getLibName() @@ -214,7 +214,7 @@ public final class Loader * Returns the name of the libusb native library. This could be * "libusb0.dll" for example or null if this library is not needed on the * current platform (Because it is provided by the operating system). - * + * * @return The libusb native library name or null if not needed. */ private static String getExtraLibName() @@ -229,7 +229,7 @@ public final class Loader /** * Copies the specified input stream to the specified output file. - * + * * @param input * The input stream. * @param output @@ -239,7 +239,7 @@ public final class Loader */ private static void copy(final InputStream input, final File output) throws IOException - { + { final byte[] buffer = new byte[BUFFER_SIZE]; final FileOutputStream stream = new FileOutputStream(output); try @@ -254,11 +254,11 @@ public final class Loader { stream.close(); } - } + } /** * Extracts a single library. - * + * * @param platform * The platform name (For example "linux-x86") * @param lib @@ -333,7 +333,7 @@ public final class Loader * times. Duplicate calls are ignored. This method is automatically called * when the {@link LibUsb} class is loaded. When you need to do it earlier * (To catch exceptions for example) then simply call this method manually. - * + * * @throws LoaderException * When loading the native wrapper libraries failed. */ diff --git a/src/main/java/de/ailis/usb4java/libusb/LoaderException.java b/src/main/java/de/ailis/usb4java/libusb/LoaderException.java index 7d23d06..0522915 100644 --- a/src/main/java/de/ailis/usb4java/libusb/LoaderException.java +++ b/src/main/java/de/ailis/usb4java/libusb/LoaderException.java @@ -7,7 +7,7 @@ package de.ailis.usb4java.libusb; /** * Thrown when JNI library could not be loaded. - * + * * @author Klaus Reimer (k@ailis.de) */ public final class LoaderException extends RuntimeException @@ -17,7 +17,7 @@ public final class LoaderException extends RuntimeException /** * Constructor. - * + * * @param message * The error message. */ @@ -28,7 +28,7 @@ public final class LoaderException extends RuntimeException /** * Constructor. - * + * * @param message * The error message. * @param cause diff --git a/src/main/java/de/ailis/usb4java/libusb/PollfdListener.java b/src/main/java/de/ailis/usb4java/libusb/PollfdListener.java index f1d028f..6f3282c 100644 --- a/src/main/java/de/ailis/usb4java/libusb/PollfdListener.java +++ b/src/main/java/de/ailis/usb4java/libusb/PollfdListener.java @@ -1,9 +1,9 @@ /* * Copyright 2013 Klaus Reimer * See LICENSE.md for licensing information. - * + * * Based on libusb : - * + * * Copyright 2001 Johannes Erdfelt * Copyright 2007-2009 Daniel Drake * Copyright 2010-2012 Peter Stuge @@ -22,7 +22,7 @@ import java.io.FileDescriptor; /** * Listener interface for pollfd notifications. - * + * * @author Klaus Reimer (k@ailis.de) */ public interface PollfdListener @@ -30,7 +30,7 @@ public interface PollfdListener /** * Callback function, invoked when a new file descriptor should be added to * the set of file descriptors monitored for events. - * + * * @param fd * the new file descriptor. * @param events @@ -43,10 +43,10 @@ public interface PollfdListener /** * Callback function, invoked when a file descriptor should be removed from * the set of file descriptors being monitored for events. - * + * * After returning from this callback, do not use that file descriptor * again. - * + * * @param fd * The file descriptor to stop monitoring. * @param userData diff --git a/src/main/java/de/ailis/usb4java/libusb/SsEndpointCompanionDescriptor.java b/src/main/java/de/ailis/usb4java/libusb/SsEndpointCompanionDescriptor.java index 5135c3b..425425b 100644 --- a/src/main/java/de/ailis/usb4java/libusb/SsEndpointCompanionDescriptor.java +++ b/src/main/java/de/ailis/usb4java/libusb/SsEndpointCompanionDescriptor.java @@ -1,9 +1,9 @@ /* * Copyright 2013 Klaus Reimer * See LICENSE.md for licensing information. - * + * * Based on libusb : - * + * * Copyright 2001 Johannes Erdfelt * Copyright 2007-2009 Daniel Drake * Copyright 2010-2012 Peter Stuge @@ -23,10 +23,10 @@ import org.apache.commons.lang3.builder.HashCodeBuilder; /** * A structure representing the superspeed endpoint companion descriptor. - * + * * This descriptor is documented in section 9.6.7 of the USB 3.0 specification. * All multiple-byte fields are represented in host-endian format. - * + * * @author Klaus Reimer (k@ailis.de) */ public final class SsEndpointCompanionDescriptor @@ -46,7 +46,7 @@ public final class SsEndpointCompanionDescriptor /** * Returns the native pointer. - * + * * @return The native pointer. */ public long getPointer() @@ -56,14 +56,14 @@ public final class SsEndpointCompanionDescriptor /** * Returns the size of this descriptor (in bytes). - * + * * @return The descriptor size in bytes; */ public native byte bLength(); /** * Returns the descriptor type. - * + * * @return The descriptor type. */ public native byte bDescriptorType(); @@ -71,7 +71,7 @@ public final class SsEndpointCompanionDescriptor /** * Returns the maximum number of packets the endpoint can send or receive as * part of a burst. - * + * * @return The maximum number of packets as part of a burst. */ public native byte bMaxBurst(); @@ -81,7 +81,7 @@ public final class SsEndpointCompanionDescriptor * maximum number of streams the EP supports. In isochronous endpoint: * bits 1:0 represents the Mult - a zero based value that determines the * maximum number of packets within a service interval. - * + * * @return The attributes. */ public native byte bmAttributes(); @@ -89,14 +89,14 @@ public final class SsEndpointCompanionDescriptor /** * Returns the total number of bytes this endpoint will transfer every * service interval. Valid only for periodic endpoints. - * + * * @return The total number of bytes per service interval. */ public native short wBytesPerInterval(); /** * Returns a dump of this descriptor. - * + * * @return The descriptor dump. */ public String dump() @@ -126,12 +126,12 @@ public final class SsEndpointCompanionDescriptor } final SsEndpointCompanionDescriptor other = (SsEndpointCompanionDescriptor) obj; return new EqualsBuilder() - .append(this.bDescriptorType(), other.bDescriptorType()) - .append(this.bLength(), other.bLength()) - .append(this.bMaxBurst(), other.bMaxBurst()) - .append(this.bmAttributes(), other.bmAttributes()) - .append(this.wBytesPerInterval(), other.wBytesPerInterval()) - .isEquals(); + .append(this.bDescriptorType(), other.bDescriptorType()) + .append(this.bLength(), other.bLength()) + .append(this.bMaxBurst(), other.bMaxBurst()) + .append(this.bmAttributes(), other.bmAttributes()) + .append(this.wBytesPerInterval(), other.wBytesPerInterval()) + .isEquals(); } @Override diff --git a/src/main/java/de/ailis/usb4java/libusb/SsUsbDeviceCapabilityDescriptor.java b/src/main/java/de/ailis/usb4java/libusb/SsUsbDeviceCapabilityDescriptor.java index 41473ba..0f44756 100644 --- a/src/main/java/de/ailis/usb4java/libusb/SsUsbDeviceCapabilityDescriptor.java +++ b/src/main/java/de/ailis/usb4java/libusb/SsUsbDeviceCapabilityDescriptor.java @@ -1,9 +1,9 @@ /* * Copyright 2013 Klaus Reimer * See LICENSE.md for licensing information. - * + * * Based on libusb : - * + * * Copyright 2001 Johannes Erdfelt * Copyright 2007-2009 Daniel Drake * Copyright 2010-2012 Peter Stuge @@ -25,9 +25,9 @@ import org.apache.commons.lang3.builder.HashCodeBuilder; * A structure representing the SuperSpeed USB Device Capability descriptor. * This descriptor is documented in section 9.6.2.2 of the USB 3.0 * specification. - * + * * All multiple-byte fields are represented in host-endian format. - * + * * @author Klaus Reimer (k@ailis.de) */ public final class SsUsbDeviceCapabilityDescriptor @@ -48,7 +48,7 @@ public final class SsUsbDeviceCapabilityDescriptor /** * Returns the native pointer. - * + * * @return The native pointer. */ public long getPointer() @@ -58,28 +58,28 @@ public final class SsUsbDeviceCapabilityDescriptor /** * Returns the size of this descriptor (in bytes). - * + * * @return The descriptor size in bytes; */ public native byte bLength(); /** * Returns the descriptor type. - * + * * @return The descriptor type. */ public native byte bDescriptorType(); /** * Returns the device capability type. - * + * * @return The device capability type. */ public native byte bDevCapabilityType(); /** * Returns the bitmap of supported device level features. - * + * * @return The supported device level features. */ public native byte bmAttributes(); @@ -87,7 +87,7 @@ public final class SsUsbDeviceCapabilityDescriptor /** * Returns the bitmap encoding of the speed supported by this device when * operating in SuperSpeed mode. - * + * * @return The supported speed. */ public native short wSpeedSupported(); @@ -95,28 +95,28 @@ public final class SsUsbDeviceCapabilityDescriptor /** * Returns the lowest speed at which all the functionality supported by the * device is available to the user. - * + * * @return The lowest speed. */ public native byte bFunctionalitySupport(); /** * Returns the U1 Device Exit Latency. - * + * * @return The U1 Device Exit Latency. */ public native byte bU1DevExitLat(); /** * Returns the U2 Device Exit Latency. - * + * * @return The U2 Device Exit Latency. */ public native short bU2DevExitLat(); /** * Returns a dump of this descriptor. - * + * * @return The descriptor dump. */ public String dump() @@ -151,14 +151,14 @@ public final class SsUsbDeviceCapabilityDescriptor } final SsUsbDeviceCapabilityDescriptor other = (SsUsbDeviceCapabilityDescriptor) obj; return new EqualsBuilder() - .append(this.bDescriptorType(), other.bDescriptorType()) - .append(this.bLength(), other.bLength()) - .append(this.bDevCapabilityType(), other.bDevCapabilityType()) - .append(this.bmAttributes(), other.bmAttributes()) - .append(this.wSpeedSupported(), other.wSpeedSupported()) - .append(this.bFunctionalitySupport(), other.bFunctionalitySupport()) - .append(this.bU1DevExitLat(), other.bU1DevExitLat()) - .append(this.bU2DevExitLat(), other.bU2DevExitLat()).isEquals(); + .append(this.bDescriptorType(), other.bDescriptorType()) + .append(this.bLength(), other.bLength()) + .append(this.bDevCapabilityType(), other.bDevCapabilityType()) + .append(this.bmAttributes(), other.bmAttributes()) + .append(this.wSpeedSupported(), other.wSpeedSupported()) + .append(this.bFunctionalitySupport(), other.bFunctionalitySupport()) + .append(this.bU1DevExitLat(), other.bU1DevExitLat()) + .append(this.bU2DevExitLat(), other.bU2DevExitLat()).isEquals(); } @Override diff --git a/src/main/java/de/ailis/usb4java/libusb/Transfer.java b/src/main/java/de/ailis/usb4java/libusb/Transfer.java index de0d51d..d842ae7 100644 --- a/src/main/java/de/ailis/usb4java/libusb/Transfer.java +++ b/src/main/java/de/ailis/usb4java/libusb/Transfer.java @@ -1,9 +1,9 @@ /* * Copyright 2013 Klaus Reimer * See LICENSE.md for licensing information. - * + * * Based on libusb : - * + * * Copyright 2001 Johannes Erdfelt * Copyright 2007-2009 Daniel Drake * Copyright 2010-2012 Peter Stuge @@ -22,11 +22,11 @@ import java.nio.ByteBuffer; /** * The generic USB transfer structure. - * + * * The user populates this structure and then submits it in order to request a * transfer. After the transfer has completed, the library populates the * transfer with the results and passes it back to the user. - * + * * @author Klaus Reimer (k@ailis.de) */ public final class Transfer @@ -50,7 +50,7 @@ public final class Transfer /** * Returns the native pointer. - * + * * @return The native pointer. */ public long getPointer() @@ -60,14 +60,14 @@ public final class Transfer /** * Returns the handle of the device that this transfer will be submitted to. - * + * * @return The handle of the device. */ public native DeviceHandle devHandle(); /** * Sets the handle of the device that this transfer will be submitted to. - * + * * @param handle * The handle of the device. */ @@ -75,14 +75,14 @@ public final class Transfer /** * Returns the bitwise OR combination of libusb transfer flags. - * + * * @return The transfer flags. */ public native byte flags(); /** * Sets the bitwise OR combination of libusb transfer flags. - * + * * @param flags * The transfer flags to set. */ @@ -90,14 +90,14 @@ public final class Transfer /** * Returns the address of the endpoint where this transfer will be sent. - * + * * @return The endpoint address. */ public native byte endpoint(); /** * Sets the address of the endpoint where this transfer will be sent. - * + * * @param endpoint * The endpoint address to set */ @@ -105,14 +105,14 @@ public final class Transfer /** * Returns the type of the endpoint. - * + * * @return The endpoint type. */ public native byte type(); /** * Sets the type of the endpoint. - * + * * @param type * The endpoint type to set. */ @@ -121,7 +121,7 @@ public final class Transfer /** * Returns the timeout for this transfer in milliseconds. A value of 0 * indicates no timeout. - * + * * @return The timeout. */ public native long timeout(); @@ -129,7 +129,7 @@ public final class Transfer /** * Sets the timeout for this transfer in milliseconds. A value of 0 * indicates no timeout. - * + * * @param timeout * The timeout to set. */ @@ -138,28 +138,28 @@ public final class Transfer /** * Returns the status of the transfer. Read-only, and only for use within * transfer callback function. - * + * * If this is an isochronous transfer, this field may read * {@link LibUsb#TRANSFER_COMPLETED} even if there were errors in the * frames. Use the status field in each packet to determine if errors * occurred. - * + * * @return The transfer status. */ public native int status(); /** * Returns the length of the data buffer. - * + * * @return The data buffer length. */ public native int length(); /** * Sets the length of the data buffer. - * + * * This is checked against the maximum capacity of the supplied ByteBuffer. - * + * * @param length * The data buffer length to set. */ @@ -192,23 +192,23 @@ public final class Transfer * Returns the actual length of data that was transferred. Read-only, and * only for use within transfer callback function. Not valid for isochronous * endpoint transfers. - * + * * @return The actual length of the transferred data. */ public native int actualLength(); /** * Returns the current callback object. - * + * * @return The current callback object. */ public native TransferCallback callback(); /** * Sets the callback object. - * + * * This will be invoked when the transfer completes, fails, or is cancelled. - * + * * @param callback * The callback object to use. */ @@ -216,7 +216,7 @@ public final class Transfer /** * Returns the current user data object. - * + * * @return The current user data object. */ public native Object userData(); @@ -224,7 +224,7 @@ public final class Transfer /** * Sets the user data object, representing user context data to pass to * the callback function and that can be accessed from there. - * + * * @param userData * The user data object to set. */ @@ -232,7 +232,7 @@ public final class Transfer /** * Returns the data buffer. - * + * * @return The data buffer. */ public ByteBuffer buffer() @@ -242,7 +242,7 @@ public final class Transfer /** * Sets the data buffer. - * + * * @param buffer * The data buffer to set. */ @@ -271,14 +271,14 @@ public final class Transfer /** * Returns the number of isochronous packets. Only used for I/O with * isochronous endpoints. - * + * * @return The number of isochronous packets. */ public native int numIsoPackets(); /** * Sets the number of isochronous packets. - * + * * @param numIsoPackets * The number of isochronous packets to set. */ @@ -286,7 +286,7 @@ public final class Transfer /** * Array of isochronous packet descriptors, for isochronous transfers only. - * + * * @return The array of isochronous packet descriptors. */ public native IsoPacketDescriptor[] isoPacketDesc(); diff --git a/src/main/java/de/ailis/usb4java/libusb/Usb20ExtensionDescriptor.java b/src/main/java/de/ailis/usb4java/libusb/Usb20ExtensionDescriptor.java index 6939acd..14150f6 100644 --- a/src/main/java/de/ailis/usb4java/libusb/Usb20ExtensionDescriptor.java +++ b/src/main/java/de/ailis/usb4java/libusb/Usb20ExtensionDescriptor.java @@ -1,9 +1,9 @@ /* * Copyright 2013 Klaus Reimer * See LICENSE.md for licensing information. - * + * * Based on libusb : - * + * * Copyright 2001 Johannes Erdfelt * Copyright 2007-2009 Daniel Drake * Copyright 2010-2012 Peter Stuge @@ -24,9 +24,9 @@ import org.apache.commons.lang3.builder.HashCodeBuilder; /** * A structure representing the USB 2.0 Extension descriptor. This descriptor is * documented in section 9.6.2.1 of the USB 3.0 specification. - * + * * All multiple-byte fields are represented in host-endian format. - * + * * @author Klaus Reimer (k@ailis.de) */ public final class Usb20ExtensionDescriptor @@ -46,7 +46,7 @@ public final class Usb20ExtensionDescriptor /** * Returns the native pointer. - * + * * @return The native pointer. */ public long getPointer() @@ -56,35 +56,35 @@ public final class Usb20ExtensionDescriptor /** * Returns the size of this descriptor (in bytes). - * + * * @return The descriptor size in bytes; */ public native byte bLength(); /** * Returns the descriptor type. - * + * * @return The descriptor type. */ public native byte bDescriptorType(); /** * Returns the device capability type. - * + * * @return The device capability type. */ public native byte bDevCapabilityType(); /** * Returns the bitmap of supported device level features. - * + * * @return The supported device level features. */ public native int bmAttributes(); /** * Returns a dump of this descriptor. - * + * * @return The descriptor dump. */ public String dump() @@ -114,10 +114,10 @@ public final class Usb20ExtensionDescriptor } final Usb20ExtensionDescriptor other = (Usb20ExtensionDescriptor) obj; return new EqualsBuilder() - .append(this.bDescriptorType(), other.bDescriptorType()) - .append(this.bLength(), other.bLength()) - .append(this.bDevCapabilityType(), other.bDevCapabilityType()) - .append(this.bmAttributes(), other.bmAttributes()).isEquals(); + .append(this.bDescriptorType(), other.bDescriptorType()) + .append(this.bLength(), other.bLength()) + .append(this.bDevCapabilityType(), other.bDevCapabilityType()) + .append(this.bmAttributes(), other.bmAttributes()).isEquals(); } @Override diff --git a/src/main/java/de/ailis/usb4java/libusb/Version.java b/src/main/java/de/ailis/usb4java/libusb/Version.java index ccaaa2e..b5f5b03 100644 --- a/src/main/java/de/ailis/usb4java/libusb/Version.java +++ b/src/main/java/de/ailis/usb4java/libusb/Version.java @@ -1,9 +1,9 @@ /* * Copyright 2013 Klaus Reimer * See LICENSE.md for licensing information. - * + * * Based on libusb : - * + * * Copyright 2001 Johannes Erdfelt * Copyright 2007-2009 Daniel Drake * Copyright 2010-2012 Peter Stuge @@ -24,7 +24,7 @@ import org.apache.commons.lang3.builder.HashCodeBuilder; /** * Structure providing the version of the libusb runtime. - * + * * @author Klaus Reimer (k@ailis.de) */ public final class Version implements Comparable @@ -43,7 +43,7 @@ public final class Version implements Comparable /** * Returns the native pointer. - * + * * @return The native pointer. */ public long getPointer() @@ -53,35 +53,35 @@ public final class Version implements Comparable /** * Returns the library major version. - * + * * @return The library major version. */ public native int major(); /** * Returns the library minor version. - * + * * @return The library minor version. */ public native int minor(); /** * Returns the library micro version. - * + * * @return The library micro version. */ public native int micro(); /** * Returns the library nano version. - * + * * @return The library nano version. */ public native int nano(); /** * Returns the release candidate suffix string, e.g. "-rc4". - * + * * @return The release candidate suffix string. */ public native String rc();