- setResetOnFirstOpen(): new timeout parameter

- javadoc changes

git-svn-id: https://svn.code.sf.net/p/libusbjava/code/trunk@169 94ad28fe-ef68-46b1-9651-e7ae4fcf1c4c
This commit is contained in:
schlaepfer
2006-08-31 13:27:22 +00:00
parent 896c4714ae
commit c7d6ad0b1a
2 changed files with 20 additions and 12 deletions

View File

@@ -27,7 +27,7 @@ public class Device {
private boolean resetOnFirstOpen, resetDone;
private Usb_Device_Descriptor devDesc;
private int resetTimeout = 1000;
protected Device(short idVendor, short idProduct) {
resetOnFirstOpen = false;
@@ -81,7 +81,7 @@ public class Device {
while (bus != null) {
Usb_Device dev = bus.devices;
while (dev != null) {
devDesc = dev.descriptor;
Usb_Device_Descriptor devDesc = dev.descriptor;
if ((devDesc.idVendor == idVendor)
&& (devDesc.idProduct == idProduct)) {
logger.info("Open device: " + dev.filename);
@@ -128,7 +128,7 @@ public class Device {
resetDone = true;
reset();
try {
Thread.sleep(1000);
Thread.sleep(resetTimeout);
} catch (InterruptedException e) {
//
}
@@ -545,12 +545,17 @@ public class Device {
* If enabled, the device is reset when first opened. <br>
* This will only happen once. When the application is started, the device
* state is unknown. If the device is not reset, read or write may result in
* a {@link USBTimeoutException}.
* a {@link USBTimeoutException}.<br>
* <br>
* This feature is disabled by default.
*
* @param enable
* true if the device should be reset when first opened
* @param timeout
* the timeout between the reset and the reopening
*/
public void setResetOnFirstOpen(boolean enable) {
public void setResetOnFirstOpen(boolean enable, int timeout) {
resetOnFirstOpen = enable;
resetTimeout = timeout;
}
}

View File

@@ -13,7 +13,8 @@ package ch.ntb.usb;
* kernel driver code.<br>
* <br>
* The API description of this class has been copied from the <a
* href="http://libusb.sourceforge.net/documentation.html">libusb documentation</a>.<br>
* href="http://libusb.sourceforge.net/documentation.html">libusb documentation</a>
* and adapted where neccessary.<br>
*
* @author schlaepfer
* @version DLL: 00.02.00
@@ -47,13 +48,15 @@ public class LibusbWin {
public static native int usb_find_devices();
/**
* <code>usb_get_busses</code> simply returns the value of the global
* variable usb_busses. This was implemented for those languages that
* support C calling convention and can use shared libraries, but don't
* support C global variables (like Delphi).
* <code>usb_get_busses</code> returns a tree of descriptor objects.<br>
* The tree represents the bus structure with devices, configurations,
* interfaces and endpoints. Note that this is only a copy. To refresh the
* information, <code>usb_getbusses()</code> must be called again. The
* name of the objects contained in the tree is starting with
* <code>Usb_</code>.
*
* @return the structure of all busses and devices. <b>Note:</b> The java
* objects are copies of the C structs.
* @return the structure of all busses and devices. <code>Note:</code> The
* java objects are copies of the C structs.
*/
public static native Usb_Bus usb_get_busses();