- Removed library's JNI test
- Introduced code to explicitly unref devices - Corrected code formatting git-svn-id: https://svn.code.sf.net/p/libusbjava/code/trunk@309 94ad28fe-ef68-46b1-9651-e7ae4fcf1c4c
This commit is contained in:
@@ -299,7 +299,7 @@ public class LibusbJava {
|
||||
handle = LibusbJava1.libusb_open(dev);
|
||||
}
|
||||
catch (LibusbError e) {
|
||||
System.err.println("LibusbJava-1.0 init failed with errorcode: "
|
||||
System.err.println("LibusbJava-1.0 failed with errorcode: "
|
||||
+ e.getMessage());
|
||||
e.printStackTrace();
|
||||
handle = 0;
|
||||
@@ -581,6 +581,7 @@ public class LibusbJava {
|
||||
try {
|
||||
result = LibusbJava1.libusb_get_descriptor(dev_handle, type, index, size);
|
||||
} catch (LibusbError e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
@@ -107,6 +107,36 @@ public class Usb_Device {
|
||||
next = dev;
|
||||
}
|
||||
|
||||
public static void freeDeviceList(Usb_Device device)
|
||||
{
|
||||
Usb_Device curr = device.getPrev();
|
||||
|
||||
/* Detach the left part of the list */
|
||||
device.setPrev(null);
|
||||
|
||||
/* First walk to the left of the list and free all
|
||||
devices on our way */
|
||||
while (curr != null)
|
||||
{
|
||||
freeDevice(curr);
|
||||
curr = curr.getPrev();
|
||||
}
|
||||
|
||||
curr = device;
|
||||
/* Then walk to the right of the list and free all */
|
||||
while (curr != null)
|
||||
{
|
||||
freeDevice(curr);
|
||||
curr = curr.getNext();
|
||||
}
|
||||
}
|
||||
|
||||
public static void freeDevice(Usb_Device device)
|
||||
{
|
||||
freeDeviceList(device.getChildren());
|
||||
LibusbJava1.libusb_unref_device(device);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of children of this device.<br>
|
||||
*
|
||||
|
||||
@@ -13,8 +13,8 @@ package ch.ntb.inf.libusbJava;
|
||||
* endpoints into a functional group performing a single feature of the device.<br>
|
||||
* <br>
|
||||
* The length of the interface descriptor is
|
||||
* {@link ch.ntb.inf.libusbJava.Usb_Descriptor#USB_DT_INTERFACE_SIZE} and the type is
|
||||
* {@link ch.ntb.inf.libusbJava.Usb_Descriptor#USB_DT_INTERFACE}.
|
||||
* {@link ch.ntb.inf.libusbJava.Usb_Descriptor#USB_DT_INTERFACE_SIZE} and the
|
||||
* type is {@link ch.ntb.inf.libusbJava.Usb_Descriptor#USB_DT_INTERFACE}.
|
||||
*
|
||||
*/
|
||||
public class Usb_Interface_Descriptor extends Usb_Descriptor {
|
||||
@@ -51,7 +51,8 @@ public class Usb_Interface_Descriptor extends Usb_Descriptor {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value used to select the alternate setting ({@link LibusbJava#usb_set_altinterface(long, int)}).<br>
|
||||
* Returns the value used to select the alternate setting (
|
||||
* {@link LibusbJava#usb_set_altinterface(long, int)}).<br>
|
||||
*
|
||||
* @return the alternate setting
|
||||
*/
|
||||
|
||||
@@ -15,12 +15,14 @@ import ch.ntb.inf.libusbJava.Utils;
|
||||
* Initalises Libusb and prints the bus(ses) with attached devices to the
|
||||
* standard out.<br>
|
||||
*
|
||||
*
|
||||
* @deprecated This class will be removed with the legacy {@link LibusbJava}
|
||||
* class
|
||||
*/
|
||||
public class LogBus {
|
||||
|
||||
private static void logBus() {
|
||||
// if you don't use the ch.ntb.inf.libusbJava.Device class you must initialise
|
||||
// if you don't use the ch.ntb.inf.libusbJava.Device class you must
|
||||
// initialise
|
||||
// Libusb before use
|
||||
LibusbJava.usb_init();
|
||||
LibusbJava.usb_find_busses();
|
||||
|
||||
Reference in New Issue
Block a user