- 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 boolean resetOnFirstOpen, resetDone;
private Usb_Device_Descriptor devDesc; private int resetTimeout = 1000;
protected Device(short idVendor, short idProduct) { protected Device(short idVendor, short idProduct) {
resetOnFirstOpen = false; resetOnFirstOpen = false;
@@ -81,7 +81,7 @@ public class Device {
while (bus != null) { while (bus != null) {
Usb_Device dev = bus.devices; Usb_Device dev = bus.devices;
while (dev != null) { while (dev != null) {
devDesc = dev.descriptor; Usb_Device_Descriptor devDesc = dev.descriptor;
if ((devDesc.idVendor == idVendor) if ((devDesc.idVendor == idVendor)
&& (devDesc.idProduct == idProduct)) { && (devDesc.idProduct == idProduct)) {
logger.info("Open device: " + dev.filename); logger.info("Open device: " + dev.filename);
@@ -128,7 +128,7 @@ public class Device {
resetDone = true; resetDone = true;
reset(); reset();
try { try {
Thread.sleep(1000); Thread.sleep(resetTimeout);
} catch (InterruptedException e) { } catch (InterruptedException e) {
// //
} }
@@ -545,12 +545,17 @@ public class Device {
* If enabled, the device is reset when first opened. <br> * If enabled, the device is reset when first opened. <br>
* This will only happen once. When the application is started, the device * 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 * 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 * @param enable
* true if the device should be reset when first opened * 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; resetOnFirstOpen = enable;
resetTimeout = timeout;
} }
} }

View File

@@ -13,7 +13,8 @@ package ch.ntb.usb;
* kernel driver code.<br> * kernel driver code.<br>
* <br> * <br>
* The API description of this class has been copied from the <a * 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 * @author schlaepfer
* @version DLL: 00.02.00 * @version DLL: 00.02.00
@@ -47,13 +48,15 @@ public class LibusbWin {
public static native int usb_find_devices(); public static native int usb_find_devices();
/** /**
* <code>usb_get_busses</code> simply returns the value of the global * <code>usb_get_busses</code> returns a tree of descriptor objects.<br>
* variable usb_busses. This was implemented for those languages that * The tree represents the bus structure with devices, configurations,
* support C calling convention and can use shared libraries, but don't * interfaces and endpoints. Note that this is only a copy. To refresh the
* support C global variables (like Delphi). * 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 * @return the structure of all busses and devices. <code>Note:</code> The
* objects are copies of the C structs. * java objects are copies of the C structs.
*/ */
public static native Usb_Bus usb_get_busses(); public static native Usb_Bus usb_get_busses();