From cc65dbfa741ac743cb98b78d148ec7699dd28515 Mon Sep 17 00:00:00 2001 From: uniederer Date: Fri, 30 Mar 2012 12:08:45 +0000 Subject: [PATCH] - Binding to Libusb 1.0 - Adding version information to the library git-svn-id: https://svn.code.sf.net/p/libusbjava/code/trunk@281 94ad28fe-ef68-46b1-9651-e7ae4fcf1c4c --- LibusbJava/.cproject | 350 ++- LibusbJava/.project | 52 +- .../.settings/org.eclipse.cdt.core.prefs | 4 - LibusbJava/LibusbJava.cpp | 2598 +++++++++++------ LibusbJava/LibusbJava.h | 550 +++- LibusbJava/LibusbTest.cpp | 466 --- LibusbJava/build.xml | 204 +- LibusbJava/build_rc.cmd | 35 + LibusbJava/common.rc | 35 - LibusbJava/error.h | 23 - LibusbJava/libusb-1.0.def | 592 ++++ LibusbJava/libusb.a | Bin 27984 -> 0 bytes LibusbJava/libusb.h | 1354 +++++++++ LibusbJava/resource.rc | 7 - LibusbJava/usb.h | 394 --- LibusbJava/version.properties | 7 +- 16 files changed, 4589 insertions(+), 2082 deletions(-) delete mode 100644 LibusbJava/.settings/org.eclipse.cdt.core.prefs delete mode 100644 LibusbJava/LibusbTest.cpp create mode 100644 LibusbJava/build_rc.cmd delete mode 100644 LibusbJava/common.rc delete mode 100644 LibusbJava/error.h create mode 100644 LibusbJava/libusb-1.0.def delete mode 100644 LibusbJava/libusb.a create mode 100644 LibusbJava/libusb.h delete mode 100644 LibusbJava/resource.rc delete mode 100644 LibusbJava/usb.h diff --git a/LibusbJava/.cproject b/LibusbJava/.cproject index 26a6217..e3d472f 100644 --- a/LibusbJava/.cproject +++ b/LibusbJava/.cproject @@ -1,67 +1,291 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/LibusbJava/.project b/LibusbJava/.project index 0032176..3b07456 100644 --- a/LibusbJava/.project +++ b/LibusbJava/.project @@ -1,49 +1,37 @@ - LibusbJava + LibusbJava-1.0 - org.eclipse.cdt.make.core.makeBuilder - + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean, - org.eclipse.cdt.core.errorOutputParser - org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GASErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.VCErrorParser; + ?name? + org.eclipse.cdt.make.core.append_environment true - org.eclipse.cdt.make.core.build.arguments + org.eclipse.cdt.make.core.buildArguments - org.eclipse.cdt.make.core.build.command + org.eclipse.cdt.make.core.buildCommand make - org.eclipse.cdt.make.core.build.location - + org.eclipse.cdt.make.core.buildLocation + ${workspace_loc:/LibusbJava-1.0/Debug} - org.eclipse.cdt.make.core.build.target.auto - all - - - org.eclipse.cdt.make.core.build.target.clean - clean - - - org.eclipse.cdt.make.core.build.target.full - clean all - - - org.eclipse.cdt.make.core.build.target.inc - all + org.eclipse.cdt.make.core.contents + org.eclipse.cdt.make.core.activeConfigSettings org.eclipse.cdt.make.core.enableAutoBuild @@ -51,23 +39,15 @@ org.eclipse.cdt.make.core.enableCleanBuild - false + true org.eclipse.cdt.make.core.enableFullBuild false - - org.eclipse.cdt.make.core.enabledIncrementalBuild - false - - - org.eclipse.cdt.make.core.environment - - org.eclipse.cdt.make.core.stopOnError - false + true org.eclipse.cdt.make.core.useDefaultBuildCmd @@ -76,15 +56,15 @@ - org.eclipse.cdt.make.core.ScannerConfigBuilder + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder org.eclipse.cdt.core.cnature - org.eclipse.cdt.make.core.makeNature - org.eclipse.cdt.make.core.ScannerConfigNature org.eclipse.cdt.core.ccnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature diff --git a/LibusbJava/.settings/org.eclipse.cdt.core.prefs b/LibusbJava/.settings/org.eclipse.cdt.core.prefs deleted file mode 100644 index ae32dbf..0000000 --- a/LibusbJava/.settings/org.eclipse.cdt.core.prefs +++ /dev/null @@ -1,4 +0,0 @@ -#Sat Aug 11 13:28:28 CEST 2007 -eclipse.preferences.version=1 -indexer/indexerId=org.eclipse.cdt.core.domsourceindexer -indexerId=org.eclipse.cdt.core.domsourceindexer diff --git a/LibusbJava/LibusbJava.cpp b/LibusbJava/LibusbJava.cpp index f0e0722..e9ed8c6 100644 --- a/LibusbJava/LibusbJava.cpp +++ b/LibusbJava/LibusbJava.cpp @@ -1,852 +1,1796 @@ -/* - * Java libusb wrapper - * Copyright (c) 2005-2006 Andreas Schläpfer +/******************************************************************************************** + * Java libusb1.0 wrapper + * Copyright (c) 2010-2011 Roger Millischer * - * http://libusbjava.sourceforge.net - * This library is covered by the LGPL, read LGPL.txt for details. - */ - + * This libary is covered by the LGPL, read LGPL.txt for details + *******************************************************************************************/ +/******************************************************************************************** + * + * Includes + * + *******************************************************************************************/ #include -#include -#include -#include -#include -#include -#include "LibusbJava.h" +#include +#include +#include +#include -// Windows specific stuff -#ifdef WIN32 -#include -#endif +#include + +#include "libusb.h" +#include "LibusbJava.h" //#define DEBUGON -// global bus (updated when usb_get_busses() is called) -struct usb_bus *busses; - -// global flag for loading all class, method and field ID references +/******************************************************************************************** + * + * Globals + * + *******************************************************************************************/ +/* global flag for loading all class, method and field ID references*/ int java_references_loaded = 0; -// if > 0 an LibusbJava specific error string is set +/* if > 0 an LibusbJava specific error string is set*/ char *libusbJavaError = NULL; - -// macros to set and clear LibusbJava specific errors +/******************************************************************************************** + * + * Macros + * + *******************************************************************************************/ +/* to set and clear LibusbJava specific errors*/ #define setLibusbJavaError(error) libusbJavaError = error #define clearLibusbJavaError() libusbJavaError = NULL -// class references -jclass usb_busClazz, usb_devClazz, usb_devDescClazz, usb_confDescClazz, \ - usb_intClazz, usb_intDescClazz, usb_epDescClazz; +/******************************************************************************************** + * + * Prototyp and define for callback-function + * + *******************************************************************************************/ +static void LIBUSB_CALL transfer_callback(struct libusb_transfer *transfer); -// method ID references -jmethodID usb_busMid, usb_devMid, usb_devDescMid, usb_confDescMid, \ - usb_intMid, usb_intDescMid, usb_epDescMid; +static void + LIBUSB_CALL fd_added_callback(int fd, short events, void *user_data); -// field ID references -// usb_bus -jfieldID usb_busFID_next, usb_busFID_prev, usb_busFID_dirname, \ - usb_busFID_devices, usb_busFID_location, usb_busFID_root_dev; -// usb_device -jfieldID usb_devFID_next, usb_devFID_prev, usb_devFID_filename, \ - usb_devFID_bus, usb_devFID_descriptor, usb_devFID_config, \ - usb_devFID_devnum, usb_devFID_num_children, usb_devFID_children, \ - usb_devFID_devStructAddr; -// usb_deviceDescriptor -jfieldID usb_devDescFID_bLength, usb_devDescFID_bDescriptorType, \ - usb_devDescFID_bcdUSB, usb_devDescFID_bDeviceClass, \ - usb_devDescFID_bDeviceSubClass, usb_devDescFID_bDeviceProtocol, \ - usb_devDescFID_bMaxPacketSize0, usb_devDescFID_idVendor, \ - usb_devDescFID_idProduct, usb_devDescFID_bcdDevice, \ - usb_devDescFID_iManufacturer, usb_devDescFID_iProduct, \ - usb_devDescFID_iSerialNumber, usb_devDescFID_bNumConfigurations; -// usb_configurationDescriptor -jfieldID usb_confDescFID_bLength, usb_confDescFID_bDescriptorType, usb_confDescFID_wTotalLength, \ - usb_confDescFID_bNumInterfaces, usb_confDescFID_bConfigurationValue, \ - usb_confDescFID_iConfiguration, usb_confDescFID_bmAttributes, usb_confDescFID_MaxPower, \ - usb_confDescFID_interface_, usb_confDescFID_extra, usb_confDescFID_extralen; -// usb_interface -jfieldID usb_intFID_altsetting, usb_intFID_num_altsetting; -// usb_intDesc -jfieldID usb_intDescFID_bLength, usb_intDescFID_bDescriptorType, \ - usb_intDescFID_bInterfaceNumber, usb_intDescFID_bAlternateSetting, \ - usb_intDescFID_bNumEndpoints, usb_intDescFID_bInterfaceClass, \ - usb_intDescFID_bInterfaceSubClass, usb_intDescFID_bInterfaceProtocol, \ - usb_intDescFID_iInterface, usb_intDescFID_endpoint, usb_intDescFID_extra, \ - usb_intDescFID_extralen; -// usb_endpointDescriptor -jfieldID usb_epDescFID_bLength, usb_epDescFID_bDescriptorType, \ - usb_epDescFID_bEndpointAddress, usb_epDescFID_bmAttributes, \ - usb_epDescFID_wMaxPacketSize, usb_epDescFID_bInterval, \ - usb_epDescFID_bRefresh, usb_epDescFID_bSynchAddress, usb_epDescFID_extra, \ - usb_epDescFID_extralen; +static void LIBUSB_CALL fd_removed_callback(int fd, void *user_data); -/* - * Class: ch_ntb_usb_LibusbJava - * Method: usb_set_debug - * Signature: (B)V - */ -JNIEXPORT void JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava_usb_1set_1debug - (JNIEnv *env, jclass obj, jint level) - { - clearLibusbJavaError(); - usb_set_debug(level); - } -/* - * Class: ch_ntb_usb_LibusbJava - * Method: usb_init - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava_usb_1init - (JNIEnv *env, jclass obj) - { - clearLibusbJavaError(); - usb_init(); - } +/******************************************************************************************** + * + * References + * + *******************************************************************************************/ +/* class references*/ +static jclass usb_devClazz, usb_devDescClazz, usb_confDescClazz, usb_intClazz, + usb_intDescClazz, usb_epDescClazz, usb_cb_clazz, usb_pollfd_clazz; -/* - * Class: ch_ntb_usb_LibusbJava - * Method: usb_find_busses - * Signature: ()I - */ -JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava_usb_1find_1busses - (JNIEnv *env, jclass obj) - { - clearLibusbJavaError(); - return usb_find_busses(); - } +/* method ID references*/ +static jmethodID usb_devMid, usb_devDescMid, usb_confDescMid, usb_intMid, + usb_intDescMid, usb_epDescMid, usb_transfer_cb_Mid, + usb_fd_added_cb_Mid, usb_fd_removed_cb_Mid, usb_pollfd_Mid; -/* - * Class: ch_ntb_usb_LibusbJava - * Method: usb_find_devices - * Signature: ()I - */ -JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava_usb_1find_1devices - (JNIEnv *env, jclass obj) - { - clearLibusbJavaError(); - return usb_find_devices(); - } +/* field ID references*/ +/* usb_device*/ +static jfieldID usb_devFID_next, usb_devFID_prev, usb_devFID_filename, usb_devFID_bus, + usb_devFID_descriptor, usb_devFID_config, usb_devFID_devnum, + usb_devFID_num_children, usb_devFID_children, usb_devFID_devStructAddr; +/* usb_deviceDescriptor */ +static jfieldID usb_devDescFID_bLength, usb_devDescFID_bDescriptorType, + usb_devDescFID_bcdUSB, usb_devDescFID_bDeviceClass, + usb_devDescFID_bDeviceSubClass, usb_devDescFID_bDeviceProtocol, + usb_devDescFID_bMaxPacketSize0, usb_devDescFID_idVendor, + usb_devDescFID_idProduct, usb_devDescFID_bcdDevice, + usb_devDescFID_iManufacturer, usb_devDescFID_iProduct, + usb_devDescFID_iSerialNumber, usb_devDescFID_bNumConfigurations; +/* usb_configurationDescriptor*/ +static jfieldID usb_confDescFID_bLength, usb_confDescFID_bDescriptorType, + usb_confDescFID_wTotalLength, usb_confDescFID_bNumInterfaces, + usb_confDescFID_bConfigurationValue, usb_confDescFID_iConfiguration, + usb_confDescFID_bmAttributes, usb_confDescFID_MaxPower, + usb_confDescFID_interface_, usb_confDescFID_extra, + usb_confDescFID_extralen; +/* usb_interface*/ +static jfieldID usb_intFID_altsetting, usb_intFID_num_altsetting; +/* usb_intDesc*/ +static jfieldID usb_intDescFID_bLength, usb_intDescFID_bDescriptorType, + usb_intDescFID_bInterfaceNumber, usb_intDescFID_bAlternateSetting, + usb_intDescFID_bNumEndpoints, usb_intDescFID_bInterfaceClass, + usb_intDescFID_bInterfaceSubClass, usb_intDescFID_bInterfaceProtocol, + usb_intDescFID_iInterface, usb_intDescFID_endpoint, + usb_intDescFID_extra, usb_intDescFID_extralen; +/* usb_endpointDescriptor*/ +static jfieldID usb_epDescFID_bLength, usb_epDescFID_bDescriptorType, + usb_epDescFID_bEndpointAddress, usb_epDescFID_bmAttributes, + usb_epDescFID_wMaxPacketSize, usb_epDescFID_bInterval, + usb_epDescFID_bRefresh, usb_epDescFID_bSynchAddress, + usb_epDescFID_extra, usb_epDescFID_extralen; +/*Libusb_pollfd*/ +static jfieldID usb_pollfdFID_fd, usb_pollfdFID_events; -/* - * Class: ch_ntb_usb_LibusbJava - * Method: usb_get_busses - * Signature: ()Lch/ntb/usb/Usb_Bus; - */ -JNIEXPORT jobject JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava_usb_1get_1busses - (JNIEnv *env, jclass obj) - { +/******************************************************************************************** + * + * Methods + * + *******************************************************************************************/ +/******************************************************************************************** + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_set_debug + * Signature: (JI)V + ********************************************************************************************/ +JNIEXPORT void JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1set_1debug( JNIEnv *env, jclass obj, jlong ctx, jint level) { + clearLibusbJavaError(); + libusb_context *context = NULL; + if (ctx) { + context = (libusb_context*) ((unsigned long) ctx); + } + libusb_set_debug(context, level); +} + +/******************************************************************************************** + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_init + * Signature: ()J + ********************************************************************************************/ +JNIEXPORT jlong JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1init( JNIEnv *env, jclass obj) { + int res; + libusb_context *context; clearLibusbJavaError(); - // only load class, method and field ID references once - if (!java_references_loaded) { - // find classes and field ids - // usb_bus - usb_busClazz = env->FindClass("ch/ntb/usb/Usb_Bus"); - if (usb_busClazz == NULL) { return NULL; /* exception thrown */ } - usb_busMid = env->GetMethodID(usb_busClazz, "","()V"); - if (usb_busMid == NULL) { return NULL; } + res = libusb_init(&context); - usb_busFID_next = env->GetFieldID(usb_busClazz, "next", "Lch/ntb/usb/Usb_Bus;"); - usb_busFID_prev = env->GetFieldID(usb_busClazz, "prev", "Lch/ntb/usb/Usb_Bus;"); - usb_busFID_dirname = env->GetFieldID(usb_busClazz, "dirname", "Ljava/lang/String;"); - usb_busFID_devices = env->GetFieldID(usb_busClazz, "devices", "Lch/ntb/usb/Usb_Device;"); - usb_busFID_location = env->GetFieldID(usb_busClazz, "location", "J"); - usb_busFID_root_dev = env->GetFieldID(usb_busClazz, "root_dev", "Lch/ntb/usb/Usb_Device;"); + #ifdef DEBUGON + printf("res = %i \n", res); + printf("env = %p\n", env); + printf("context = %p\n", &context); + #endif - // usb_device - usb_devClazz = env->FindClass("ch/ntb/usb/Usb_Device"); - if (usb_devClazz == NULL) { return NULL; /* exception thrown */ } - usb_devMid = env->GetMethodID(usb_devClazz, "","()V"); - if (usb_devMid == NULL) { return NULL; } - - usb_devFID_next = env->GetFieldID(usb_devClazz, "next", "Lch/ntb/usb/Usb_Device;"); - usb_devFID_prev = env->GetFieldID(usb_devClazz, "prev", "Lch/ntb/usb/Usb_Device;"); - usb_devFID_filename = env->GetFieldID(usb_devClazz, "filename", "Ljava/lang/String;"); - usb_devFID_bus = env->GetFieldID(usb_devClazz, "bus", "Lch/ntb/usb/Usb_Bus;"); - usb_devFID_descriptor = env->GetFieldID(usb_devClazz, "descriptor", "Lch/ntb/usb/Usb_Device_Descriptor;"); - usb_devFID_config = env->GetFieldID(usb_devClazz, "config", "[Lch/ntb/usb/Usb_Config_Descriptor;"); - usb_devFID_devnum = env->GetFieldID(usb_devClazz, "devnum", "B"); - usb_devFID_num_children = env->GetFieldID(usb_devClazz, "num_children", "B"); - usb_devFID_children = env->GetFieldID(usb_devClazz, "children", "Lch/ntb/usb/Usb_Device;"); - usb_devFID_devStructAddr = env->GetFieldID(usb_devClazz, "devStructAddr", "J"); - - - // usb_device_descriptor - usb_devDescClazz = env->FindClass("ch/ntb/usb/Usb_Device_Descriptor"); - if (usb_devDescClazz == NULL) { return NULL; /* exception thrown */ } - usb_devDescMid = env->GetMethodID(usb_devDescClazz, "","()V"); - if (usb_devDescMid == NULL) { return NULL; } - - usb_devDescFID_bLength = env->GetFieldID(usb_devDescClazz, "bLength", "B"); - usb_devDescFID_bDescriptorType = env->GetFieldID(usb_devDescClazz, "bDescriptorType", "B"); - usb_devDescFID_bcdUSB = env->GetFieldID(usb_devDescClazz, "bcdUSB", "S"); - usb_devDescFID_bDeviceClass = env->GetFieldID(usb_devDescClazz, "bDeviceClass", "B"); - usb_devDescFID_bDeviceSubClass = env->GetFieldID(usb_devDescClazz, "bDeviceSubClass", "B"); - usb_devDescFID_bDeviceProtocol = env->GetFieldID(usb_devDescClazz, "bDeviceProtocol", "B"); - usb_devDescFID_bMaxPacketSize0 = env->GetFieldID(usb_devDescClazz, "bMaxPacketSize0", "B"); - usb_devDescFID_idVendor = env->GetFieldID(usb_devDescClazz, "idVendor", "S"); - usb_devDescFID_idProduct = env->GetFieldID(usb_devDescClazz, "idProduct", "S"); - usb_devDescFID_bcdDevice = env->GetFieldID(usb_devDescClazz, "bcdDevice", "S"); - usb_devDescFID_iManufacturer = env->GetFieldID(usb_devDescClazz, "iManufacturer", "B"); - usb_devDescFID_iProduct = env->GetFieldID(usb_devDescClazz, "iProduct", "B"); - usb_devDescFID_iSerialNumber = env->GetFieldID(usb_devDescClazz, "iSerialNumber", "B"); - usb_devDescFID_bNumConfigurations = env->GetFieldID(usb_devDescClazz, "bNumConfigurations", "B"); - - // usb_configuration_descriptor - usb_confDescClazz = env->FindClass("ch/ntb/usb/Usb_Config_Descriptor"); - if (usb_confDescClazz == NULL) { return NULL; /* exception thrown */ } - usb_confDescMid = env->GetMethodID(usb_confDescClazz, "","()V"); - if (usb_confDescMid == NULL) { return NULL; } - - usb_confDescFID_bLength = env->GetFieldID(usb_confDescClazz, "bLength", "B"); - usb_confDescFID_bDescriptorType = env->GetFieldID(usb_confDescClazz, "bDescriptorType", "B"); - usb_confDescFID_wTotalLength = env->GetFieldID(usb_confDescClazz, "wTotalLength", "S"); - usb_confDescFID_bNumInterfaces = env->GetFieldID(usb_confDescClazz, "bNumInterfaces", "B"); - usb_confDescFID_bConfigurationValue = env->GetFieldID(usb_confDescClazz, "bConfigurationValue", "B"); - usb_confDescFID_iConfiguration = env->GetFieldID(usb_confDescClazz, "iConfiguration", "B"); - usb_confDescFID_bmAttributes = env->GetFieldID(usb_confDescClazz, "bmAttributes", "B"); - usb_confDescFID_MaxPower = env->GetFieldID(usb_confDescClazz, "MaxPower", "B"); - usb_confDescFID_interface_ = env->GetFieldID(usb_confDescClazz, "interface_", "[Lch/ntb/usb/Usb_Interface;"); - usb_confDescFID_extra = env->GetFieldID(usb_confDescClazz, "extra", "[B"); - usb_confDescFID_extralen = env->GetFieldID(usb_confDescClazz, "extralen", "I"); - - // usb_interface - usb_intClazz = env->FindClass("ch/ntb/usb/Usb_Interface"); - if (usb_intClazz == NULL) { return NULL; /* exception thrown */ } - usb_intMid = env->GetMethodID(usb_intClazz, "","()V"); - if (usb_intMid == NULL) { return NULL; } - - usb_intFID_altsetting = env->GetFieldID(usb_intClazz, "altsetting", "[Lch/ntb/usb/Usb_Interface_Descriptor;"); - usb_intFID_num_altsetting = env->GetFieldID(usb_intClazz, "num_altsetting", "I"); - - // usb_interface_descriptor - usb_intDescClazz = env->FindClass("ch/ntb/usb/Usb_Interface_Descriptor"); - if (usb_intDescClazz == NULL) { return NULL; /* exception thrown */ } - usb_intDescMid = env->GetMethodID(usb_intDescClazz, "","()V"); - if (usb_intDescMid == NULL) { return NULL; } - - usb_intDescFID_bLength = env->GetFieldID(usb_intDescClazz, "bLength", "B"); - usb_intDescFID_bDescriptorType = env->GetFieldID(usb_intDescClazz, "bDescriptorType", "B"); - usb_intDescFID_bInterfaceNumber = env->GetFieldID(usb_intDescClazz, "bInterfaceNumber", "B"); - usb_intDescFID_bAlternateSetting = env->GetFieldID(usb_intDescClazz, "bAlternateSetting", "B"); - usb_intDescFID_bNumEndpoints = env->GetFieldID(usb_intDescClazz, "bNumEndpoints", "B"); - usb_intDescFID_bInterfaceClass = env->GetFieldID(usb_intDescClazz, "bInterfaceClass", "B"); - usb_intDescFID_bInterfaceSubClass = env->GetFieldID(usb_intDescClazz, "bInterfaceSubClass", "B"); - usb_intDescFID_bInterfaceProtocol = env->GetFieldID(usb_intDescClazz, "bInterfaceProtocol", "B"); - usb_intDescFID_iInterface = env->GetFieldID(usb_intDescClazz, "iInterface", "B"); - usb_intDescFID_endpoint = env->GetFieldID(usb_intDescClazz, "endpoint", "[Lch/ntb/usb/Usb_Endpoint_Descriptor;"); - usb_intDescFID_extra = env->GetFieldID(usb_intDescClazz, "extra", "[B"); - usb_intDescFID_extralen = env->GetFieldID(usb_intDescClazz, "extralen", "I"); - - // usb_endpoint_descriptor - usb_epDescClazz = env->FindClass("ch/ntb/usb/Usb_Endpoint_Descriptor"); - if (usb_epDescClazz == NULL) { return NULL; /* exception thrown */ } - usb_epDescMid = env->GetMethodID(usb_epDescClazz, "","()V"); - if (usb_epDescMid == NULL) { return NULL; } - - usb_epDescFID_bLength = env->GetFieldID(usb_epDescClazz, "bLength", "B"); - usb_epDescFID_bDescriptorType = env->GetFieldID(usb_epDescClazz, "bDescriptorType", "B"); - usb_epDescFID_bEndpointAddress = env->GetFieldID(usb_epDescClazz, "bEndpointAddress", "B"); - usb_epDescFID_bmAttributes = env->GetFieldID(usb_epDescClazz, "bmAttributes", "B"); - usb_epDescFID_wMaxPacketSize = env->GetFieldID(usb_epDescClazz, "wMaxPacketSize", "S"); - usb_epDescFID_bInterval = env->GetFieldID(usb_epDescClazz, "bInterval", "B"); - usb_epDescFID_bRefresh = env->GetFieldID(usb_epDescClazz, "bRefresh", "B"); - usb_epDescFID_bSynchAddress = env->GetFieldID(usb_epDescClazz, "bSynchAddress", "B"); - usb_epDescFID_extra = env->GetFieldID(usb_epDescClazz, "extra", "[B"); - usb_epDescFID_extralen = env->GetFieldID(usb_epDescClazz, "extralen", "I"); -#ifdef DEBUGON - printf("usb_get_busses: Field initialization done (1)\n"); -#endif - } - - //************************************************************************// - - struct usb_device *dev; - struct usb_bus *bus; - - busses = usb_get_busses(); - bus = busses; - if (!bus){ - return NULL; - } - - // objects - jobject main_usb_busObj, usb_busObj, usb_busObj_next, usb_busObj_prev, \ - main_usb_devObj, usb_devObj, usb_devObj_next, usb_devObj_prev, \ - usb_devDescObj, usb_confDescObj, usb_intObj, usb_intDescObj, \ - usb_epDescObj; - - jobjectArray usb_confDescObjArray, usb_intObjArray, usb_intDescObjArray, usb_epDescObjArray; - - usb_busObj = NULL; - usb_busObj_prev = NULL; - main_usb_busObj = NULL; - -#ifdef DEBUGON - printf("usb_get_busses: usb_get_busses done (2)\n"); -#endif - - while (bus){ -#ifdef DEBUGON - printf("\tusb_get_busses: bus %x (3)\n", bus); -#endif - - // create a new object for every bus - if (!usb_busObj) { - usb_busObj = env->NewObject(usb_busClazz, usb_busMid); - if (!usb_busObj) { - setLibusbJavaError("shared library error: Error NewObject (usb_busObj)"); - return NULL; - } - main_usb_busObj = usb_busObj; - } - - // fill the fields of the object - usb_busObj_next = NULL; - if (bus->next){ - usb_busObj_next = env->NewObject(usb_busClazz, usb_busMid); - if (!usb_busObj_next) { - setLibusbJavaError("shared library error: Error NewObject (usb_busObj_next)"); - return NULL; - } - } - env->SetObjectField(usb_busObj, usb_busFID_next, usb_busObj_next); - env->SetObjectField(usb_busObj, usb_busFID_prev, usb_busObj_prev); - env->SetObjectField(usb_busObj, usb_busFID_dirname, env->NewStringUTF(bus->dirname)); - env->SetLongField(usb_busObj, usb_busFID_location, bus->location); - - dev = bus->devices; - usb_devObj = NULL; - usb_devObj_prev = NULL; - main_usb_devObj = NULL; - - while (dev){ -#ifdef DEBUGON - printf("\tusb_get_busses: dev %x (4)\n", dev); -#endif - // create a new object for every device - if (!usb_devObj){ - usb_devObj = env->NewObject(usb_devClazz, usb_devMid); - if (!usb_devObj) { - setLibusbJavaError("shared library error: Error NewObject (usb_devObj)"); - return NULL; - } - main_usb_devObj = usb_devObj; - } - // fill the fields of the object - usb_devObj_next = NULL; - if (dev->next){ - usb_devObj_next = env->NewObject(usb_devClazz, usb_devMid); - if (!usb_devObj_next) { - setLibusbJavaError("shared library error: Error NewObject (usb_devObj_next)"); - return NULL; - } - } - env->SetObjectField(usb_devObj, usb_devFID_next, usb_devObj_next); - env->SetObjectField(usb_devObj, usb_devFID_prev, usb_devObj_prev); - env->SetObjectField(usb_devObj, usb_devFID_bus, usb_busObj); - env->SetObjectField(usb_devObj, usb_devFID_filename, env->NewStringUTF(dev->filename)); - env->SetByteField(usb_devObj, usb_devFID_devnum, dev->devnum); - env->SetByteField(usb_devObj, usb_devFID_num_children, dev->num_children); - env->SetLongField(usb_devObj, usb_devFID_devStructAddr, (jlong) dev); - - // device descriptor - usb_devDescObj = env->NewObject(usb_devDescClazz, usb_devDescMid); - if (!usb_devDescObj) { - setLibusbJavaError("shared library error: Error NewObject (usb_devDescObj)"); - return NULL; - } - env->SetByteField(usb_devDescObj, usb_devDescFID_bLength, dev->descriptor.bLength); - env->SetByteField(usb_devDescObj, usb_devDescFID_bDescriptorType, dev->descriptor.bDescriptorType); - env->SetShortField(usb_devDescObj, usb_devDescFID_bcdUSB, dev->descriptor.bcdUSB); - env->SetByteField(usb_devDescObj, usb_devDescFID_bDeviceClass, dev->descriptor.bDeviceClass); - env->SetByteField(usb_devDescObj, usb_devDescFID_bDeviceSubClass, dev->descriptor.bDeviceSubClass); - env->SetByteField(usb_devDescObj, usb_devDescFID_bDeviceProtocol, dev->descriptor.bDeviceProtocol); - env->SetByteField(usb_devDescObj, usb_devDescFID_bMaxPacketSize0, dev->descriptor.bMaxPacketSize0); - env->SetShortField(usb_devDescObj, usb_devDescFID_idVendor, dev->descriptor.idVendor); - env->SetShortField(usb_devDescObj, usb_devDescFID_idProduct, dev->descriptor.idProduct); - env->SetShortField(usb_devDescObj, usb_devDescFID_bcdDevice, dev->descriptor.bcdDevice); - env->SetByteField(usb_devDescObj, usb_devDescFID_iManufacturer, dev->descriptor.iManufacturer); - env->SetByteField(usb_devDescObj, usb_devDescFID_iProduct, dev->descriptor.iProduct); - env->SetByteField(usb_devDescObj, usb_devDescFID_iSerialNumber, dev->descriptor.iSerialNumber); - env->SetByteField(usb_devDescObj, usb_devDescFID_bNumConfigurations, dev->descriptor.bNumConfigurations); - - env->SetObjectField(usb_devObj, usb_devFID_descriptor, usb_devDescObj); - // configuration descriptor - // Loop through all of the configurations - usb_confDescObjArray = (jobjectArray) env->NewObjectArray(dev->descriptor.bNumConfigurations, usb_confDescClazz, NULL); - if (!usb_confDescObjArray) { - setLibusbJavaError("shared library error: Error NewObject 6"); - return NULL; - } - for (int c = 0; c < dev->descriptor.bNumConfigurations; c++){ -#ifdef DEBUGON - printf("\t\tusb_get_busses: configuration %x (5)\n", c); -#endif - if (dev->config == NULL) { - // this shouldn't happen, but it did occasionally (maybe this is (or probably was) a libusb bug) - setLibusbJavaError("shared library error: dev->config == NULL"); - return main_usb_busObj; - } - - usb_confDescObj = env->NewObject(usb_confDescClazz, usb_confDescMid); - if (!usb_confDescObj) { - setLibusbJavaError("shared library error: Error NewObject (usb_confDescObj)"); - return NULL; - } - env->SetObjectArrayElement(usb_confDescObjArray, c, usb_confDescObj); - env->SetByteField(usb_confDescObj, usb_confDescFID_bLength, dev->config[c].bLength); - env->SetByteField(usb_confDescObj, usb_confDescFID_bDescriptorType, dev->config[c].bDescriptorType); - env->SetShortField(usb_confDescObj, usb_confDescFID_wTotalLength, dev->config[c].wTotalLength); - env->SetByteField(usb_confDescObj, usb_confDescFID_bNumInterfaces, dev->config[c].bNumInterfaces); - env->SetByteField(usb_confDescObj, usb_confDescFID_bConfigurationValue, dev->config[c].bConfigurationValue); - env->SetByteField(usb_confDescObj, usb_confDescFID_iConfiguration, dev->config[c].iConfiguration); - env->SetByteField(usb_confDescObj, usb_confDescFID_bmAttributes, dev->config[c].bmAttributes); - env->SetByteField(usb_confDescObj, usb_confDescFID_MaxPower, dev->config[c].MaxPower); - env->SetIntField(usb_confDescObj, usb_confDescFID_extralen, dev->config[c].extralen); - if (dev->config[c].extra){ - jbyteArray jbExtraDesc = env->NewByteArray(dev->config[c].extralen); - env->SetByteArrayRegion(jbExtraDesc, 0, dev->config[c].extralen, (jbyte *) dev->config[c].extra); - env->SetObjectField(usb_confDescObj, usb_confDescFID_extra, jbExtraDesc); - } else { - env->SetObjectField(usb_confDescObj, usb_confDescFID_extra, NULL); - } - // interface - usb_intObjArray = (jobjectArray) env->NewObjectArray(dev->config[c].bNumInterfaces, usb_intClazz, NULL); - if (!usb_intObjArray) { - setLibusbJavaError("shared library error: Error NewObject (usb_intObjArray)"); - return NULL; - } - for (int i = 0; i < dev->config[c].bNumInterfaces; i++){ -#ifdef DEBUGON - printf("\t\t\tusb_get_busses: interface %x (6)\n", i); -#endif - if (dev->config[c].interface == NULL) { - // this shouldn't happen - printf("dev->config[c].interface == NULL"); - return main_usb_busObj; - } - - usb_intObj = env->NewObject(usb_intClazz, usb_intMid); - if (!usb_intObj) { - setLibusbJavaError("shared library error: Error NewObject (usb_intObj)"); - return NULL; - } - env->SetObjectArrayElement(usb_intObjArray, i, usb_intObj); - env->SetIntField(usb_intObj, usb_intFID_num_altsetting, dev->config[c].interface[i].num_altsetting); - // interface descriptor - usb_intDescObjArray = (jobjectArray) env->NewObjectArray(dev->config[c].interface[i].num_altsetting, usb_intDescClazz, NULL); - if (!usb_intDescObjArray) { - setLibusbJavaError("shared library error: Error NewObject (usb_intDescObjArray)"); - return NULL; - } - for (int a = 0; a < dev->config[c].interface[i].num_altsetting; a++){ -#ifdef DEBUGON - printf("\t\t\t\tusb_get_busses: interface descriptor %x (7)\n", a); -#endif - if (dev->config[c].interface[i].altsetting == NULL) { - // this shouldn't happen - printf("LibusbJava: usb_get_busses: dev->config[c].interface[i].altsetting == NULL\n"); - return main_usb_busObj; - } - - usb_intDescObj = env->NewObject(usb_intDescClazz, usb_intDescMid); - if (!usb_intDescObj) { - setLibusbJavaError("shared library error: Error NewObject (usb_intDescObj)"); - return NULL; - } - env->SetObjectArrayElement(usb_intDescObjArray, a, usb_intDescObj); - env->SetByteField(usb_intDescObj, usb_intDescFID_bLength, dev->config[c].interface[i].altsetting[a].bLength); - env->SetByteField(usb_intDescObj, usb_intDescFID_bDescriptorType, dev->config[c].interface[i].altsetting[a].bDescriptorType); - env->SetByteField(usb_intDescObj, usb_intDescFID_bInterfaceNumber, dev->config[c].interface[i].altsetting[a].bInterfaceNumber); - env->SetByteField(usb_intDescObj, usb_intDescFID_bAlternateSetting, dev->config[c].interface[i].altsetting[a].bAlternateSetting); - env->SetByteField(usb_intDescObj, usb_intDescFID_bNumEndpoints, dev->config[c].interface[i].altsetting[a].bNumEndpoints); - env->SetByteField(usb_intDescObj, usb_intDescFID_bInterfaceClass, dev->config[c].interface[i].altsetting[a].bInterfaceClass); - env->SetByteField(usb_intDescObj, usb_intDescFID_bInterfaceSubClass, dev->config[c].interface[i].altsetting[a].bInterfaceSubClass); - env->SetByteField(usb_intDescObj, usb_intDescFID_bInterfaceProtocol, dev->config[c].interface[i].altsetting[a].bInterfaceProtocol); - env->SetByteField(usb_intDescObj, usb_intDescFID_iInterface, dev->config[c].interface[i].altsetting[a].iInterface); - env->SetIntField(usb_intDescObj, usb_intDescFID_extralen, dev->config[c].interface[i].altsetting[a].extralen); - if (dev->config[c].interface[i].altsetting[a].extra){ - jbyteArray jbExtraDesc = env->NewByteArray(dev->config[c].interface[i].altsetting[a].extralen); - env->SetByteArrayRegion(jbExtraDesc, 0, dev->config[c].interface[i].altsetting[a].extralen, (jbyte *) dev->config[c].interface[i].altsetting[a].extra); - env->SetObjectField(usb_intDescObj, usb_intDescFID_extra, jbExtraDesc); - } else { - env->SetObjectField(usb_intDescObj, usb_intDescFID_extra, NULL); - } - // endpoint descriptor - usb_epDescObjArray = (jobjectArray) env->NewObjectArray(dev->config[c].interface[i].altsetting[a].bNumEndpoints, usb_epDescClazz, NULL); - if (!usb_epDescObjArray) { - setLibusbJavaError("shared library error: Error NewObject (usb_epDescObjArray)"); - return NULL; - } - for (int e = 0; e < dev->config[c].interface[i].altsetting[a].bNumEndpoints; e++){ -#ifdef DEBUGON - printf("\t\t\t\t\tusb_get_busses: endpoint descriptor %x (8)\n", e); -#endif - if (dev->config[c].interface[i].altsetting[a].endpoint == NULL) { - printf("LibusbJava: usb_get_busses: dev->config[c].interface[i].altsetting[a].endpoint == NULL\n"); - return main_usb_busObj; - } - - usb_epDescObj = env->NewObject(usb_epDescClazz, usb_epDescMid); - if (!usb_epDescObj) { - setLibusbJavaError("shared library error: Error NewObject (usb_epDescObj)"); - return NULL; - } - env->SetObjectArrayElement(usb_epDescObjArray, e, usb_epDescObj); - env->SetByteField(usb_epDescObj, usb_epDescFID_bLength, dev->config[c].interface[i].altsetting[a].endpoint[e].bLength); - env->SetByteField(usb_epDescObj, usb_epDescFID_bDescriptorType, dev->config[c].interface[i].altsetting[a].endpoint[e].bDescriptorType); - env->SetByteField(usb_epDescObj, usb_epDescFID_bEndpointAddress, dev->config[c].interface[i].altsetting[a].endpoint[e].bEndpointAddress); - env->SetByteField(usb_epDescObj, usb_epDescFID_bmAttributes, dev->config[c].interface[i].altsetting[a].endpoint[e].bmAttributes); - env->SetShortField(usb_epDescObj, usb_epDescFID_wMaxPacketSize, dev->config[c].interface[i].altsetting[a].endpoint[e].wMaxPacketSize); - env->SetByteField(usb_epDescObj, usb_epDescFID_bInterval, dev->config[c].interface[i].altsetting[a].endpoint[e].bInterval); - env->SetByteField(usb_epDescObj, usb_epDescFID_bRefresh, dev->config[c].interface[i].altsetting[a].endpoint[e].bRefresh); - env->SetByteField(usb_epDescObj, usb_epDescFID_bSynchAddress, dev->config[c].interface[i].altsetting[a].endpoint[e].bSynchAddress); - env->SetIntField(usb_epDescObj, usb_epDescFID_extralen, dev->config[c].interface[i].altsetting[a].endpoint[e].extralen); - if (dev->config[c].interface[i].altsetting[a].endpoint[e].extra){ - jbyteArray jbExtraDesc = env->NewByteArray(dev->config[c].interface[i].altsetting[a].endpoint[e].extralen); - env->SetByteArrayRegion(jbExtraDesc, 0, dev->config[c].interface[i].altsetting[a].endpoint[e].extralen, (jbyte *) dev->config[c].interface[i].altsetting[a].endpoint[e].extra); - env->SetObjectField(usb_epDescObj, usb_epDescFID_extra, jbExtraDesc); - } else { - env->SetObjectField(usb_epDescObj, usb_epDescFID_extra, NULL); - } - } - env->SetObjectField(usb_intDescObj, usb_intDescFID_endpoint, usb_epDescObjArray); - } - env->SetObjectField(usb_intObj, usb_intFID_altsetting, usb_intDescObjArray); - } - env->SetObjectField(usb_confDescObj, usb_confDescFID_interface_, usb_intObjArray); - } - - - env->SetObjectField(usb_devObj, usb_devFID_config, usb_confDescObjArray); - - usb_devObj_prev = usb_devObj; - usb_devObj = usb_devObj_next; - dev = dev->next; - } - env->SetObjectField(usb_busObj, usb_busFID_devices, main_usb_devObj); - env->SetObjectField(usb_busObj, usb_busFID_root_dev, main_usb_devObj); - - usb_busObj_prev = usb_busObj; - usb_busObj = usb_busObj_next; - bus = bus->next; - } - -#ifdef DEBUGON - printf("usb_get_busses: done\n"); -#endif - return main_usb_busObj; - } - -/* - * Class: ch_ntb_usb_LibusbJava - * Method: usb_open - * Signature: (Lch/ntb/usb/Usb_Device;)I - */ -JNIEXPORT jlong JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava_usb_1open - (JNIEnv *env, jclass obj, jobject dev) - { - clearLibusbJavaError(); - if (busses == NULL) { - setLibusbJavaError("shared library error: busses is null"); - return 0; - } - - unsigned char devnum = env->GetByteField(dev, usb_devFID_devnum); - struct usb_device *usb_device_cmp; - jlong usb_device_cmp_addr = env->GetLongField(dev, usb_devFID_devStructAddr); - struct usb_bus *tmpBus; - - for (tmpBus = busses; tmpBus; tmpBus = tmpBus->next) { - struct usb_device *device; - for (device = tmpBus->devices; device; device = device->next) { - if ((jlong) device == usb_device_cmp_addr){ - return (jlong) usb_open(device); - } - } - } - setLibusbJavaError("shared library error: no device with dev.devnum found on busses"); - return 0; - } - -/* - * Class: ch_ntb_usb_LibusbJava - * Method: usb_close - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava_usb_1close - (JNIEnv *env, jclass obj, jlong dev_handle) - { - clearLibusbJavaError(); - return (jint) usb_close((usb_dev_handle *) dev_handle); - } - -/* - * Class: ch_ntb_usb_LibusbJava - * Method: usb_set_configuration - * Signature: (II)I - */ -JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava_usb_1set_1configuration - (JNIEnv *env, jclass obj, jlong dev_handle, jint configuration) - { - clearLibusbJavaError(); - return usb_set_configuration((usb_dev_handle *) dev_handle, configuration); - } - -/* - * Class: ch_ntb_usb_LibusbJava - * Method: usb_set_altinterface - * Signature: (II)I - */ -JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava_usb_1set_1altinterface - (JNIEnv *env, jclass obj, jlong dev_handle, jint alternate) - { - clearLibusbJavaError(); - return usb_set_altinterface((usb_dev_handle *) dev_handle, alternate); - } - -/* - * Class: ch_ntb_usb_LibusbJava - * Method: usb_clear_halt - * Signature: (II)I - */ -JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava_usb_1clear_1halt - (JNIEnv *env, jclass obj, jlong dev_handle, jint ep) - { - clearLibusbJavaError(); - return usb_clear_halt((usb_dev_handle *) dev_handle, (unsigned) ep); - } - -/* - * Class: ch_ntb_usb_LibusbJava - * Method: usb_reset - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava_usb_1reset - (JNIEnv *env, jclass obj, jlong dev_handle) - { - clearLibusbJavaError(); - return usb_reset((usb_dev_handle *) dev_handle); - } - -/* - * Class: ch_ntb_usb_LibusbJava - * Method: usb_claim_interface - * Signature: (II)I - */ -JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava_usb_1claim_1interface - (JNIEnv *env, jclass obj, jlong dev_handle, jint interface) - { - clearLibusbJavaError(); - return usb_claim_interface((usb_dev_handle *) dev_handle, interface); - } - -/* - * Class: ch_ntb_usb_LibusbJava - * Method: usb_release_interface - * Signature: (II)I - */ -JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava_usb_1release_1interface - (JNIEnv *env, jclass obj, jlong dev_handle, jint interface) - { - clearLibusbJavaError(); - return usb_release_interface((usb_dev_handle *) dev_handle, interface); - } - -/* - * Class: ch_ntb_usb_LibusbJava - * Method: usb_control_msg - * Signature: (IIIII[BII)I - */ -JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava_usb_1control_1msg - (JNIEnv *env, jclass obj, jlong dev_handle, jint requesttype, jint request, jint value, jint index, jbyteArray jbytes, jint size, jint timeout) - { - clearLibusbJavaError(); - jbyte *bytes = env->GetByteArrayElements(jbytes, NULL); - int num_bytes = usb_control_msg((usb_dev_handle *) dev_handle, requesttype, request, value, index, (char *) bytes, size, timeout); - env->SetByteArrayRegion(jbytes, 0, size, bytes); - env->ReleaseByteArrayElements(jbytes, bytes, 0); - return num_bytes; - } - -/* - * Class: ch_ntb_usb_LibusbJava - * Method: usb_get_string - * Signature: (III)Ljava/lang/String; - */ -JNIEXPORT jstring JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava_usb_1get_1string - (JNIEnv *env, jclass obj, jlong dev_handle, jint index, jint langid) - { - clearLibusbJavaError(); - char string[256]; - int retVal = usb_get_string((usb_dev_handle *) dev_handle, index, langid, string, 256); - if (retVal > 0) - return env->NewStringUTF(string); - return 0; - } - -/* - * Class: ch_ntb_usb_LibusbJava - * Method: usb_get_string_simple - * Signature: (II)Ljava/lang/String; - */ -JNIEXPORT jstring JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava_usb_1get_1string_1simple - (JNIEnv *env, jclass obj, jlong dev_handle, jint index) - { - clearLibusbJavaError(); - char string[256]; - int retVal = usb_get_string_simple((usb_dev_handle *) dev_handle, index, string, 256); - if (retVal > 0) - return env->NewStringUTF(string); - return 0; - } - -/* - * Class: ch_ntb_usb_LibusbJava - * Method: usb_get_descriptor - * Signature: (IBBI)Ljava/lang/String; - */ -JNIEXPORT jstring JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava_usb_1get_1descriptor - (JNIEnv *env, jclass obj, jlong dev_handle, jbyte type, jbyte index, jint size) - { - clearLibusbJavaError(); - char *string = (char *) malloc(size * sizeof(char)); - int retVal = usb_get_descriptor((usb_dev_handle *) dev_handle, (unsigned) type, - (unsigned) index, string, size); - if (retVal > 0) - return env->NewStringUTF(string); - return 0; - } - -/* - * Class: ch_ntb_usb_LibusbJava - * Method: usb_get_descriptor_by_endpoint - * Signature: (IIBBI)Ljava/lang/String; - */ -JNIEXPORT jstring JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava_usb_1get_1descriptor_1by_1endpoint - (JNIEnv *env, jclass obj, jlong dev_handle, jint ep, jbyte type, jbyte index, jint size) - { - clearLibusbJavaError(); - char *string = (char *) malloc(size * sizeof(char)); - int retVal = usb_get_descriptor_by_endpoint((usb_dev_handle *) dev_handle, ep, (unsigned) type, - (unsigned) index, string, size); - if (retVal > 0) - return env->NewStringUTF(string); - return 0; - } - -/* - * Class: ch_ntb_usb_LibusbJava - * Method: usb_bulk_write - * Signature: (II[BII)I - */ -JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava_usb_1bulk_1write - (JNIEnv *env, jclass obj, jlong dev_handle, jint ep, jbyteArray jbytes, jint size, jint timeout) - { - clearLibusbJavaError(); - jbyte *bytes = env->GetByteArrayElements(jbytes, NULL); - int num_bytes = usb_bulk_write((usb_dev_handle *) dev_handle, ep, (char *) bytes, size, timeout); - env->ReleaseByteArrayElements(jbytes, bytes, 0); - return num_bytes; - } - -/* - * Class: ch_ntb_usb_LibusbJava - * Method: usb_bulk_read - * Signature: (II[BII)I - */ -JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava_usb_1bulk_1read - (JNIEnv *env, jclass obj, jlong dev_handle, jint ep, jbyteArray jbytes, jint size, jint timeout) - { - clearLibusbJavaError(); - char *bytes = (char *) malloc(size * sizeof(char)); - int num_bytes = usb_bulk_read((usb_dev_handle *) dev_handle, ep, bytes, size, timeout); - if (!bytes) { return num_bytes; } - env->SetByteArrayRegion(jbytes, 0, size, (jbyte *) bytes); - free(bytes); - return num_bytes; - } - -/* - * Class: ch_ntb_usb_LibusbJava - * Method: usb_interrupt_write - * Signature: (II[BII)I - */ -JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava_usb_1interrupt_1write - (JNIEnv *env, jclass obj, jlong dev_handle, jint ep, jbyteArray jbytes, jint size, jint timeout) - { - clearLibusbJavaError(); - jbyte *bytes = env->GetByteArrayElements(jbytes, NULL); - int num_bytes = usb_interrupt_write((usb_dev_handle *) dev_handle, ep, (char *) bytes, size, timeout); - env->ReleaseByteArrayElements(jbytes, bytes, 0); - return num_bytes; - } - -/* - * Class: ch_ntb_usb_LibusbJava - * Method: usb_interrupt_read - * Signature: (II[BII)I - */ -JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava_usb_1interrupt_1read - (JNIEnv *env, jclass obj, jlong dev_handle, jint ep, jbyteArray jbytes, jint size, jint timeout) - { - clearLibusbJavaError(); - char *bytes = (char *) malloc(size * sizeof(char)); - int num_bytes = usb_interrupt_read((usb_dev_handle *) dev_handle, ep, bytes, size, timeout); - if (!bytes) { return num_bytes; } - env->SetByteArrayRegion(jbytes, 0, size, (jbyte *) bytes); - free(bytes); - return num_bytes; - } - -/* - * Class: ch_ntb_usb_LibusbJava - * Method: usb_strerror - * Signature: ()Ljava/lang/String; - */ -JNIEXPORT jstring JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava_usb_1strerror - (JNIEnv *env, jclass obj){ - - char *str; - // check for LibusbJava specific errors first - if (libusbJavaError != NULL) { - str = libusbJavaError; - clearLibusbJavaError(); - } else { - str = usb_strerror(); - } - - return env->NewStringUTF(str); - } - -/* - * Class: ch_ntb_usb_LibusbJava - * Method: usb_error_no - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava_usb_1error_1no - (JNIEnv *env, jclass obj, jint java_error_no){ - - switch (java_error_no) { - case 0: - return 0; - case 1: - return EBADF; - case 2: - return ENXIO; - case 3: - return EBUSY; - case 4: - return EINVAL; - case 5: - return ETIMEDOUT; - case 6: - return EIO; - case 7: - return ENOMEM; - default: - return 100000; + if (!res) { + return (jlong) context; + } else { + return (jlong) res; } } + +/******************************************************************************************** + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_exit + * Signature: (J)V + *******************************************************************************************/ +JNIEXPORT void JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1exit(JNIEnv *env, jclass obj, jlong ctx) { + libusb_context *context = NULL; + clearLibusbJavaError(); + if (ctx) { + context = (libusb_context*) ((unsigned long) ctx); + } + libusb_exit(context); +} + +/******************************************************************************************** + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_get_device_list + * Signature: (J)Lch/ntb/inf/libusbJava/Usb_Device; + ********************************************************************************************/ +JNIEXPORT jobject JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1get_1device_1list( JNIEnv *env, jclass obj, jlong ctx) { + libusb_device **devs; + libusb_context *context = NULL; + ssize_t cnt; + int res, a, i; + uint8_t c, h, e; + + /* only load class references, method and field ID once*/ + if (!java_references_loaded) { + /* find classes and field ids*/ +#ifdef DEBUGON + printf("load references starts\n"); +#endif + + /*usb_device*/ + jobject devClazz = env->FindClass("ch/ntb/inf/libusbJava/Usb_Device");//returns a local reference + usb_devClazz = (jclass)env->NewGlobalRef(devClazz);//make it global + if (usb_devClazz == NULL) { + return NULL; /* exception thrown */ + } + usb_devMid = env->GetMethodID(usb_devClazz, "", "()V"); + if (usb_devMid == NULL) { + return NULL; + } + + usb_devFID_next = env->GetFieldID(usb_devClazz, "next", "Lch/ntb/inf/libusbJava/Usb_Device;"); + usb_devFID_prev = env->GetFieldID(usb_devClazz, "prev", "Lch/ntb/inf/libusbJava/Usb_Device;"); + usb_devFID_filename = env->GetFieldID(usb_devClazz, "filename", "Ljava/lang/String;"); + usb_devFID_bus = env->GetFieldID(usb_devClazz, "bus", "Lch/ntb/inf/libusbJava/Usb_Bus;"); + usb_devFID_descriptor = env->GetFieldID(usb_devClazz, "descriptor", "Lch/ntb/inf/libusbJava/Usb_Device_Descriptor;"); + usb_devFID_config = env->GetFieldID(usb_devClazz, "config", "[Lch/ntb/inf/libusbJava/Usb_Config_Descriptor;"); + usb_devFID_devnum = env->GetFieldID(usb_devClazz, "devnum", "B"); + usb_devFID_num_children = env->GetFieldID(usb_devClazz, "num_children", "B"); + usb_devFID_children = env->GetFieldID(usb_devClazz, "children", "Lch/ntb/inf/libusbJava/Usb_Device;"); + usb_devFID_devStructAddr = env->GetFieldID(usb_devClazz, "devStructAddr", "J"); + +#ifdef DEBUGON + printf("usb_device references loaded\n"); +#endif + /* usb_device_descriptor*/ + jobject devDescClazz = env->FindClass("ch/ntb/inf/libusbJava/Usb_Device_Descriptor");//returns a local reference + usb_devDescClazz = (jclass)env->NewGlobalRef(devDescClazz);//make it global + if (usb_devDescClazz == NULL) { + return NULL; /* exception thrown */ + } + usb_devDescMid = env->GetMethodID(usb_devDescClazz, "", "()V"); + if (usb_devDescMid == NULL) { + return NULL; + } + usb_devDescFID_bLength = env->GetFieldID(usb_devDescClazz, "bLength", "B"); + usb_devDescFID_bDescriptorType = env->GetFieldID(usb_devDescClazz, "bDescriptorType", "B"); + usb_devDescFID_bcdUSB = env->GetFieldID(usb_devDescClazz, "bcdUSB", "S"); + usb_devDescFID_bDeviceClass = env->GetFieldID(usb_devDescClazz, "bDeviceClass", "B"); + usb_devDescFID_bDeviceSubClass = env->GetFieldID(usb_devDescClazz, "bDeviceSubClass", "B"); + usb_devDescFID_bDeviceProtocol = env->GetFieldID(usb_devDescClazz, "bDeviceProtocol", "B"); + usb_devDescFID_bMaxPacketSize0 = env->GetFieldID(usb_devDescClazz, "bMaxPacketSize0", "B"); + usb_devDescFID_idVendor = env->GetFieldID(usb_devDescClazz, "idVendor", "S"); + usb_devDescFID_idProduct = env->GetFieldID(usb_devDescClazz, "idProduct", "S"); + usb_devDescFID_bcdDevice = env->GetFieldID(usb_devDescClazz, "bcdDevice", "S"); + usb_devDescFID_iManufacturer = env->GetFieldID(usb_devDescClazz, "iManufacturer", "B"); + usb_devDescFID_iProduct = env->GetFieldID(usb_devDescClazz, "iProduct", "B"); + usb_devDescFID_iSerialNumber = env->GetFieldID(usb_devDescClazz, "iSerialNumber", "B"); + usb_devDescFID_bNumConfigurations = env->GetFieldID(usb_devDescClazz, "bNumConfigurations", "B"); + + +#ifdef DEBUGON + printf("usb_device_descriptor references loaded\n"); +#endif + /* usb_configuration_descriptor*/ + jobject confDescClazz = env->FindClass("ch/ntb/inf/libusbJava/Usb_Config_Descriptor");//returns a local reference + usb_confDescClazz = (jclass)env->NewGlobalRef(confDescClazz);//make it global + if (usb_confDescClazz == NULL) { + return NULL; /* exception thrown */ + } + usb_confDescMid = env->GetMethodID(usb_confDescClazz, "", "()V"); + if (usb_confDescMid == NULL) { + return NULL; + } + + usb_confDescFID_bLength = env->GetFieldID(usb_confDescClazz, "bLength", "B"); + usb_confDescFID_bDescriptorType = env->GetFieldID(usb_confDescClazz, "bDescriptorType", "B"); + usb_confDescFID_wTotalLength = env->GetFieldID(usb_confDescClazz, "wTotalLength", "S"); + usb_confDescFID_bNumInterfaces = env->GetFieldID(usb_confDescClazz, "bNumInterfaces", "B"); + usb_confDescFID_bConfigurationValue = env->GetFieldID(usb_confDescClazz, "bConfigurationValue", "B"); + usb_confDescFID_iConfiguration = env->GetFieldID(usb_confDescClazz, "iConfiguration", "B"); + usb_confDescFID_bmAttributes = env->GetFieldID(usb_confDescClazz, "bmAttributes", "B"); + usb_confDescFID_MaxPower = env->GetFieldID(usb_confDescClazz, "MaxPower", "B"); + usb_confDescFID_interface_ = env->GetFieldID(usb_confDescClazz, "interface_", "[Lch/ntb/inf/libusbJava/Usb_Interface;"); + usb_confDescFID_extra = env->GetFieldID(usb_confDescClazz, "extra", "[B"); + usb_confDescFID_extralen = env->GetFieldID(usb_confDescClazz, "extralen", "I"); +#ifdef DEBUGON + printf("usb_configuration_descriptor references loaded\n"); +#endif + /* usb_interface*/ + jobject intClazz = env->FindClass("ch/ntb/inf/libusbJava/Usb_Interface");//returns a local reference + usb_intClazz = (jclass)env->NewGlobalRef(intClazz);//make it global + if (usb_intClazz == NULL) { + return NULL; /* exception thrown */ + } + usb_intMid = env->GetMethodID(usb_intClazz, "", "()V"); + if (usb_intMid == NULL) { + return NULL; + } + usb_intFID_altsetting = env->GetFieldID(usb_intClazz, "altsetting", "[Lch/ntb/inf/libusbJava/Usb_Interface_Descriptor;"); + usb_intFID_num_altsetting = env->GetFieldID(usb_intClazz, "num_altsetting", "I"); +#ifdef DEBUGON + printf("usb_interface references loaded\n"); +#endif + /* usb_interface_descriptor*/ + jobject intDescClazz = env->FindClass( "ch/ntb/inf/libusbJava/Usb_Interface_Descriptor");//returns a local reference + usb_intDescClazz = (jclass)env->NewGlobalRef(intDescClazz);//make it global + if (usb_intDescClazz == NULL) { + return NULL; /* exception thrown */ + } + usb_intDescMid = env->GetMethodID(usb_intDescClazz, "", "()V"); + if (usb_intDescMid == NULL) { + return NULL; + } + usb_intDescFID_bLength = env->GetFieldID(usb_intDescClazz, "bLength", "B"); + usb_intDescFID_bDescriptorType = env->GetFieldID(usb_intDescClazz, "bDescriptorType", "B"); + usb_intDescFID_bInterfaceNumber = env->GetFieldID(usb_intDescClazz, "bInterfaceNumber", "B"); + usb_intDescFID_bAlternateSetting = env->GetFieldID(usb_intDescClazz, "bAlternateSetting", "B"); + usb_intDescFID_bNumEndpoints = env->GetFieldID(usb_intDescClazz, "bNumEndpoints", "B"); + usb_intDescFID_bInterfaceClass = env->GetFieldID(usb_intDescClazz, "bInterfaceClass", "B"); + usb_intDescFID_bInterfaceSubClass = env->GetFieldID(usb_intDescClazz, "bInterfaceSubClass", "B"); + usb_intDescFID_bInterfaceProtocol = env->GetFieldID(usb_intDescClazz, "bInterfaceProtocol", "B"); + usb_intDescFID_iInterface = env->GetFieldID(usb_intDescClazz, "iInterface", "B"); + usb_intDescFID_endpoint = env->GetFieldID(usb_intDescClazz, "endpoint", "[Lch/ntb/inf/libusbJava/Usb_Endpoint_Descriptor;"); + usb_intDescFID_extra = env->GetFieldID(usb_intDescClazz, "extra", "[B"); + usb_intDescFID_extralen = env->GetFieldID(usb_intDescClazz, "extralen", "I"); +#ifdef DEBUGON + printf("usb_interface_descriptor references loaded\n"); +#endif + /* usb_endpoint_descriptor*/ + jobject epDescClazz = env->FindClass("ch/ntb/inf/libusbJava/Usb_Endpoint_Descriptor");//returns a local reference + usb_epDescClazz = (jclass)env->NewGlobalRef(epDescClazz);//make it global + if (usb_epDescClazz == NULL) { + return NULL; /* exception thrown */ + } + usb_epDescMid = env->GetMethodID(usb_epDescClazz, "", "()V"); + if (usb_epDescMid == NULL) { + return NULL; + } + usb_epDescFID_bLength = env->GetFieldID(usb_epDescClazz, "bLength", "B"); + usb_epDescFID_bDescriptorType = env->GetFieldID(usb_epDescClazz, "bDescriptorType", "B"); + usb_epDescFID_bEndpointAddress = env->GetFieldID(usb_epDescClazz, "bEndpointAddress", "B"); + usb_epDescFID_bmAttributes = env->GetFieldID(usb_epDescClazz, "bmAttributes", "B"); + usb_epDescFID_wMaxPacketSize = env->GetFieldID(usb_epDescClazz, "wMaxPacketSize", "S"); + usb_epDescFID_bInterval = env->GetFieldID(usb_epDescClazz, "bInterval", "B"); + usb_epDescFID_bRefresh = env->GetFieldID(usb_epDescClazz, "bRefresh", "B"); + usb_epDescFID_bSynchAddress = env->GetFieldID(usb_epDescClazz, "bSynchAddress", "B"); + usb_epDescFID_extra = env->GetFieldID(usb_epDescClazz, "extra", "[B"); + usb_epDescFID_extralen = env->GetFieldID(usb_epDescClazz, "extralen", "I"); +#ifdef DEBUGON + printf("usb_endpoint_descriptor references loaded\n"); +#endif + /*libusb_event*/ + jobject cb_clazz = env->FindClass("ch/ntb/inf/libusbJava/Libusb_event");//returns a local reference + usb_cb_clazz = (jclass)env->NewGlobalRef(cb_clazz);//make it global + if (usb_cb_clazz == NULL) { + printf("load Clazz failed\n"); + return NULL; /*exception thrown*/ + } + usb_transfer_cb_Mid = env->GetMethodID(usb_cb_clazz, "transferCallback", "()V"); + if (usb_transfer_cb_Mid == NULL) { + printf("load method transferCallback failed\n"); + return NULL; /* exception thrown */ + } + usb_fd_added_cb_Mid = env->GetMethodID(usb_cb_clazz, "fdAddedCallback", "(I)V"); + if (usb_fd_added_cb_Mid == NULL) { + printf("load method fdAddedCallback failed\n"); + return NULL;/* exception thrown */ + } + usb_fd_removed_cb_Mid = env->GetMethodID(usb_cb_clazz, "fdRemovedCallback", "(I)V"); + if (usb_fd_removed_cb_Mid == NULL) { + printf("load method fdRemovedCallback failed\n"); + return NULL;/* exception thrown */ + } +#ifdef DEBUGON + printf("usb_event_descriptor references loaded\n"); +#endif + /*Libusb_pollfd*/ + jobject pollfd_clazz = env->FindClass("ch/ntb/inf/libusbJava/Libusb_pollfd");//returns a local reference + usb_pollfd_clazz = (jclass)env->NewGlobalRef(pollfd_clazz);//make it global + if (usb_pollfd_clazz == NULL) { + return NULL; /*exception thrown*/ + } + usb_pollfd_Mid = env->GetMethodID(usb_pollfd_clazz, "", "()V"); + if (usb_devMid == NULL) { + return NULL; /*exception thrown*/ + } + usb_pollfdFID_fd = env->GetFieldID(usb_pollfd_clazz, "fd", "I"); + usb_pollfdFID_events = env->GetFieldID(usb_pollfd_clazz, "events", "B"); +#ifdef DEBUGON + printf("Libusb_pollfd_descriptor references loaded\n"); +#endif + java_references_loaded = 1; + +#ifdef DEBUGON + printf("libusb_init: Field initialization done \n"); +#endif + } + + /* objects*/ + jobject root_usb_devObj, usb_devObj, usb_devObj_next, usb_devObj_prev, + usb_devDescObj, usb_confDescObj, usb_intObj, usb_intDescObj, + usb_epDescObj; + + jobjectArray usb_confDescObjArray, usb_intObjArray, usb_intDescObjArray, + usb_epDescObjArray; + clearLibusbJavaError(); + + libusb_config_descriptor *conf_desc; + if (ctx > 0) { + context = (libusb_context*) ((unsigned long) ctx); + cnt = libusb_get_device_list(context, &devs); + } else { + cnt = libusb_get_device_list(NULL, &devs); + } + if (cnt < 0) { + setLibusbJavaError("libusb_get_device_list: Error on Memory allocation"); + libusb_free_device_list(devs, 1); + return NULL; + } + + /*empty list*/ + if (!cnt) { + libusb_free_device_list(devs, 1); + usb_devObj = env->NewObject(usb_devClazz, usb_devMid); + env->SetByteField(usb_devObj, usb_devFID_devnum, -1); + } + usb_devObj = NULL; + usb_devObj_next = NULL; + usb_devObj_prev = NULL; + /* create a new object for every device*/ + for (i = 0; i < cnt; i++) { +#ifdef DEBUGON + printf("libusb_get_device_list: dev %u \n", i); +#endif + char filename[3]; + + libusb_device_descriptor dev_desc; + res = libusb_get_device_descriptor(devs[i], &dev_desc); + + if (res) { + /* this shouldn't happen*/ + printf("\t libusb_get _device_list: dev %u coudn't read Devicedescriptor\n",i); + continue; + } + if (dev_desc.bLength != 18) { + printf("Corrupt Devicedescriptor dev %d\n", i); + continue; + } + + if (!usb_devObj) { + usb_devObj = env->NewObject(usb_devClazz, usb_devMid); + if (!usb_devObj) { + setLibusbJavaError("shared library error: Error NewObject (usb_devObj)"); + return NULL; + } + root_usb_devObj = usb_devObj; + } + usb_devObj_next = NULL; + if (i < cnt - 1) { + usb_devObj_next = env->NewObject(usb_devClazz, usb_devMid); + if (!usb_devObj_next) { + setLibusbJavaError("shared library error: Error NewObject (usb_devObj_next)"); + return NULL; + } + } + /*fill the fields of the object*/ + env->SetObjectField(usb_devObj, usb_devFID_next, usb_devObj_next); + env->SetObjectField(usb_devObj, usb_devFID_prev, usb_devObj_prev); + sprintf(filename, "%03d", libusb_get_device_address(devs[i])); + env->SetObjectField(usb_devObj, usb_devFID_filename, env->NewStringUTF(filename));/*like the compatibility Layer*/ + env->SetByteField(usb_devObj, usb_devFID_devnum, libusb_get_device_address(devs[i])); + env->SetByteField(usb_devObj, usb_devFID_num_children, 0);/*Hardcoded to 0, like the compatibility Layer*/ + env->SetObjectField(usb_devObj, usb_devFID_children, NULL);/*Hardcoded to NULL, like the compatibility Layer*/ + env->SetLongField(usb_devObj, usb_devFID_devStructAddr, (jlong) devs[i]); + + /*device Descriptor*/ + usb_devDescObj = env->NewObject(usb_devDescClazz, usb_devDescMid); + if (!usb_devDescObj) { + setLibusbJavaError("shared library error: Error NewObject (usb_devDescObj)"); + return NULL; + } + env->SetByteField(usb_devDescObj, usb_devDescFID_bLength, dev_desc.bLength); + env->SetByteField(usb_devDescObj, usb_devDescFID_bDescriptorType, dev_desc.bDescriptorType); + env->SetShortField(usb_devDescObj, usb_devDescFID_bcdUSB, dev_desc.bcdUSB); + env->SetByteField(usb_devDescObj, usb_devDescFID_bDeviceClass, dev_desc.bDeviceClass); + env->SetByteField(usb_devDescObj, usb_devDescFID_bDeviceSubClass, dev_desc.bDeviceSubClass); + env->SetByteField(usb_devDescObj, usb_devDescFID_bDeviceProtocol, dev_desc.bDeviceProtocol); + env->SetByteField(usb_devDescObj, usb_devDescFID_bMaxPacketSize0, dev_desc.bMaxPacketSize0); + env->SetShortField(usb_devDescObj, usb_devDescFID_idVendor, dev_desc.idVendor); + env->SetShortField(usb_devDescObj, usb_devDescFID_idProduct, dev_desc.idProduct); + env->SetShortField(usb_devDescObj, usb_devDescFID_bcdDevice, dev_desc.bcdDevice); + env->SetByteField(usb_devDescObj, usb_devDescFID_iManufacturer, dev_desc.iManufacturer); + env->SetByteField(usb_devDescObj, usb_devDescFID_iProduct, dev_desc.iProduct); + env->SetByteField(usb_devDescObj, usb_devDescFID_iSerialNumber, dev_desc.iSerialNumber); + env->SetByteField(usb_devDescObj, usb_devDescFID_bNumConfigurations, dev_desc.bNumConfigurations); + env->SetObjectField(usb_devDescObj, usb_devFID_descriptor, usb_devDescObj); + env->SetObjectField(usb_devObj, usb_devFID_descriptor, usb_devDescObj); + + /*configuration descriptor*/ + /*Loop through all of the configurations*/ + usb_confDescObjArray = (jobjectArray) env->NewObjectArray(dev_desc.bNumConfigurations, usb_confDescClazz, NULL); + if (!usb_confDescObjArray) { + setLibusbJavaError("shared library error: Error NewOjectArray"); + return NULL; + } + for (c = 0; c < dev_desc.bNumConfigurations; c++) { +#ifdef DEBUGON + printf("\t\tlibusb_get_device_list: configuration %u, Dev: %d \n", c, i); +#endif + res = libusb_get_config_descriptor(devs[i], c, &conf_desc); + if (res) { + continue; + } + usb_confDescObj = env->NewObject(usb_confDescClazz, usb_confDescMid); + if (!usb_confDescObj) { + setLibusbJavaError("shared library error: Error NewObject (usb_confDescObj)"); + return NULL; + } + env->SetObjectArrayElement(usb_confDescObjArray, c, usb_confDescObj);/*add it to the Array*/ + /*fill the fields*/ + env->SetByteField(usb_confDescObj, usb_confDescFID_bLength, conf_desc->bLength); + env->SetByteField(usb_confDescObj, usb_confDescFID_bDescriptorType, conf_desc->bDescriptorType); + env->SetShortField(usb_confDescObj, usb_confDescFID_wTotalLength, conf_desc->wTotalLength); + env->SetByteField(usb_confDescObj, usb_confDescFID_bNumInterfaces, conf_desc->bNumInterfaces); + env->SetByteField(usb_confDescObj, usb_confDescFID_bConfigurationValue, conf_desc->bConfigurationValue); + env->SetByteField(usb_confDescObj, usb_confDescFID_iConfiguration, conf_desc->iConfiguration); + env->SetByteField(usb_confDescObj, usb_confDescFID_bmAttributes, conf_desc->bmAttributes); + env->SetByteField(usb_confDescObj, usb_confDescFID_MaxPower, conf_desc->MaxPower); + env->SetIntField(usb_confDescObj, usb_confDescFID_extralen, conf_desc->extra_length); + if (conf_desc->extra) { + jbyteArray jbExtraDesc = env->NewByteArray( conf_desc->extra_length); + env->SetByteArrayRegion(jbExtraDesc, 0, conf_desc->extra_length, (jbyte *) conf_desc->extra); + env->SetObjectField(usb_confDescObj, usb_confDescFID_extra, jbExtraDesc); + } else { + env->SetObjectField(usb_confDescObj, usb_confDescFID_extra, NULL); + } + /*interface*/ + usb_intObjArray = (jobjectArray) env->NewObjectArray(conf_desc->bNumInterfaces, usb_intClazz, NULL); + if (!usb_intObjArray) { + setLibusbJavaError("shared library error: Error NewObjectArray (usb_intObjArray)"); + return NULL; + } + for (h = 0; h < conf_desc->bNumInterfaces; h++) { +#ifdef DEBUGON + printf("\t\t\tlibusb_get_device_list: interface %u \n", h); +#endif + + if (conf_desc->interface == NULL) { + /* this shouldn't happen*/ + printf("(*conf_desc)->usb_interface == NULL"); + return root_usb_devObj; + } + usb_intObj = env->NewObject(usb_intClazz, usb_intMid); + if (!usb_intObj) { + setLibusbJavaError("shared library error: Error NewObject (usb_intObj)"); + return NULL; + } + env->SetObjectArrayElement(usb_intObjArray, h, usb_intObj); + env->SetIntField(usb_intObj, usb_intFID_num_altsetting, conf_desc->interface[h].num_altsetting); + // interface descriptor + usb_intDescObjArray = (jobjectArray) env->NewObjectArray( conf_desc->interface[h].num_altsetting, usb_intDescClazz, NULL); + if (!usb_intDescObjArray) { + setLibusbJavaError("shared library error: Error NewObjectArray (usb_intDescObjArray)"); + return NULL; + } + for (a = 0; a < conf_desc->interface[h].num_altsetting; a++) { +#ifdef DEBUGON + printf("\t\t\t\tlibusb_get_device_list: interface descriptor %u \n", a); +#endif + if (conf_desc->interface[h].altsetting == NULL) { + // this shouldn't happen + printf("LibusbJava: libusb_get_device_list: (*conf_desc)->interface->altsetting == NULL\n"); + return root_usb_devObj; + } + usb_intDescObj = env->NewObject(usb_intDescClazz, usb_intDescMid); + if (!usb_intDescObj) { + setLibusbJavaError("shared library error: Error NewObject (usb_intDescObj)"); + return NULL; + } + env->SetObjectArrayElement(usb_intDescObjArray, a, usb_intDescObj); + /*fill fields*/ + env->SetByteField(usb_intDescObj, usb_intDescFID_bLength, conf_desc->interface[h].altsetting[a].bLength); + env->SetByteField(usb_intDescObj, usb_intDescFID_bDescriptorType, conf_desc->interface[h].altsetting[a].bDescriptorType); + env->SetByteField(usb_intDescObj, usb_intDescFID_bInterfaceNumber, conf_desc->interface[h].altsetting[a].bInterfaceNumber); + env->SetByteField(usb_intDescObj, usb_intDescFID_bAlternateSetting, conf_desc->interface[h].altsetting[a].bAlternateSetting); + env->SetByteField(usb_intDescObj, usb_intDescFID_bNumEndpoints, conf_desc->interface[h].altsetting[a].bNumEndpoints); + env->SetByteField(usb_intDescObj, usb_intDescFID_bInterfaceClass, conf_desc->interface[h].altsetting[a].bInterfaceClass); + env->SetByteField(usb_intDescObj, usb_intDescFID_bInterfaceSubClass, conf_desc->interface[h].altsetting[a].bInterfaceSubClass); + env->SetByteField(usb_intDescObj, usb_intDescFID_bInterfaceProtocol, conf_desc->interface[h].altsetting[a].bInterfaceProtocol); + env->SetByteField(usb_intDescObj, usb_intDescFID_iInterface, conf_desc->interface[h].altsetting[a].iInterface); + env->SetIntField(usb_intDescObj, usb_intDescFID_extralen, conf_desc->interface[h].altsetting[a].extra_length); + if (conf_desc->interface[h].altsetting[a].extra) { + jbyteArray jbExtraDesc = env->NewByteArray( conf_desc->interface[h].altsetting[a].extra_length); + env->SetByteArrayRegion(jbExtraDesc, 0, conf_desc->interface[h].altsetting[a].extra_length, (jbyte *) conf_desc->interface[h].altsetting[a].extra); + env->SetObjectField(usb_intDescObj, usb_intDescFID_extra, jbExtraDesc); + } else { + env->SetObjectField(usb_intDescObj, usb_intDescFID_extra, NULL); + } + /*endpoint descriptor*/ + usb_epDescObjArray = (jobjectArray) env->NewObjectArray( conf_desc->interface[h].altsetting[a].bNumEndpoints, usb_epDescClazz, NULL); + if (!usb_epDescObjArray) { + setLibusbJavaError("shared library error: Error NewObjectArray (usb_epDescObjArray)"); + return NULL; + } + for (e = 0; e < conf_desc->interface[h].altsetting[a].bNumEndpoints; e++) { +#ifdef DEBUGON + printf("\t\t\t\t\tLibusb_get_device_list: endpoint descriptor %u \n",e); +#endif + + + if (conf_desc->interface[h].altsetting[a].endpoint == NULL) { + printf( "LibusbJava: usb_get_busses: (*conf_desc)->interface->altsetting->endpoint == NULL\n"); + return root_usb_devObj; + } + usb_epDescObj = env->NewObject(usb_epDescClazz, usb_epDescMid); + if (!usb_epDescObj) { + setLibusbJavaError("shared library error: Error NewObject (usb_epDescObj)"); + return NULL; + } + env->SetObjectArrayElement(usb_epDescObjArray, e, usb_epDescObj); + env->SetByteField(usb_epDescObj, usb_epDescFID_bLength, conf_desc->interface[h].altsetting[a].endpoint[e].bLength); + env->SetByteField(usb_epDescObj, usb_epDescFID_bDescriptorType, conf_desc->interface[h].altsetting[a].endpoint[e].bDescriptorType); + env->SetByteField(usb_epDescObj, usb_epDescFID_bEndpointAddress, conf_desc->interface[h].altsetting[a].endpoint[e].bEndpointAddress); + env->SetByteField(usb_epDescObj, usb_epDescFID_bmAttributes, conf_desc->interface[h].altsetting[a].endpoint[e].bmAttributes); + env->SetShortField(usb_epDescObj, usb_epDescFID_wMaxPacketSize, conf_desc->interface[h].altsetting[a].endpoint[e].wMaxPacketSize); + env->SetByteField(usb_epDescObj, usb_epDescFID_bInterval, conf_desc->interface[h].altsetting[a].endpoint[e].bInterval); + env->SetByteField(usb_epDescObj, usb_epDescFID_bRefresh, conf_desc->interface[h].altsetting[a].endpoint[e].bRefresh); + env->SetByteField(usb_epDescObj, usb_epDescFID_bSynchAddress, conf_desc->interface[h].altsetting[a].endpoint[e].bSynchAddress); + env->SetIntField(usb_epDescObj, usb_epDescFID_extralen, conf_desc->interface[h].altsetting[a].endpoint[e].extra_length); + if (conf_desc->interface[h].altsetting[a].endpoint[e].extra) { + jbyteArray jbExtraDesc = env->NewByteArray( conf_desc->interface[h].altsetting[a].endpoint[e].extra_length); + env->SetByteArrayRegion(jbExtraDesc, 0, conf_desc->interface[h].altsetting[a].endpoint[e].extra_length, (jbyte *) conf_desc->interface[h].altsetting[a].endpoint[e].extra); + env->SetObjectField(usb_epDescObj, usb_epDescFID_extra, jbExtraDesc); + } else { + env->SetObjectField(usb_epDescObj, usb_epDescFID_extra, NULL); + } + } + env->SetObjectField(usb_intDescObj, usb_intDescFID_endpoint, usb_epDescObjArray); + } + env->SetObjectField(usb_intObj, usb_intFID_altsetting, usb_intDescObjArray); + } + env->SetObjectField(usb_confDescObj, usb_confDescFID_interface_, usb_intObjArray); + libusb_free_config_descriptor(conf_desc); + } + if (res) { + env->SetLongField(usb_devObj, usb_devFID_devStructAddr, (jlong) 0); + continue; + } + env->SetObjectField(usb_devObj, usb_devFID_config, usb_confDescObjArray); + usb_devObj_prev = usb_devObj; + usb_devObj = usb_devObj_next; + + } + //Eliminate empty last device + env->SetObjectField(usb_devObj_prev, usb_devFID_next, NULL); + +// free(dev_desc); + libusb_free_device_list(devs, 0); +#ifdef DEBUGON + printf("libusb_get_device_list: done\n"); +#endif + return root_usb_devObj; +} + +/******************************************************************************************** + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_get_bus_number + * Signature: (Lch/ntb/inf/libusbJava/Usb_Device;)S + ********************************************************************************************/ +JNIEXPORT jshort JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1get_1bus_1number( JNIEnv *env, jclass obj, jobject dev) { + clearLibusbJavaError(); + libusb_device *libusb_dev = (libusb_device *) (long) env->GetLongField(dev, usb_devFID_devStructAddr); + return libusb_get_bus_number(libusb_dev); +} + +/******************************************************************************************** + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_get_max_iso_packet_size + * Signature: (Lch/ntb/inf/libusbJava/Usb_Device;S)I + ********************************************************************************************/ +JNIEXPORT jint +JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1get_1max_1iso_1packet_1size( JNIEnv *env, jclass obj, jobject dev, jshort epAddr) { + clearLibusbJavaError(); + libusb_device *libusb_dev = (libusb_device *) (unsigned long) env->GetLongField(dev, usb_devFID_devStructAddr); + return libusb_get_max_iso_packet_size(libusb_dev, epAddr); +} + +/******************************************************************************************** + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_ref_device + * Signature: (Lch/ntb/inf/libusbJava/Usb_Device;)Lch/ntb/inf/libusbJava/Usb_Device; + ********************************************************************************************/ +JNIEXPORT jobject JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1ref_1device(JNIEnv *env, jclass obj, jobject dev) { + clearLibusbJavaError(); + libusb_device *libusb_dev = (libusb_device *) (unsigned long) env->GetLongField(dev, usb_devFID_devStructAddr); + libusb_ref_device(libusb_dev); + return dev; +} + +/******************************************************************************************** + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_unref_device + * Signature: (Lch/ntb/inf/libusbJava/Usb_Device;)V + ********************************************************************************************/ +JNIEXPORT void JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1unref_1device(JNIEnv *env, jclass obj, jobject dev) { + clearLibusbJavaError(); + libusb_device *libusb_dev = (libusb_device *) (unsigned long) env->GetLongField(dev,usb_devFID_devStructAddr); + libusb_unref_device(libusb_dev); +} + +/******************************************************************************************** + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_open + * Signature: (Lch/ntb/inf/libusbJava/Usb_Device;)J + ********************************************************************************************/ +JNIEXPORT jlong JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1open( JNIEnv *env, jclass obj, jobject dev) { + clearLibusbJavaError(); + libusb_device_handle *handle; + libusb_device *libusb_dev = (libusb_device *) (unsigned long) env->GetLongField(dev, usb_devFID_devStructAddr); + int res = libusb_open(libusb_dev, &handle); + if(!res){ + return (jlong) handle; + } + return (jlong)res; +} + +/******************************************************************************************** + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_open_device_with_vid_pid + * Signature: (JII)J + ********************************************************************************************/ +JNIEXPORT jlong +JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1open_1device_1with_1vid_1pid(JNIEnv *env, jclass obj, jlong ctx, jint vendor_id, jint product_id) { + clearLibusbJavaError(); + return (jlong) libusb_open_device_with_vid_pid((libusb_context*) (unsigned long) ctx, vendor_id, product_id); +} + +/******************************************************************************************** + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_close + * Signature: (J)V + ********************************************************************************************/ +JNIEXPORT void JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1close(JNIEnv *env, jclass obj, jlong dev_handle) { + clearLibusbJavaError(); + libusb_close((libusb_device_handle*) (unsigned long) dev_handle); +} + +/******************************************************************************************** + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_get_device + * Signature: (J)Lch/ntb/inf/libusbJava/Usb_Device; + ********************************************************************************************/ +JNIEXPORT jobject JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1get_1device(JNIEnv *env, jclass obj, jlong handle) { + int res, a; + uint8_t c, h, e; + char filename[3]; + clearLibusbJavaError(); + libusb_config_descriptor *conf_desc; + struct libusb_device_descriptor dev_desc; + libusb_device *lib_dev = libusb_get_device((libusb_device_handle*) (unsigned long) handle); + + /* objects*/ + jobject usb_devObj, usb_devDescObj, usb_confDescObj, usb_intObj, usb_intDescObj, usb_epDescObj; + jobjectArray usb_confDescObjArray, usb_intObjArray, usb_intDescObjArray, usb_epDescObjArray; + + /* create a new object for device*/ + libusb_get_device_descriptor(lib_dev, &dev_desc); + usb_devObj = env->NewObject(usb_devClazz, usb_devMid); + if (!usb_devObj) { + setLibusbJavaError("shared library error: Error NewObject (usb_devObj)"); + return NULL; + } + + /*fill the fields of the object*/ + env->SetObjectField(usb_devObj, usb_devFID_next, NULL); + env->SetObjectField(usb_devObj, usb_devFID_prev, NULL); + + sprintf(filename, "%03d", libusb_get_device_address(lib_dev)); + env->SetObjectField(usb_devObj, usb_devFID_filename, env->NewStringUTF(filename));/*like the compatibility Layer*/ + env->SetByteField(usb_devObj, usb_devFID_devnum, libusb_get_device_address(lib_dev)); + env->SetByteField(usb_devObj, usb_devFID_num_children, 0);/*Hardcoded to 0, like the compatibility Layer*/ + env->SetObjectField(usb_devObj, usb_devFID_children, NULL);/*Hardcoded to NULL, like the compatibility Layer*/ + env->SetLongField(usb_devObj, usb_devFID_devStructAddr,(jlong) lib_dev); + + /*device Descriptor*/ + usb_devDescObj = env->NewObject(usb_devDescClazz, usb_devDescMid); + if (!usb_devDescObj) { + setLibusbJavaError("shared library error: Error NewObject (usb_devDescObj)"); + return NULL; + } + env->SetByteField(usb_devDescObj, usb_devDescFID_bLength, dev_desc.bLength); + env->SetByteField(usb_devDescObj, usb_devDescFID_bDescriptorType, dev_desc.bDescriptorType); + env->SetShortField(usb_devDescObj, usb_devDescFID_bcdUSB, dev_desc.bcdUSB); + env->SetByteField(usb_devDescObj, usb_devDescFID_bDeviceClass, dev_desc.bDeviceClass); + env->SetByteField(usb_devDescObj, usb_devDescFID_bDeviceSubClass, dev_desc.bDeviceSubClass); + env->SetByteField(usb_devDescObj, usb_devDescFID_bDeviceProtocol, dev_desc.bDeviceProtocol); + env->SetByteField(usb_devDescObj, usb_devDescFID_bMaxPacketSize0, dev_desc.bMaxPacketSize0); + env->SetShortField(usb_devDescObj, usb_devDescFID_idVendor, dev_desc.idVendor); + env->SetShortField(usb_devDescObj, usb_devDescFID_idProduct, dev_desc.idProduct); + env->SetShortField(usb_devDescObj, usb_devDescFID_bcdDevice, dev_desc.bcdDevice); + env->SetByteField(usb_devDescObj, usb_devDescFID_iManufacturer, dev_desc.iManufacturer); + env->SetByteField(usb_devDescObj, usb_devDescFID_iProduct, dev_desc.iProduct); + env->SetByteField(usb_devDescObj, usb_devDescFID_iSerialNumber, dev_desc.iSerialNumber); + env->SetByteField(usb_devDescObj, usb_devDescFID_bNumConfigurations, dev_desc.bNumConfigurations); + env->SetObjectField(usb_devDescObj, usb_devFID_descriptor, usb_devDescObj); + + /*configuration descriptor*/ + /*Loop through all of the configurations*/ + usb_confDescObjArray = (jobjectArray) env->NewObjectArray( + dev_desc.bNumConfigurations, usb_confDescClazz, NULL); + if (!usb_confDescObjArray) { + setLibusbJavaError("shared library error: Error NewOjectArray"); + return NULL; + } + for (c = 0; c < dev_desc.bNumConfigurations; c++) { +#ifdef DEBUGON + printf("\t\tlibusb_get_device: configuration %u \n", c); +#endif + res = libusb_get_config_descriptor(lib_dev, c, &conf_desc); + if (res) { + setLibusbJavaError("shared library error: read conf_desc failed"); + return usb_devObj; + } + + usb_confDescObj = env->NewObject(usb_confDescClazz, usb_confDescMid); + if (!usb_confDescObj) { + setLibusbJavaError("shared library error: Error NewObject (usb_confDescObj)"); + return NULL; + } + env->SetObjectArrayElement(usb_confDescObjArray, c, usb_confDescObj);/*add it to the Array*/ + /*fill the fields*/ + env->SetByteField(usb_confDescObj, usb_confDescFID_bLength, conf_desc->bLength); + env->SetByteField(usb_confDescObj, usb_confDescFID_bDescriptorType, conf_desc->bDescriptorType); + env->SetShortField(usb_confDescObj, usb_confDescFID_wTotalLength, conf_desc->wTotalLength); + env->SetByteField(usb_confDescObj, usb_confDescFID_bNumInterfaces, conf_desc->bNumInterfaces); + env->SetByteField(usb_confDescObj, usb_confDescFID_bConfigurationValue, conf_desc->bConfigurationValue); + env->SetByteField(usb_confDescObj, usb_confDescFID_iConfiguration, conf_desc->iConfiguration); + env->SetByteField(usb_confDescObj, usb_confDescFID_bmAttributes, conf_desc->bmAttributes); + env->SetByteField(usb_confDescObj, usb_confDescFID_MaxPower, conf_desc->MaxPower); + env->SetIntField(usb_confDescObj, usb_confDescFID_extralen, conf_desc->extra_length); + if (conf_desc->extra) { + jbyteArray jbExtraDesc = env->NewByteArray(conf_desc->extra_length); + env->SetByteArrayRegion(jbExtraDesc, 0, conf_desc->extra_length, (jbyte *) conf_desc->extra); + env->SetObjectField(usb_confDescObj, usb_confDescFID_extra, jbExtraDesc); + } else { + env->SetObjectField(usb_confDescObj, usb_confDescFID_extra, NULL); + } + /*interface*/ + usb_intObjArray = (jobjectArray) env->NewObjectArray(conf_desc->bNumInterfaces, usb_intClazz, NULL); + if (!usb_intObjArray) { + setLibusbJavaError("shared library error: Error NewObjectArray (usb_intObjArray)"); + return NULL; + } + for (h = 0; h < conf_desc->bNumInterfaces; h++) { +#ifdef DEBUGON + printf("\t\t\tlibusb_get_device: interface %u \n", h); +#endif + + if (conf_desc->interface == NULL) { + // this shouldn't happen + printf("(*conf_desc)->usb_interface == NULL"); + return usb_devObj; + } + usb_intObj = env->NewObject(usb_intClazz, usb_intMid); + if (!usb_intObj) { + setLibusbJavaError("shared library error: Error NewObject (usb_intObj)"); + return NULL; + } + env->SetObjectArrayElement(usb_intObjArray, h, usb_intObj); + env->SetIntField(usb_intObj, usb_intFID_num_altsetting, conf_desc->interface[h].num_altsetting); + // interface descriptor + usb_intDescObjArray = (jobjectArray) env->NewObjectArray(conf_desc->interface[h].num_altsetting, usb_intDescClazz, NULL); + if (!usb_intDescObjArray) { + setLibusbJavaError("shared library error: Error NewObjectArray (usb_intDescObjArray)"); + return NULL; + } + for (a = 0; a < conf_desc->interface[h].num_altsetting; a++) { +#ifdef DEBUGON + printf("\t\t\t\tlibusb_get_device: interface descriptor %u \n", a); +#endif + + if (conf_desc->interface[h].altsetting == NULL) { + // this shouldn't happen + printf("LibusbJava: libusb_get_device_list: altsetting == NULL\n"); + return usb_devObj; + } + usb_intDescObj = env->NewObject(usb_intDescClazz, usb_intDescMid); + if (!usb_intDescObj) { + setLibusbJavaError("shared library error: Error NewObject (usb_intDescObj)"); + return NULL; + } + env->SetObjectArrayElement(usb_intDescObjArray, a, usb_intDescObj); + /*fill fields*/ + env->SetByteField(usb_intDescObj, usb_intDescFID_bLength, conf_desc->interface[h].altsetting[a].bLength); + env->SetByteField(usb_intDescObj, usb_intDescFID_bDescriptorType, conf_desc->interface[h].altsetting[a].bDescriptorType); + env->SetByteField(usb_intDescObj, usb_intDescFID_bInterfaceNumber, conf_desc->interface[h].altsetting[a].bInterfaceNumber); + env->SetByteField(usb_intDescObj, usb_intDescFID_bAlternateSetting, conf_desc->interface[h].altsetting[a].bAlternateSetting); + env->SetByteField(usb_intDescObj, usb_intDescFID_bNumEndpoints, conf_desc->interface[h].altsetting[a].bNumEndpoints); + env->SetByteField(usb_intDescObj, usb_intDescFID_bInterfaceClass, conf_desc->interface[h].altsetting[a].bInterfaceClass); + env->SetByteField(usb_intDescObj, usb_intDescFID_bInterfaceSubClass, conf_desc->interface[h].altsetting[a].bInterfaceSubClass); + env->SetByteField(usb_intDescObj, usb_intDescFID_bInterfaceProtocol, conf_desc->interface[h].altsetting[a].bInterfaceProtocol); + env->SetByteField(usb_intDescObj, usb_intDescFID_iInterface, conf_desc->interface[h].altsetting[a].iInterface); + env->SetIntField(usb_intDescObj, usb_intDescFID_extralen, conf_desc->interface[h].altsetting[a].extra_length); + if (conf_desc->interface[h].altsetting[a].extra) { + jbyteArray jbExtraDesc = env->NewByteArray(conf_desc->interface[h].altsetting[a].extra_length); + env->SetByteArrayRegion(jbExtraDesc, 0, conf_desc->interface[h].altsetting[a].extra_length, (jbyte *) conf_desc->interface[h].altsetting[a].extra); + env->SetObjectField(usb_intDescObj, usb_intDescFID_extra, jbExtraDesc); + } else { + env->SetObjectField(usb_intDescObj, usb_intDescFID_extra, NULL); + } + /*endpoint descriptor*/ + usb_epDescObjArray = (jobjectArray) env->NewObjectArray(conf_desc->interface[h].altsetting[a].bNumEndpoints, usb_epDescClazz, NULL); + if (!usb_epDescObjArray) { + setLibusbJavaError("shared library error: Error NewObjectArray (usb_epDescObjArray)"); + return NULL; + } + for (e = 0; e < conf_desc->interface[h].altsetting[a].bNumEndpoints; e++) { +#ifdef DEBUGON + printf("\t\t\t\t\tLibusb_get_device: endpoint descriptor %u \n", e); +#endif + + if (conf_desc->interface[h].altsetting[a].endpoint == NULL) { + printf("LibusbJava: usb_get_busses: endpoint == NULL\n"); + return usb_devObj; + } + usb_epDescObj = env->NewObject(usb_epDescClazz, usb_epDescMid); + if (!usb_epDescObj) { + setLibusbJavaError("shared library error: Error NewObject (usb_epDescObj)"); + return NULL; + } + env->SetObjectArrayElement(usb_epDescObjArray, e, usb_epDescObj); + env->SetByteField(usb_epDescObj, usb_epDescFID_bLength, conf_desc->interface[h].altsetting[a].endpoint[e].bLength); + env->SetByteField(usb_epDescObj, usb_epDescFID_bDescriptorType, conf_desc->interface[h].altsetting[a].endpoint[e].bDescriptorType); + env->SetByteField(usb_epDescObj, usb_epDescFID_bEndpointAddress, conf_desc->interface[h].altsetting[a].endpoint[e].bEndpointAddress); + env->SetByteField(usb_epDescObj, usb_epDescFID_bmAttributes, conf_desc->interface[h].altsetting[a].endpoint[e].bmAttributes); + env->SetShortField(usb_epDescObj, usb_epDescFID_wMaxPacketSize, conf_desc->interface[h].altsetting[a].endpoint[e].wMaxPacketSize); + env->SetByteField(usb_epDescObj, usb_epDescFID_bInterval, conf_desc->interface[h].altsetting[a].endpoint[e].bInterval); + env->SetByteField(usb_epDescObj, usb_epDescFID_bRefresh, conf_desc->interface[h].altsetting[a].endpoint[e].bRefresh); + env->SetByteField(usb_epDescObj, usb_epDescFID_bSynchAddress, conf_desc->interface[h].altsetting[a].endpoint[e].bSynchAddress); + env->SetIntField(usb_epDescObj, usb_epDescFID_extralen, conf_desc->interface[h].altsetting[a].endpoint[e].extra_length); + if (conf_desc->interface[h].altsetting[a].endpoint[e].extra) { + jbyteArray jbExtraDesc = env->NewByteArray(conf_desc->interface[h].altsetting[a].endpoint[e].extra_length); + env->SetByteArrayRegion(jbExtraDesc, 0, conf_desc->interface[h].altsetting[a].endpoint[e].extra_length, (jbyte *) conf_desc->interface[h].altsetting[a].endpoint[e].extra); + env->SetObjectField(usb_epDescObj, usb_epDescFID_extra, jbExtraDesc); + } else { + env->SetObjectField(usb_epDescObj, usb_epDescFID_extra, NULL); + } + } + env->SetObjectField(usb_intDescObj, usb_intDescFID_endpoint, usb_epDescObjArray); + } + env->SetObjectField(usb_intObj, usb_intFID_altsetting, usb_intDescObjArray); + } + env->SetObjectField(usb_confDescObj, usb_confDescFID_interface_, usb_intObjArray); + libusb_free_config_descriptor(conf_desc); + } + env->SetObjectField(usb_devObj, usb_devFID_config, usb_confDescObjArray); + +#ifdef DEBUGON + printf("libusb_get_device: done\n"); +#endif + return usb_devObj; +} +/******************************************************************************************** + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_get_configuration + * Signature: (J)B + ********************************************************************************************/ +JNIEXPORT jbyte JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1get_1configuration(JNIEnv *env, jclass obj, jlong handle) { + int config; + clearLibusbJavaError(); + if (libusb_get_configuration((libusb_device_handle*) (unsigned long) handle, &config)) { + setLibusbJavaError("shared library error: get_configuration failed"); + return -1; + } + return config; +} + +/******************************************************************************************** + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_set_configuration + * Signature: (JI)I + ********************************************************************************************/ +JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1set_1configuration(JNIEnv *env, jclass obj, jlong handle, jint config) { + clearLibusbJavaError(); + return libusb_set_configuration((libusb_device_handle*) (unsigned long) handle, config); +} + +/******************************************************************************************** + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_claim_interface + * Signature: (JI)I + ********************************************************************************************/ +JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1claim_1interface(JNIEnv *env, jclass obj, jlong handle, jint iNumber) { + clearLibusbJavaError(); + return libusb_claim_interface((libusb_device_handle*) (unsigned long) handle, iNumber); +} + +/******************************************************************************************** + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_release_interface + * Signature: (JI)I + ********************************************************************************************/ +JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1release_1interface(JNIEnv *env, jclass obj, jlong handle, jint iNumber) { + clearLibusbJavaError(); + return libusb_release_interface((libusb_device_handle*) (unsigned long) handle, iNumber); +} + +/******************************************************************************************** + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_set_interface_alt_setting + * Signature: (JII)I + ********************************************************************************************/ +JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1set_1interface_1alt_1setting(JNIEnv *env, jclass obj, jlong handle, jint iNumber, jint altSet) { + clearLibusbJavaError(); + return libusb_set_interface_alt_setting((libusb_device_handle*) (unsigned long) handle, iNumber, altSet); +} + +/******************************************************************************************** + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_clear_halt + * Signature: (JS)I + ********************************************************************************************/ +JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1clear_1halt(JNIEnv *env, jclass obj, jlong handle, jshort ep) { + clearLibusbJavaError(); + return libusb_clear_halt((libusb_device_handle*) (unsigned long) handle, ep); +} + +/******************************************************************************************** + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_reset_device + * Signature: (J)I + ********************************************************************************************/ +JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1reset_1device(JNIEnv *env, jclass obj, jlong handle) { + clearLibusbJavaError(); + return libusb_reset_device((libusb_device_handle*) (unsigned long) handle); +} + +/******************************************************************************************** + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_kernel_driver_active + * Signature: (JI)I + ********************************************************************************************/ +JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1kernel_1driver_1active(JNIEnv *env, jclass obj, jlong handle, jint iNumber) { + clearLibusbJavaError(); + return libusb_kernel_driver_active((libusb_device_handle*) (unsigned long) handle, iNumber); +} + +/******************************************************************************************** + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_detach_kernel_driver + * Signature: (JI)I + ********************************************************************************************/ +JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1detach_1kernel_1driver(JNIEnv *env, jclass obj, jlong handle, jint iNumber) { + clearLibusbJavaError(); + return libusb_detach_kernel_driver((libusb_device_handle*) (unsigned long) handle, iNumber); +} + +/******************************************************************************************** + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_attach_kernel_driver + * Signature: (JI)I + ********************************************************************************************/ +JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1attach_1kernel_1driver(JNIEnv *env, jclass obj, jlong handle, jint iNumber) { + clearLibusbJavaError(); + return libusb_attach_kernel_driver((libusb_device_handle*) (unsigned long) handle, iNumber); +} + +/******************************************************************************************** + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_get_active_config_descriptor + * Signature: (Lch/ntb/inf/libusbJava/Usb_Device;)Lch/ntb/inf/libusbJava/Usb_Config_Descriptor; + ********************************************************************************************/ +JNIEXPORT jobject JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1get_1active_1config_1descriptor(JNIEnv *env, jclass obj, jobject dev) { + uint8_t a, e; + clearLibusbJavaError(); + libusb_config_descriptor *conf_desc; + jobject usb_confDescObj, usb_intObj, usb_intDescObj, usb_epDescObj; + jobjectArray usb_intObjArray, usb_intDescObjArray, usb_epDescObjArray; + + libusb_device *lib_dev = (libusb_device*) (unsigned long) env->GetLongField(dev, usb_devFID_devStructAddr); + if (libusb_get_active_config_descriptor(lib_dev, &conf_desc)) { + setLibusbJavaError("shared library error: get_configuration failed"); + return NULL; + } + usb_confDescObj = env->NewObject(usb_confDescClazz, usb_confDescMid); + if (!usb_confDescObj) { + setLibusbJavaError("shared library error: Error NewObject (usb_confDescObj)"); + return NULL; + } + /*fill the fields*/ + env->SetByteField(usb_confDescObj, usb_confDescFID_bLength, conf_desc->bLength); + env->SetByteField(usb_confDescObj, usb_confDescFID_bDescriptorType, conf_desc->bDescriptorType); + env->SetShortField(usb_confDescObj, usb_confDescFID_wTotalLength, conf_desc->wTotalLength); + env->SetByteField(usb_confDescObj, usb_confDescFID_bNumInterfaces, conf_desc->bNumInterfaces); + env->SetByteField(usb_confDescObj, usb_confDescFID_bConfigurationValue, conf_desc->bConfigurationValue); + env->SetByteField(usb_confDescObj, usb_confDescFID_iConfiguration, conf_desc->iConfiguration); + env->SetByteField(usb_confDescObj, usb_confDescFID_bmAttributes, conf_desc->bmAttributes); + env->SetByteField(usb_confDescObj, usb_confDescFID_MaxPower, conf_desc->MaxPower); + env->SetIntField(usb_confDescObj, usb_confDescFID_extralen, conf_desc->extra_length); + if (conf_desc->extra) { + jbyteArray jbExtraDesc = env->NewByteArray(conf_desc->extra_length); + env->SetByteArrayRegion(jbExtraDesc, 0, conf_desc->extra_length, (jbyte *) conf_desc->extra); + env->SetObjectField(usb_confDescObj, usb_confDescFID_extra, jbExtraDesc); + } else { + env->SetObjectField(usb_confDescObj, usb_confDescFID_extra, NULL); + } + /*interface*/ + usb_intObjArray = (jobjectArray) env->NewObjectArray(conf_desc->bNumInterfaces, usb_intClazz, NULL); + if (!usb_intObjArray) { + setLibusbJavaError("shared library error: Error NewObjectArray (usb_intObjArray)"); + return NULL; + } + for (int i = 0; i < conf_desc->bNumInterfaces; i++) { +#ifdef DEBUGON + printf("\t\t\tlibusb_get_activ_config_descriptor: interface %u \n", i); +#endif + if (conf_desc->interface == NULL) { + // this shouldn't happen + printf("conf_des->interface == NULL"); + return usb_confDescObj; + } + usb_intObj = env->NewObject(usb_intClazz, usb_intMid); + if (!usb_intObj) { + setLibusbJavaError("shared library error: Error NewObject (usb_intObj)"); + return NULL; + } + env->SetObjectArrayElement(usb_intObjArray, i, usb_intObj); + env->SetIntField(usb_intObj, usb_intFID_num_altsetting, conf_desc->interface[i].num_altsetting); + // interface descriptor + usb_intDescObjArray = (jobjectArray) env->NewObjectArray(conf_desc->interface[i].num_altsetting, usb_intDescClazz, NULL); + if (!usb_intDescObjArray) { + setLibusbJavaError("shared library error: Error NewObjectArray (usb_intDescObjArray)"); + return NULL; + } + for (a = 0; a < conf_desc->interface[i].num_altsetting; a++) { +#ifdef DEBUGON + printf("\t\t\t\tlibusb_get__activ_config_descriptor: interface descriptor %u \n", a); +#endif + + if (conf_desc->interface[i].altsetting == NULL) { + // this shouldn't happen + printf("LibusbJava: libusb_get__activ_config_descriptor: altsetting == NULL\n"); + return usb_confDescObj; + } + usb_intDescObj = env->NewObject(usb_intDescClazz, usb_intDescMid); + if (!usb_intDescObj) { + setLibusbJavaError("shared library error: Error NewObject (usb_intDescObj)"); + return NULL; + } + env->SetObjectArrayElement(usb_intDescObjArray, a, usb_intDescObj); + /*fill fields*/ + env->SetByteField(usb_intDescObj, usb_intDescFID_bLength, conf_desc->interface[i].altsetting[a].bLength); + env->SetByteField(usb_intDescObj, usb_intDescFID_bDescriptorType, conf_desc->interface[i].altsetting[a].bDescriptorType); + env->SetByteField(usb_intDescObj, usb_intDescFID_bInterfaceNumber, conf_desc->interface[i].altsetting[a].bInterfaceNumber); + env->SetByteField(usb_intDescObj, usb_intDescFID_bAlternateSetting, conf_desc->interface[i].altsetting[a].bAlternateSetting); + env->SetByteField(usb_intDescObj, usb_intDescFID_bNumEndpoints, conf_desc->interface[i].altsetting[a].bNumEndpoints); + env->SetByteField(usb_intDescObj, usb_intDescFID_bInterfaceClass, conf_desc->interface[i].altsetting[a].bInterfaceClass); + env->SetByteField(usb_intDescObj, usb_intDescFID_bInterfaceSubClass, conf_desc->interface[i].altsetting[a].bInterfaceSubClass); + env->SetByteField(usb_intDescObj, usb_intDescFID_bInterfaceProtocol, conf_desc->interface[i].altsetting[a].bInterfaceProtocol); + env->SetByteField(usb_intDescObj, usb_intDescFID_iInterface, conf_desc->interface[i].altsetting[a].iInterface); + env->SetIntField(usb_intDescObj, usb_intDescFID_extralen, conf_desc->interface[i].altsetting[a].extra_length); + if (conf_desc->interface[i].altsetting[a].extra) { + jbyteArray jbExtraDesc = env->NewByteArray(conf_desc->interface[i].altsetting[a].extra_length); + env->SetByteArrayRegion(jbExtraDesc, 0, conf_desc->interface[i].altsetting[a].extra_length, (jbyte *) conf_desc->interface[i].altsetting[a].extra); + env->SetObjectField(usb_intDescObj, usb_intDescFID_extra, jbExtraDesc); + } else { + env->SetObjectField(usb_intDescObj, usb_intDescFID_extra, NULL); + } + /*endpoint descriptor*/ + usb_epDescObjArray = (jobjectArray) env->NewObjectArray(conf_desc->interface[i].altsetting[a].bNumEndpoints, usb_epDescClazz, NULL); + if (!usb_epDescObjArray) { + setLibusbJavaError("shared library error: Error NewObjectArray (usb_epDescObjArray)"); + return NULL; + } + for (e = 0; e < conf_desc->interface[i].altsetting[a].bNumEndpoints; e++) { +#ifdef DEBUGON + printf("\t\t\t\t\tLibusb_get__activ_config_descriptor: endpoint descriptor %u \n", e); +#endif + if (conf_desc->interface[i].altsetting[a].endpoint == NULL) { + printf("LibusbJava: usb_get__activ_config_descriptor: endpoint == NULL\n"); + return usb_confDescObj; + } + usb_epDescObj = env->NewObject(usb_epDescClazz, usb_epDescMid); + if (!usb_epDescObj) { + setLibusbJavaError("shared library error: Error NewObject (usb_epDescObj)"); + return NULL; + } + env->SetObjectArrayElement(usb_epDescObjArray, e, usb_epDescObj); + env->SetByteField(usb_epDescObj, usb_epDescFID_bLength, conf_desc->interface[i].altsetting[a].endpoint[e].bLength); + env->SetByteField(usb_epDescObj, usb_epDescFID_bDescriptorType, conf_desc->interface[i].altsetting[a].endpoint[e].bDescriptorType); + env->SetByteField(usb_epDescObj, usb_epDescFID_bEndpointAddress, conf_desc->interface[i].altsetting[a].endpoint[e].bEndpointAddress); + env->SetByteField(usb_epDescObj, usb_epDescFID_bmAttributes, conf_desc->interface[i].altsetting[a].endpoint[e].bmAttributes); + env->SetShortField(usb_epDescObj, usb_epDescFID_wMaxPacketSize, conf_desc->interface[i].altsetting[a].endpoint[e].wMaxPacketSize); + env->SetByteField(usb_epDescObj, usb_epDescFID_bInterval, conf_desc->interface[i].altsetting[a].endpoint[e].bInterval); + env->SetByteField(usb_epDescObj, usb_epDescFID_bRefresh, conf_desc->interface[i].altsetting[a].endpoint[e].bRefresh); + env->SetByteField(usb_epDescObj, usb_epDescFID_bSynchAddress, conf_desc->interface[i].altsetting[a].endpoint[e].bSynchAddress); + env->SetIntField(usb_epDescObj, usb_epDescFID_extralen, conf_desc->interface[i].altsetting[a].endpoint[e].extra_length); + if (conf_desc->interface[i].altsetting[a].endpoint[e].extra) { + jbyteArray jbExtraDesc = env->NewByteArray(conf_desc->interface[i].altsetting[a].endpoint[e].extra_length); + env->SetByteArrayRegion(jbExtraDesc, 0, conf_desc->interface[i].altsetting[a].endpoint[e].extra_length, (jbyte *) conf_desc->interface[i].altsetting[a].endpoint[e].extra); + env->SetObjectField(usb_epDescObj, usb_epDescFID_extra, jbExtraDesc); + } else { + env->SetObjectField(usb_epDescObj, usb_epDescFID_extra, NULL); + } + } + env->SetObjectField(usb_intDescObj, usb_intDescFID_endpoint, usb_epDescObjArray); + } + env->SetObjectField(usb_intObj, usb_intFID_altsetting, usb_intDescObjArray); + } + env->SetObjectField(usb_confDescObj, usb_confDescFID_interface_, usb_intObjArray); + libusb_free_config_descriptor(conf_desc); + + return usb_confDescObj; +} + +/******************************************************************************************** + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_get_string_descriptor_ascii + * Signature: (JSI)Ljava/lang/String; + ********************************************************************************************/ +JNIEXPORT jstring JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1get_1string_1descriptor_1ascii( JNIEnv *env, jclass obj, jlong handle, jshort desc_index, jint length) { + jstring string; + int res = 0; + clearLibusbJavaError(); + unsigned char data[(int)length]; + res = libusb_get_string_descriptor_ascii((libusb_device_handle*) (unsigned long) handle, desc_index, data, (int)length); + if (res > 0) { + string = env->NewStringUTF((const char*)data); + } else { + setLibusbJavaError("get_string_descriptor_ascii: retrieve String failed"); + string = NULL; + } + return string; +} +/******************************************************************************************** + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_get_descriptor + * Signature: (JISI)[B + ********************************************************************************************/ + +JNIEXPORT jbyteArray JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1get_1descriptor( + JNIEnv *env, jclass obj, jlong handle, jint desc_type, + jshort desc_index, jint size) { + + clearLibusbJavaError(); + int res; + unsigned char data[255]; + + res = libusb_get_descriptor((libusb_device_handle*) (unsigned long) handle, desc_type, desc_index, data, size); + if (res < 0) { + setLibusbJavaError("libusb_get_descriptor: retrieve data failed"); + return NULL; + } + + jbyte *byteArrayElements; + jbyteArray bArray = env->NewByteArray(res); + + byteArrayElements = env->GetByteArrayElements(bArray, NULL); + memcpy(byteArrayElements, data, res); + env->ReleaseByteArrayElements(bArray, byteArrayElements, 0); + + return bArray; + +} +/******************************************************************************************** + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_get_string_descriptor + * Signature: (JSII)Ljava/lang/String; + ********************************************************************************************/ +JNIEXPORT jstring +JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1get_1string_1descriptor(JNIEnv *env, jclass obj, jlong handle, jshort desc_index, jint langid, jint size) { + clearLibusbJavaError(); + int res; + jstring string; + unsigned char data[(int)size]; + + res = libusb_get_string_descriptor((libusb_device_handle*) (unsigned long) handle, desc_index, langid, data, size); + res = 0; + if (res > 0) { + string = env->NewStringUTF((const char*) data); + } else { + setLibusbJavaError("get_string_descriptor: retrieve String failed"); + string = NULL; + } + return string; + +} +/******************************************************************************************** + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_alloc_transfer + * Signature: (I)J + ********************************************************************************************/ +JNIEXPORT jlong JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1alloc_1transfer( JNIEnv *env, jclass obj, jint iso_packets) { + clearLibusbJavaError(); + return (jlong) libusb_alloc_transfer(iso_packets); +} + +/******************************************************************************************** + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_free_transfer + * Signature: (J)V + ********************************************************************************************/ +JNIEXPORT void JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1free_1transfer( JNIEnv *env, jclass obj, jlong transfernumber) { + clearLibusbJavaError(); + libusb_free_transfer((libusb_transfer*) (unsigned long) transfernumber); +} + +/******************************************************************************************** + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_submit_transfer + * Signature: (J)I + ********************************************************************************************/ +JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1submit_1transfer(JNIEnv *env, jclass obj, jlong transfernumber) { + clearLibusbJavaError(); + return libusb_submit_transfer((libusb_transfer*) (unsigned long) transfernumber); +} + +/******************************************************************************************** + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_cancel_transfer + * Signature: (J)I + ********************************************************************************************/ +JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1cancel_1transfer(JNIEnv *env, jclass obj, jlong transfernumber) { + clearLibusbJavaError(); + return libusb_cancel_transfer((libusb_transfer*) (unsigned long) transfernumber); +} +/******************************************************************************************** + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_control_transfer_get_data + * Signature: (J)[B + ********************************************************************************************/ +JNIEXPORT jbyteArray JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1control_1transfer_1get_1data(JNIEnv *env, jclass obj, jlong transfernumber) { + clearLibusbJavaError(); + unsigned char *data; + libusb_transfer* trans = (libusb_transfer*) (unsigned long) transfernumber; + jbyte *byteArrayElements; + jbyteArray bArray = env->NewByteArray(trans->actual_length - 8); + + data = libusb_control_transfer_get_data(trans); + + byteArrayElements = env->GetByteArrayElements(bArray, NULL); + memcpy(byteArrayElements, data, trans->actual_length - 8); + env->ReleaseByteArrayElements(bArray, byteArrayElements, 0); + + return bArray; +} + +/********************************************************************************************* + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_control_transfer_get_setup + * Signature: (J)[B + ********************************************************************************************/ +JNIEXPORT jbyteArray JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1control_1transfer_1get_1setup(JNIEnv *env, jclass obj, jlong transfernumber) { + clearLibusbJavaError(); + unsigned char *data; + libusb_transfer* trans = (libusb_transfer*) (unsigned long) transfernumber; + jbyte *byteArrayElements; + jbyteArray bArray = env->NewByteArray(8); + + data = (unsigned char*) libusb_control_transfer_get_setup(trans); + + byteArrayElements = env->GetByteArrayElements(bArray, NULL); + memcpy(byteArrayElements, data, 8); + env->ReleaseByteArrayElements(bArray, byteArrayElements, 0); + + return bArray; +} +/******************************************************************************************** + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_fill_control_setup + * Signature: (IIIII)[B + ********************************************************************************************/ +JNIEXPORT jbyteArray JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1fill_1control_1setup(JNIEnv *env, jclass obj, jint bmRequestType, jint bRequest, jint wValue, jint wIndex, jint wLength) { + clearLibusbJavaError(); + unsigned char setup[8]; + jbyte *byteArrayElements; + jbyteArray bArray = env->NewByteArray(8); + + libusb_fill_control_setup(setup, bmRequestType, bRequest, wValue, wIndex, wLength); + + byteArrayElements = env->GetByteArrayElements(bArray, NULL); + memcpy(byteArrayElements, setup, 8); + env->ReleaseByteArrayElements(bArray, byteArrayElements, 0); + + return bArray; + +} + +/******************************************************************************************** + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_fill_control_transfer + * Signature: (JJ[BI)V + ********************************************************************************************/ +JNIEXPORT void JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1fill_1control_1transfer(JNIEnv *env, jclass obj, jlong transfernumber, jlong handle, jbyteArray buffer, jint timeout) { + clearLibusbJavaError(); + jbyte *byteArrayElements = env->GetByteArrayElements(buffer, NULL); + libusb_fill_control_transfer((libusb_transfer*) (unsigned long) transfernumber,(libusb_device_handle*) (unsigned long) handle,(unsigned char*) byteArrayElements, transfer_callback, env,(unsigned int) timeout); + env->ReleaseByteArrayElements(buffer, byteArrayElements, 0); +} + +/******************************************************************************************** + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_fill_bulk_transfer + * Signature: (JJB[BII)V + ********************************************************************************************/ +JNIEXPORT void JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1fill_1bulk_1transfer(JNIEnv *env, jclass obj, jlong transfernumber, jlong handle, jbyte endpoint, jbyteArray buffer, jint length, jint timeout) { + clearLibusbJavaError(); + jbyte *byteArrayElements = env->GetByteArrayElements(buffer, NULL); + libusb_fill_bulk_transfer((libusb_transfer*) (unsigned long) transfernumber,(libusb_device_handle*) (unsigned long) handle, endpoint,(unsigned char*) byteArrayElements, length, transfer_callback, env,(unsigned int) timeout); + env->ReleaseByteArrayElements(buffer, byteArrayElements, 0); +} + +/******************************************************************************************** + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_fill_interrupt_transfer + * Signature: (JJB[BII)V + ********************************************************************************************/ +JNIEXPORT void JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1fill_1interrupt_1transfer(JNIEnv *env, jclass obj, jlong transfernumber, jlong handle,jbyte endpoint, jbyteArray buffer, jint length, jint timeout) { + clearLibusbJavaError(); + jbyte *byteArrayElements = env->GetByteArrayElements(buffer, NULL); + libusb_fill_interrupt_transfer((libusb_transfer*) (unsigned long) transfernumber,(libusb_device_handle*) (unsigned long) handle, endpoint,(unsigned char*) byteArrayElements, length, transfer_callback, env, timeout); + env->ReleaseByteArrayElements(buffer, byteArrayElements, 0); +} + +/******************************************************************************************** + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_fill_iso_transfer + * Signature: (JJB[BIII)V + ********************************************************************************************/ +JNIEXPORT void JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1fill_1iso_1transfer(JNIEnv *env, jclass obj, jlong transfernumber, jlong handle, jbyte endpoint, jbyteArray buffer, jint length, jint num_iso_packets, jint timeout) { + clearLibusbJavaError(); + jbyte *byteArrayElements = env->GetByteArrayElements(buffer, NULL); + libusb_fill_iso_transfer((libusb_transfer*) (unsigned long) transfernumber, (libusb_device_handle*) (unsigned long) handle, endpoint, (unsigned char*) byteArrayElements, length, num_iso_packets, transfer_callback, env, timeout); + env->ReleaseByteArrayElements(buffer, byteArrayElements, 0); +} + +/******************************************************************************************** + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_set_iso_packet_lengths + * Signature: (JI)V + ********************************************************************************************/ +JNIEXPORT void JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1set_1iso_1packet_1lengths(JNIEnv *env, jclass obj, jlong transfernumber, jint length) { + clearLibusbJavaError(); + libusb_set_iso_packet_lengths((libusb_transfer*) (unsigned long) transfernumber, length); +} + +/******************************************************************************************** + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_get_iso_packet_buffer + * Signature: (JI)[B + ********************************************************************************************/ + +JNIEXPORT jbyteArray JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1get_1iso_1packet_1buffer(JNIEnv *env, jclass obj, jlong transfernumber, jint packet) { + clearLibusbJavaError(); + int size; + unsigned char *data; + libusb_transfer* transfer = (libusb_transfer*) (unsigned long) transfernumber; + + if (packet < transfer->num_iso_packets) { + size = transfer->iso_packet_desc[packet].actual_length; + } + jbyteArray bArray = env->NewByteArray(size); + jbyte *byteArrayElements = env->GetByteArrayElements(bArray, NULL); + + data = libusb_get_iso_packet_buffer((libusb_transfer*) (unsigned long) transfernumber, packet); + if (data == NULL) { + return NULL; + } + memcpy(byteArrayElements, data, size); + env->ReleaseByteArrayElements(bArray, byteArrayElements, 0); + + return bArray; +} +/******************************************************************************************** + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_get_iso_packet_buffer_simple + * Signature: (JI)[B + ********************************************************************************************/ +JNIEXPORT jbyteArray JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1get_1iso_1packet_1buffer_1simple(JNIEnv *env, jclass obj, jlong transfernumber, jint packet) { + clearLibusbJavaError(); + int size; + unsigned char *data; + libusb_transfer* transfer = (libusb_transfer*) (unsigned long) transfernumber; + + if (packet < transfer->num_iso_packets) { + size = transfer->iso_packet_desc[packet].actual_length; + } + jbyteArray bArray = env->NewByteArray(size); + jbyte *byteArrayElements = env->GetByteArrayElements(bArray, NULL); + + data = libusb_get_iso_packet_buffer_simple((libusb_transfer*) (unsigned long) transfernumber, packet); + if (data == NULL) { + return NULL; + } + memcpy(byteArrayElements, data, size); + env->ReleaseByteArrayElements(bArray, byteArrayElements, 0); + + return bArray; +} + +/******************************************************************************************** + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_try_lock_events + * Signature: (J)I + ********************************************************************************************/ +JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1try_1lock_1events(JNIEnv *env, jclass obj, jlong ctx) { + clearLibusbJavaError(); + return libusb_try_lock_events((libusb_context*) (unsigned long) ctx); +// return libusb_try_lock_events(NULL); +} + +/******************************************************************************************** + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_lock_events + * Signature: (J)V + ********************************************************************************************/ +JNIEXPORT void JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1lock_1events(JNIEnv *env, jclass obj, jlong ctx) { + libusb_lock_events((libusb_context*) (unsigned long) ctx); +// libusb_lock_events(NULL); +} + +/******************************************************************************************** + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_unlock_events + * Signature: (J)V + ********************************************************************************************/ +JNIEXPORT void JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1unlock_1events(JNIEnv *env, jclass obj, jlong ctx) { + clearLibusbJavaError(); + libusb_unlock_events((libusb_context*) (unsigned long) ctx); +} + +/******************************************************************************************** + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_event_handling_ok + * Signature: (J)I + ********************************************************************************************/ +JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1event_1handling_1ok(JNIEnv *env, jclass obj, jlong ctx) { + clearLibusbJavaError(); + return libusb_event_handling_ok((libusb_context*) (unsigned long) ctx); +} + +/******************************************************************************************** + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_event_handler_active + * Signature: (J)I + ********************************************************************************************/ +JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1event_1handler_1active(JNIEnv *env, jclass obj, jlong ctx) { + clearLibusbJavaError(); + return libusb_event_handler_active((libusb_context*) (unsigned long) ctx); +} + +/******************************************************************************************** + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_lock_event_waiters + * Signature: (J)V + ********************************************************************************************/ +JNIEXPORT void JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1lock_1event_1waiters(JNIEnv *env, jclass obj, jlong ctx) { + clearLibusbJavaError(); + libusb_lock_event_waiters((libusb_context*) (unsigned long) ctx); +} + +/******************************************************************************************** + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_unlock_event_waiters + * Signature: (J)V + ********************************************************************************************/ +JNIEXPORT void JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1unlock_1event_1waiters(JNIEnv *env, jclass obj, jlong ctx) { + clearLibusbJavaError(); + libusb_unlock_event_waiters((libusb_context*) (unsigned long) ctx); +} + +/******************************************************************************************** + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_wait_for_event + * Signature: (JJ)I + ********************************************************************************************/ +JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1wait_1for_1event(JNIEnv *env, jclass obj, jlong ctx, jlong timevalue) { + clearLibusbJavaError(); + if (timevalue) { + timeval tv; + tv.tv_sec = timevalue; + tv.tv_usec = 0; + return libusb_wait_for_event((libusb_context*) (unsigned long) ctx, &tv); + } + return libusb_wait_for_event((libusb_context*) (unsigned long) ctx, NULL); +} + +/******************************************************************************************** + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_handle_events_timeout + * Signature: (JJ)I + ********************************************************************************************/ +JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1handle_1events_1timeout(JNIEnv *env, jclass obj, jlong ctx, jlong timevalue) { + clearLibusbJavaError(); + if (timevalue) { + timeval tv; + tv.tv_sec = timevalue; + tv.tv_usec = 0; + return libusb_handle_events_timeout((libusb_context*) (unsigned long) ctx, &tv); + } + return libusb_handle_events_timeout((libusb_context*) (unsigned long) ctx, NULL); +} + +/******************************************************************************************** + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_handle_events + * Signature: (J)I + ********************************************************************************************/ +JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1handle_1events(JNIEnv *env, jclass obj, jlong ctx) { + clearLibusbJavaError(); + return libusb_handle_events((libusb_context*) (unsigned long) ctx); +} + +/******************************************************************************************** + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_handle_events_locked + * Signature: (JJ)I + ********************************************************************************************/ +JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1handle_1events_1locked(JNIEnv *env, jclass obj, jlong ctx, jlong timevalue) { + clearLibusbJavaError(); + if (timevalue) { + timeval tv; + tv.tv_sec = timevalue; + tv.tv_usec = 0; + return libusb_handle_events_locked((libusb_context*) (unsigned long) ctx, &tv); + } + return libusb_handle_events_locked((libusb_context*) (unsigned long) ctx, NULL); +} + +/******************************************************************************************** + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_pollfds_handle_timeouts + * Signature: (J)I + ********************************************************************************************/ +JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1pollfds_1handle_1timeouts(JNIEnv *env, jclass obj, jlong ctx) { + clearLibusbJavaError(); + return libusb_pollfds_handle_timeouts((libusb_context*) (unsigned long) ctx); +} + +/******************************************************************************************** + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_get_next_timeout + * Signature: (J)I + ********************************************************************************************/ +JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1get_1next_1timeout(JNIEnv *env, jclass obj, jlong ctx) { + clearLibusbJavaError(); + int res; + long time; + timeval* tv = (timeval*) malloc(sizeof(struct timeval)); + + res = libusb_get_next_timeout((libusb_context*) (unsigned long) ctx, tv); + + if (res > 0) { + time = tv->tv_sec; + free(tv); + return time; + } + free(tv); + if (res == 0) { + return -999; + } + return res; +} + +/******************************************************************************************** + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_set_pollfd_notifiers + * Signature: (JZ)V + ********************************************************************************************/ +JNIEXPORT void JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1set_1pollfd_1notifiers(JNIEnv *env, jclass obj, jlong ctx, jboolean remove) { + clearLibusbJavaError(); + if (remove) { + libusb_set_pollfd_notifiers((libusb_context*) (unsigned long) ctx, NULL, NULL, env); + return; + } + libusb_set_pollfd_notifiers((libusb_context*) (unsigned long) ctx, fd_added_callback, fd_removed_callback, env); +} + +/******************************************************************************************** + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_get_pollfds + * Signature: (J)[Lch/ntb/inf/libusbJava/Libusb_pollfd; + ********************************************************************************************/ +JNIEXPORT jobjectArray JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1get_1pollfds(JNIEnv *env, jclass obj, jlong ctx) { + clearLibusbJavaError(); + int count = 0; + jobjectArray pollfdArray; + jobject pollfdObj; + const libusb_pollfd **fdList; + + fdList = libusb_get_pollfds((libusb_context*) (unsigned long) ctx); + if (fdList == NULL) { + return NULL; + } + /*determine the length of the list*/ + while (fdList[count]) { + count++; + } + pollfdArray = (jobjectArray) env->NewObjectArray(count, usb_pollfd_clazz, NULL); + if (!pollfdArray) { + setLibusbJavaError("libusb_get_pollfds: error NewObjectArry (pollfdArray"); + return NULL; + } + + for (int i = 0; i < count; i++) { + pollfdObj = env->NewObject(usb_pollfd_clazz, usb_pollfd_Mid); + if (!pollfdObj) { + setLibusbJavaError("libusb_get_pollfds: Error NewObject (pollfdObj)"); + return NULL; + } + env->SetObjectArrayElement(pollfdArray, i, pollfdObj); + env->SetIntField(pollfdObj, usb_pollfdFID_fd, fdList[i]->fd); + env->SetShortField(pollfdObj, usb_pollfdFID_events, fdList[i]->events); + } + return pollfdArray; +} + +/******************************************************************************************** + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_control_transfer + * Signature: (JIIII[BII)I + ********************************************************************************************/ +JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1control_1transfer(JNIEnv *env, jclass obj, jlong handle, jint bmRequestType, jint bRequest, jint wValue, jint wIndex, jbyteArray buffer, jint wLength, jint timeout) { + clearLibusbJavaError(); + int res; + unsigned char* data; + data = (unsigned char*) env->GetByteArrayElements(buffer, NULL); + res = libusb_control_transfer((libusb_device_handle*) (unsigned long) handle, bmRequestType, bRequest, wValue, wIndex, data, wLength, timeout); + env->ReleaseByteArrayElements(buffer, (jbyte*) data, 0); + + return res; +} + +/******************************************************************************************** + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_bulk_transfer + * Signature: (JB[BII)I + ********************************************************************************************/ +JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1bulk_1transfer(JNIEnv *env, jclass obj, jlong handle, jbyte endpoint, jbyteArray buffer, jint length, jint timeout) { + clearLibusbJavaError(); + int res, actual_length; + unsigned char* data; + + data = (unsigned char*) env->GetByteArrayElements(buffer, NULL); + res = libusb_bulk_transfer((libusb_device_handle*) (unsigned long) handle, endpoint, data, length, &actual_length, timeout); + env->ReleaseByteArrayElements(buffer, (jbyte*) data, 0); + if (res) { + return res; + } + return actual_length; +} + +/******************************************************************************************** + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_interrupt_transfer + * Signature: (JB[BII)I + ********************************************************************************************/ +JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1interrupt_1transfer(JNIEnv *env, jclass obj, jlong handle, jbyte endpoint, jbyteArray buffer, jint length, jint timeout) { + clearLibusbJavaError(); + int res, actual_length; + unsigned char* data; + + data = (unsigned char*) env->GetByteArrayElements(buffer, NULL); + res = libusb_interrupt_transfer((libusb_device_handle*) (unsigned long) handle, endpoint, data, length, &actual_length, timeout); + env->ReleaseByteArrayElements(buffer, (jbyte*) data, 0); + if (res) { + return res; + } + return actual_length; +} + +/******************************************************************************************** + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_strerror + * Signature: ()Ljava/lang/String; + ********************************************************************************************/ +JNIEXPORT jstring JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1strerror(JNIEnv *env, jclass obj) { + char *str; + /* check for LibusbJava specific errors first*/ + if (libusbJavaError != NULL) { + str = libusbJavaError; + clearLibusbJavaError(); + } else { + str = "Libusb-1.0 Error"; + } + return env->NewStringUTF(str); +} + +/******************************************************************************************** + * Class: LibusbJava_1_0.cpp + * Method: transfer_callback + * + ********************************************************************************************/ +static void LIBUSB_CALL transfer_callback(struct libusb_transfer *transfer) { + + ((JNIEnv*) transfer->user_data)->CallVoidMethod(usb_cb_clazz, + usb_transfer_cb_Mid); +} + +/******************************************************************************************** + * Class: LibusbJava_1_0.cpp + * Method: fd_added_callback + * + ********************************************************************************************/ +static void LIBUSB_CALL fd_added_callback(int fd, short events, void *user_data) { + + ((JNIEnv*) user_data)->CallVoidMethod(usb_cb_clazz, usb_fd_added_cb_Mid, + (jint) fd); +} + +/******************************************************************************************** + * Class: LibusbJava_1_0.cpp + * Method: fd_removed_callback + * + ********************************************************************************************/ +static void LIBUSB_CALL fd_removed_callback(int fd, void *user_data) { + + ((JNIEnv*) user_data)->CallVoidMethod(usb_cb_clazz, usb_fd_removed_cb_Mid, + (jint) fd); +} diff --git a/LibusbJava/LibusbJava.h b/LibusbJava/LibusbJava.h index ae7a4b8..91ee071 100644 --- a/LibusbJava/LibusbJava.h +++ b/LibusbJava/LibusbJava.h @@ -1,204 +1,484 @@ /* DO NOT EDIT THIS FILE - it is machine generated */ #include -/* Header for class ch_ntb_inf_libusbJava_LibusbJava */ +/* Header for class ch_ntb_inf_libusbJava_LibusbJava1 */ -#ifndef _Included_ch_ntb_inf_libusbJava_LibusbJava -#define _Included_ch_ntb_inf_libusbJava_LibusbJava +#ifndef _Included_ch_ntb_inf_libusbJava_LibusbJava1 +#define _Included_ch_ntb_inf_libusbJava_LibusbJava1 #ifdef __cplusplus extern "C" { #endif /* - * Class: ch_ntb_inf_libusbJava_LibusbJava - * Method: usb_set_debug - * Signature: (I)V + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_set_debug + * Signature: (JI)V */ -JNIEXPORT void JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava_usb_1set_1debug - (JNIEnv *, jclass, jint); +JNIEXPORT void JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1set_1debug + (JNIEnv *, jclass, jlong, jint); /* - * Class: ch_ntb_inf_libusbJava_LibusbJava - * Method: usb_init - * Signature: ()V + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_init + * Signature: ()J */ -JNIEXPORT void JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava_usb_1init +JNIEXPORT jlong JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1init (JNIEnv *, jclass); /* - * Class: ch_ntb_inf_libusbJava_LibusbJava - * Method: usb_find_busses - * Signature: ()I + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_exit + * Signature: (J)V */ -JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava_usb_1find_1busses - (JNIEnv *, jclass); +JNIEXPORT void JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1exit + (JNIEnv *, jclass, jlong); /* - * Class: ch_ntb_inf_libusbJava_LibusbJava - * Method: usb_find_devices - * Signature: ()I + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_get_device_list + * Signature: (J)Lch/ntb/inf/libusbJava/Usb_Device; */ -JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava_usb_1find_1devices - (JNIEnv *, jclass); +JNIEXPORT jobject JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1get_1device_1list + (JNIEnv *, jclass, jlong); /* - * Class: ch_ntb_inf_libusbJava_LibusbJava - * Method: usb_get_busses - * Signature: ()Lch/ntb/inf/libusbJava/Usb_Bus; + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_get_bus_number + * Signature: (Lch/ntb/inf/libusbJava/Usb_Device;)S */ -JNIEXPORT jobject JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava_usb_1get_1busses - (JNIEnv *, jclass); - -/* - * Class: ch_ntb_inf_libusbJava_LibusbJava - * Method: usb_open - * Signature: (Lch/ntb/inf/libusbJava/Usb_Device;)J - */ -JNIEXPORT jlong JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava_usb_1open +JNIEXPORT jshort JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1get_1bus_1number (JNIEnv *, jclass, jobject); /* - * Class: ch_ntb_inf_libusbJava_LibusbJava - * Method: usb_close - * Signature: (J)I + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_get_max_iso_packet_size + * Signature: (Lch/ntb/inf/libusbJava/Usb_Device;S)I */ -JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava_usb_1close - (JNIEnv *, jclass, jlong); +JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1get_1max_1iso_1packet_1size + (JNIEnv *, jclass, jobject, jshort); /* - * Class: ch_ntb_inf_libusbJava_LibusbJava - * Method: usb_set_configuration - * Signature: (JI)I + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_ref_device + * Signature: (Lch/ntb/inf/libusbJava/Usb_Device;)Lch/ntb/inf/libusbJava/Usb_Device; */ -JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava_usb_1set_1configuration - (JNIEnv *, jclass, jlong, jint); +JNIEXPORT jobject JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1ref_1device + (JNIEnv *, jclass, jobject); /* - * Class: ch_ntb_inf_libusbJava_LibusbJava - * Method: usb_set_altinterface - * Signature: (JI)I + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_unref_device + * Signature: (Lch/ntb/inf/libusbJava/Usb_Device;)V */ -JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava_usb_1set_1altinterface - (JNIEnv *, jclass, jlong, jint); +JNIEXPORT void JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1unref_1device + (JNIEnv *, jclass, jobject); /* - * Class: ch_ntb_inf_libusbJava_LibusbJava - * Method: usb_clear_halt - * Signature: (JI)I + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_open + * Signature: (Lch/ntb/inf/libusbJava/Usb_Device;)J */ -JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava_usb_1clear_1halt - (JNIEnv *, jclass, jlong, jint); +JNIEXPORT jlong JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1open + (JNIEnv *, jclass, jobject); /* - * Class: ch_ntb_inf_libusbJava_LibusbJava - * Method: usb_reset - * Signature: (J)I + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_open_device_with_vid_pid + * Signature: (JII)J */ -JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava_usb_1reset - (JNIEnv *, jclass, jlong); - -/* - * Class: ch_ntb_inf_libusbJava_LibusbJava - * Method: usb_claim_interface - * Signature: (JI)I - */ -JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava_usb_1claim_1interface - (JNIEnv *, jclass, jlong, jint); - -/* - * Class: ch_ntb_inf_libusbJava_LibusbJava - * Method: usb_release_interface - * Signature: (JI)I - */ -JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava_usb_1release_1interface - (JNIEnv *, jclass, jlong, jint); - -/* - * Class: ch_ntb_inf_libusbJava_LibusbJava - * Method: usb_control_msg - * Signature: (JIIII[BII)I - */ -JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava_usb_1control_1msg - (JNIEnv *, jclass, jlong, jint, jint, jint, jint, jbyteArray, jint, jint); - -/* - * Class: ch_ntb_inf_libusbJava_LibusbJava - * Method: usb_get_string - * Signature: (JII)Ljava/lang/String; - */ -JNIEXPORT jstring JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava_usb_1get_1string +JNIEXPORT jlong JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1open_1device_1with_1vid_1pid (JNIEnv *, jclass, jlong, jint, jint); /* - * Class: ch_ntb_inf_libusbJava_LibusbJava - * Method: usb_get_string_simple - * Signature: (JI)Ljava/lang/String; + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_close + * Signature: (J)V */ -JNIEXPORT jstring JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava_usb_1get_1string_1simple +JNIEXPORT void JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1close + (JNIEnv *, jclass, jlong); + +/* + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_get_device + * Signature: (J)Lch/ntb/inf/libusbJava/Usb_Device; + */ +JNIEXPORT jobject JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1get_1device + (JNIEnv *, jclass, jlong); + +/* + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_get_configuration + * Signature: (J)B + */ +JNIEXPORT jbyte JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1get_1configuration + (JNIEnv *, jclass, jlong); + +/* + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_set_configuration + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1set_1configuration (JNIEnv *, jclass, jlong, jint); /* - * Class: ch_ntb_inf_libusbJava_LibusbJava - * Method: usb_get_descriptor - * Signature: (JBBI)Ljava/lang/String; + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_claim_interface + * Signature: (JI)I */ -JNIEXPORT jstring JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava_usb_1get_1descriptor - (JNIEnv *, jclass, jlong, jbyte, jbyte, jint); +JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1claim_1interface + (JNIEnv *, jclass, jlong, jint); /* - * Class: ch_ntb_inf_libusbJava_LibusbJava - * Method: usb_get_descriptor_by_endpoint - * Signature: (JIBBI)Ljava/lang/String; + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_release_interface + * Signature: (JI)I */ -JNIEXPORT jstring JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava_usb_1get_1descriptor_1by_1endpoint - (JNIEnv *, jclass, jlong, jint, jbyte, jbyte, jint); +JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1release_1interface + (JNIEnv *, jclass, jlong, jint); /* - * Class: ch_ntb_inf_libusbJava_LibusbJava - * Method: usb_bulk_write - * Signature: (JI[BII)I + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_set_interface_alt_setting + * Signature: (JII)I */ -JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava_usb_1bulk_1write - (JNIEnv *, jclass, jlong, jint, jbyteArray, jint, jint); +JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1set_1interface_1alt_1setting + (JNIEnv *, jclass, jlong, jint, jint); /* - * Class: ch_ntb_inf_libusbJava_LibusbJava - * Method: usb_bulk_read - * Signature: (JI[BII)I + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_clear_halt + * Signature: (JS)I */ -JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava_usb_1bulk_1read - (JNIEnv *, jclass, jlong, jint, jbyteArray, jint, jint); +JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1clear_1halt + (JNIEnv *, jclass, jlong, jshort); /* - * Class: ch_ntb_inf_libusbJava_LibusbJava - * Method: usb_interrupt_write - * Signature: (JI[BII)I + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_reset_device + * Signature: (J)I */ -JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava_usb_1interrupt_1write - (JNIEnv *, jclass, jlong, jint, jbyteArray, jint, jint); +JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1reset_1device + (JNIEnv *, jclass, jlong); /* - * Class: ch_ntb_inf_libusbJava_LibusbJava - * Method: usb_interrupt_read - * Signature: (JI[BII)I + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_kernel_driver_active + * Signature: (JI)I */ -JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava_usb_1interrupt_1read - (JNIEnv *, jclass, jlong, jint, jbyteArray, jint, jint); +JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1kernel_1driver_1active + (JNIEnv *, jclass, jlong, jint); /* - * Class: ch_ntb_inf_libusbJava_LibusbJava - * Method: usb_strerror + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_detach_kernel_driver + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1detach_1kernel_1driver + (JNIEnv *, jclass, jlong, jint); + +/* + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_attach_kernel_driver + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1attach_1kernel_1driver + (JNIEnv *, jclass, jlong, jint); + +/* + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_get_active_config_descriptor + * Signature: (Lch/ntb/inf/libusbJava/Usb_Device;)Lch/ntb/inf/libusbJava/Usb_Config_Descriptor; + */ +JNIEXPORT jobject JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1get_1active_1config_1descriptor + (JNIEnv *, jclass, jobject); + +/* + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_get_string_descriptor_ascii + * Signature: (JSI)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1get_1string_1descriptor_1ascii + (JNIEnv *, jclass, jlong, jshort, jint); + +/* + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_get_descriptor + * Signature: (JISI)[B + */ +JNIEXPORT jbyteArray JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1get_1descriptor + (JNIEnv *, jclass, jlong, jint, jshort, jint); + +/* + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_get_string_descriptor + * Signature: (JSII)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1get_1string_1descriptor + (JNIEnv *, jclass, jlong, jshort, jint, jint); + +/* + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_alloc_transfer + * Signature: (I)J + */ +JNIEXPORT jlong JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1alloc_1transfer + (JNIEnv *, jclass, jint); + +/* + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_free_transfer + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1free_1transfer + (JNIEnv *, jclass, jlong); + +/* + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_submit_transfer + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1submit_1transfer + (JNIEnv *, jclass, jlong); + +/* + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_cancel_transfer + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1cancel_1transfer + (JNIEnv *, jclass, jlong); + +/* + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_control_transfer_get_data + * Signature: (J)[B + */ +JNIEXPORT jbyteArray JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1control_1transfer_1get_1data + (JNIEnv *, jclass, jlong); + +/* + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_control_transfer_get_setup + * Signature: (J)[B + */ +JNIEXPORT jbyteArray JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1control_1transfer_1get_1setup + (JNIEnv *, jclass, jlong); + +/* + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_fill_control_setup + * Signature: (IIIII)[B + */ +JNIEXPORT jbyteArray JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1fill_1control_1setup + (JNIEnv *, jclass, jint, jint, jint, jint, jint); + +/* + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_fill_control_transfer + * Signature: (JJ[BI)V + */ +JNIEXPORT void JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1fill_1control_1transfer + (JNIEnv *, jclass, jlong, jlong, jbyteArray, jint); + +/* + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_fill_bulk_transfer + * Signature: (JJB[BII)V + */ +JNIEXPORT void JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1fill_1bulk_1transfer + (JNIEnv *, jclass, jlong, jlong, jbyte, jbyteArray, jint, jint); + +/* + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_fill_interrupt_transfer + * Signature: (JJB[BII)V + */ +JNIEXPORT void JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1fill_1interrupt_1transfer + (JNIEnv *, jclass, jlong, jlong, jbyte, jbyteArray, jint, jint); + +/* + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_fill_iso_transfer + * Signature: (JJB[BIII)V + */ +JNIEXPORT void JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1fill_1iso_1transfer + (JNIEnv *, jclass, jlong, jlong, jbyte, jbyteArray, jint, jint, jint); + +/* + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_set_iso_packet_lengths + * Signature: (JI)V + */ +JNIEXPORT void JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1set_1iso_1packet_1lengths + (JNIEnv *, jclass, jlong, jint); + +/* + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_get_iso_packet_buffer + * Signature: (JI)[B + */ +JNIEXPORT jbyteArray JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1get_1iso_1packet_1buffer + (JNIEnv *, jclass, jlong, jint); + +/* + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_get_iso_packet_buffer_simple + * Signature: (JI)[B + */ +JNIEXPORT jbyteArray JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1get_1iso_1packet_1buffer_1simple + (JNIEnv *, jclass, jlong, jint); + +/* + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_try_lock_events + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1try_1lock_1events + (JNIEnv *, jclass, jlong); + +/* + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_lock_events + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1lock_1events + (JNIEnv *, jclass, jlong); + +/* + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_unlock_events + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1unlock_1events + (JNIEnv *, jclass, jlong); + +/* + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_event_handling_ok + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1event_1handling_1ok + (JNIEnv *, jclass, jlong); + +/* + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_event_handler_active + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1event_1handler_1active + (JNIEnv *, jclass, jlong); + +/* + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_lock_event_waiters + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1lock_1event_1waiters + (JNIEnv *, jclass, jlong); + +/* + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_unlock_event_waiters + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1unlock_1event_1waiters + (JNIEnv *, jclass, jlong); + +/* + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_wait_for_event + * Signature: (JJ)I + */ +JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1wait_1for_1event + (JNIEnv *, jclass, jlong, jlong); + +/* + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_handle_events_timeout + * Signature: (JJ)I + */ +JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1handle_1events_1timeout + (JNIEnv *, jclass, jlong, jlong); + +/* + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_handle_events + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1handle_1events + (JNIEnv *, jclass, jlong); + +/* + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_handle_events_locked + * Signature: (JJ)I + */ +JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1handle_1events_1locked + (JNIEnv *, jclass, jlong, jlong); + +/* + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_pollfds_handle_timeouts + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1pollfds_1handle_1timeouts + (JNIEnv *, jclass, jlong); + +/* + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_get_next_timeout + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1get_1next_1timeout + (JNIEnv *, jclass, jlong); + +/* + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_set_pollfd_notifiers + * Signature: (JZ)V + */ +JNIEXPORT void JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1set_1pollfd_1notifiers + (JNIEnv *, jclass, jlong, jboolean); + +/* + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_get_pollfds + * Signature: (J)[Lch/ntb/inf/libusbJava/Libusb_pollfd; + */ +JNIEXPORT jobjectArray JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1get_1pollfds + (JNIEnv *, jclass, jlong); + +/* + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_control_transfer + * Signature: (JIIII[BII)I + */ +JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1control_1transfer + (JNIEnv *, jclass, jlong, jint, jint, jint, jint, jbyteArray, jint, jint); + +/* + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_bulk_transfer + * Signature: (JB[BII)I + */ +JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1bulk_1transfer + (JNIEnv *, jclass, jlong, jbyte, jbyteArray, jint, jint); + +/* + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_interrupt_transfer + * Signature: (JB[BII)I + */ +JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1interrupt_1transfer + (JNIEnv *, jclass, jlong, jbyte, jbyteArray, jint, jint); + +/* + * Class: ch_ntb_inf_libusbJava_LibusbJava1 + * Method: libusb_strerror * Signature: ()Ljava/lang/String; */ -JNIEXPORT jstring JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava_usb_1strerror +JNIEXPORT jstring JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava1_libusb_1strerror (JNIEnv *, jclass); -/* - * Class: ch_ntb_inf_libusbJava_LibusbJava - * Method: usb_error_no - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_ch_ntb_inf_libusbJava_LibusbJava_usb_1error_1no - (JNIEnv *, jclass, jint); - #ifdef __cplusplus } #endif diff --git a/LibusbJava/LibusbTest.cpp b/LibusbJava/LibusbTest.cpp deleted file mode 100644 index ad098ce..0000000 --- a/LibusbJava/LibusbTest.cpp +++ /dev/null @@ -1,466 +0,0 @@ -/* - * testlibusb.c - * - * Test suite program - */ - -#include -#include -#include "usb.h" - -#define snprintf printf - -#define ID_PRODUCT 0x0200 -#define ID_VENDOR 0x8235 - -#define CONFIGURATION 1 -#define INTERFACE_ 0 -#define ALTINTERFACE 0 -#define TIMEOUT 5000 - -#define OUT_ENDPOINT 0x01 -#define IN_ENDPOINT 0x82 - -// #define SET_ALTINTERFACE_ONCE - -int verbose = 0; -unsigned char first = true; - -void print_endpoint(struct usb_endpoint_descriptor *endpoint) -{ - printf(" bEndpointAddress: %02xh\n", endpoint->bEndpointAddress); - printf(" bmAttributes: %02xh\n", endpoint->bmAttributes); - printf(" wMaxPacketSize: %d\n", endpoint->wMaxPacketSize); - printf(" bInterval: %d\n", endpoint->bInterval); - printf(" bRefresh: %d\n", endpoint->bRefresh); - printf(" bSynchAddress: %d\n", endpoint->bSynchAddress); -} - -void print_altsetting(struct usb_interface_descriptor *interface) -{ - int i; - - printf(" bInterfaceNumber: %d\n", interface->bInterfaceNumber); - printf(" bAlternateSetting: %d\n", interface->bAlternateSetting); - printf(" bNumEndpoints: %d\n", interface->bNumEndpoints); - printf(" bInterfaceClass: %d\n", interface->bInterfaceClass); - printf(" bInterfaceSubClass: %d\n", interface->bInterfaceSubClass); - printf(" bInterfaceProtocol: %d\n", interface->bInterfaceProtocol); - printf(" iInterface: %d\n", interface->iInterface); - - for (i = 0; i < interface->bNumEndpoints; i++) - print_endpoint(&interface->endpoint[i]); -} - -void print_interface(struct usb_interface *interface) -{ - int i; - - for (i = 0; i < interface->num_altsetting; i++) - print_altsetting(&interface->altsetting[i]); -} - -void print_configuration(struct usb_config_descriptor *config) -{ - int i; - - printf(" wTotalLength: %d\n", config->wTotalLength); - printf(" bNumInterfaces: %d\n", config->bNumInterfaces); - printf(" bConfigurationValue: %d\n", config->bConfigurationValue); - printf(" iConfiguration: %d\n", config->iConfiguration); - printf(" bmAttributes: %02xh\n", config->bmAttributes); - printf(" MaxPower: %d\n", config->MaxPower); - - for (i = 0; i < config->bNumInterfaces; i++) - print_interface(&config->interface[i]); -} - -int print_device(struct usb_device *dev, int level) -{ - usb_dev_handle *udev; - char description[256]; - char string[256]; - int ret, i; - - udev = usb_open(dev); - if (udev) { - if (dev->descriptor.iManufacturer) { - ret = usb_get_string_simple(udev, dev->descriptor.iManufacturer, string, sizeof(string)); - if (ret > 0) - snprintf(description, sizeof(description), "%s - ", string); - else - snprintf(description, sizeof(description), "%04X - ", - dev->descriptor.idVendor); - } else - snprintf(description, sizeof(description), "%04X - ", - dev->descriptor.idVendor); - - if (dev->descriptor.iProduct) { - ret = usb_get_string_simple(udev, dev->descriptor.iProduct, string, sizeof(string)); - if (ret > 0) - snprintf(description + strlen(description), sizeof(description) - - strlen(description), "%s", string); - else - snprintf(description + strlen(description), sizeof(description) - - strlen(description), "%04X", dev->descriptor.idProduct); - } else - snprintf(description + strlen(description), sizeof(description) - - strlen(description), "%04X", dev->descriptor.idProduct); - - } else - snprintf(description, sizeof(description), "%04X - %04X", - dev->descriptor.idVendor, dev->descriptor.idProduct); - - printf("%.*sDev #%d: %s\n", level * 2, " ", dev->devnum, - description); - - if (udev && verbose) { - if (dev->descriptor.iSerialNumber) { - ret = usb_get_string_simple(udev, dev->descriptor.iSerialNumber, string, sizeof(string)); - if (ret > 0) - printf("%.*s - Serial Number: %s\n", level * 2, - " ", string); - } - } - - if (udev) - usb_close(udev); - - if (verbose) { - if (!dev->config) { - printf(" Couldn't retrieve descriptors\n"); - return 0; - } - - for (i = 0; i < dev->descriptor.bNumConfigurations; i++) - print_configuration(&dev->config[i]); - } else { - for (i = 0; i < dev->num_children; i++) - print_device(dev->children[i], level + 1); - } - - return 0; -} - -int read(struct usb_dev_handle *handle) -{ - if (usb_claim_interface(handle, INTERFACE_) < 0) { - printf("error on usb_claim_interface: %s\n", usb_strerror()); - return -1; - } - printf("usb_claim_interface successful\n"); -#ifdef SET_ALTINTERFACE_ONCE - if (first) { - first = false; -#endif - if (usb_set_altinterface(handle, ALTINTERFACE) < 0){ - printf("usb_set_altinterface failed: %s\n", usb_strerror()); - } -#ifdef SET_ALTINTERFACE_ONCE - } -#endif - - int size = 512, res; - char *data = (char *) malloc(size*sizeof(char)); - res = usb_bulk_read(handle, IN_ENDPOINT, data, size, TIMEOUT); - if (res < 0){ - printf("usb_bulk_read failed: %s\n", usb_strerror()); - } - printf("usb_bulk_read: %d bytes read: ", res); - for (int i = 0; i < res; ++i) { - printf("%3x ", data[i]); - } - printf("\n"); - - usb_release_interface(handle, INTERFACE_); - free(data); -} - -int write(struct usb_dev_handle *handle) -{ - int size = 12; - char *data = (char *) malloc(size*sizeof(char)); - data[0] = 0x33; - data[1] = 0x5B; - data[2] = 0x02; - data[3] = 0x01; - data[4] = 0x00; - data[5] = 0x05; - data[6] = 0x01; - data[7] = 0x03; - data[8] = 0x07; - data[9] = 0x0F; - data[10] = 0x7F; - data[11] = 0x1F; - // data = {0x33, 0x5B, 0x02, 0x01, 0x00, 0x05, 0x01, 0x03, 0x07, 0x0F, 0x7F, 0x1F}; - - if (usb_claim_interface(handle, INTERFACE_) < 0) { - printf("error on usb_claim_interface: %s\n", usb_strerror()); - return -1; - } - printf("usb_claim_interface successful\n"); -#ifdef SET_ALTINTERFACE_ONCE - if (first) { - first = false; -#endif - if (usb_set_altinterface(handle, ALTINTERFACE) < 0){ - printf("usb_set_altinterface failed: %s\n", usb_strerror()); - } -#ifdef SET_ALTINTERFACE_ONCE - } -#endif - - printf("usb_bulk_write: writing %d bytes: ", size); - for (int i = 0; i < size; ++i) { - printf("%3x ", data[i]); - } - printf("\n"); - - int res = usb_bulk_write(handle, OUT_ENDPOINT, data, size, TIMEOUT); - if (res < 0){ - printf("usb_bulk_write failed: %s\n", usb_strerror()); - return -1; - } - - printf("usb_bulk_write: %d bytes written\n", res); - - usb_release_interface(handle, INTERFACE_); - free(data); -} - -int readWrite(struct usb_dev_handle *handle) -{ - - int size = 512; - char *data = (char *) malloc(size*sizeof(char)); - - printf("type a string...\n"); - scanf("%s", data); // Get a string - - if (usb_claim_interface(handle, INTERFACE_) < 0) { - printf("error on usb_claim_interface: %s\n", usb_strerror()); - system("PAUSE"); - return -1; - } - printf("usb_claim_interface successful\n"); -#ifdef SET_ALTINTERFACE_ONCE - if (first) { - first = false; -#endif - if (usb_set_altinterface(handle, ALTINTERFACE) < 0){ - printf("usb_set_altinterface failed: %s\n", usb_strerror()); - } -#ifdef SET_ALTINTERFACE_ONCE - } -#endif - - if (usb_bulk_write(handle, OUT_ENDPOINT, data, strlen(data), 3000) < 0){ - printf("usb_bulk_write failed: %s\n", usb_strerror()); - system("PAUSE"); - return -1; - } - - strcpy(data, "12345678901234567890"); - printf("%s\n", "read data"); - if (usb_bulk_read(handle, IN_ENDPOINT, data, size, 3000) < 0){ - printf("usb_bulk_read failed: %s\n", usb_strerror()); - } - printf("output %d, %s\n", size, data); -// for (int i = 0; i < size; ++i) { -// printf("%4x ", data[i]); -// } - - usb_release_interface(handle, INTERFACE_); - free(data); -} - -int readWriteLoop(struct usb_dev_handle *handle) -{ - int NOF_LOOPS = 20; - int size = 12; - char *data = (char *) malloc(size*sizeof(char)); - data[0] = 0x33; - data[1] = 0x5B; - data[2] = 0x02; - data[3] = 0x01; - data[4] = 0x00; - data[5] = 0x05; - data[6] = 0x01; - data[7] = 0x03; - data[8] = 0x07; - data[9] = 0x0F; - data[10] = 0x7F; - data[11] = 0x1F; - // data = {0x33, 0x5B, 0x02, 0x01, 0x00, 0x05, 0x01, 0x03, 0x07, 0x0F, 0x7F, 0x1F}; - - if (usb_claim_interface(handle, INTERFACE_) < 0) { - printf("error on usb_claim_interface: %s\n", usb_strerror()); - return -1; - } - printf("usb_claim_interface successful\n"); -#ifdef SET_ALTINTERFACE_ONCE - if (first) { - first = false; -#endif - if (usb_set_altinterface(handle, ALTINTERFACE) < 0){ - printf("usb_set_altinterface failed: %s\n", usb_strerror()); - } -#ifdef SET_ALTINTERFACE_ONCE - } -#endif - - printf("usb_bulk_write: writing %d bytes: ", size); - for (int i = 0; i < size; ++i) { - printf("%3x ", data[i]); - } - printf("\n------------------------\n"); - - for (int var = 0; var < NOF_LOOPS; ++var) { - - int res = usb_bulk_write(handle, OUT_ENDPOINT, data, size, TIMEOUT); - if (res < 0){ - printf("usb_bulk_write failed: %s\n", usb_strerror()); - return -1; - } - - printf("usb_bulk_write: %d bytes written\n", res); - - int size = 64; - char *data = (char *) malloc(size*sizeof(char)); - res = usb_bulk_read(handle, IN_ENDPOINT, data, size, TIMEOUT); - if (res < 0){ - printf("usb_bulk_read failed: %s\n", usb_strerror()); - } - printf("usb_bulk_read: %d bytes read: ", res); - for (int i = 0; i < res; ++i) { - printf("%3x ", data[i]); - } - printf("\n"); - } - - usb_release_interface(handle, INTERFACE_); - free(data); -} - -void logDevices() -{ - struct usb_bus *bus; - - printf("log devices...\n"); - for (bus = usb_get_busses(); bus; bus = bus->next) { - if (bus->root_dev && !verbose) - print_device(bus->root_dev, 0); - else { - struct usb_device *dev; - - for (dev = bus->devices; dev; dev = dev->next) - print_device(dev, 0); - } - } -} - -int main(int argc, char *argv[]) -{ - struct usb_bus *bus; - struct usb_device *dev; - struct usb_dev_handle *handle; - - bool run = true; - - if (argc > 1 && !strcmp(argv[1], "-v")) - verbose = 1; - - usb_set_debug(255); - - printf("initialize library, find busses and devices\n"); - usb_init(); - - usb_find_busses(); - usb_find_devices(); - - if (verbose) - logDevices(); - - int size = 512; - char *data = (char *) malloc(size*sizeof(char)); - - printf("Search for device with idVendor 0x%x and idProduct 0x%x\n", ID_VENDOR, ID_PRODUCT); - for (bus = usb_get_busses(); bus; bus = bus->next) { - if (verbose) - printf("Found bus %s\n", bus->dirname); - for (dev = bus->devices; dev; dev = dev->next) { - if (verbose) - printf("Found device with idVendor 0x%x and idProduct 0x%x\n", dev->descriptor.idVendor, dev->descriptor.idProduct); - if ((dev->descriptor.idProduct == ID_PRODUCT) && (dev->descriptor.idVendor == ID_VENDOR)){ - printf("Device found -> open\n"); - handle = usb_open(dev); - if (!handle) { - printf("invalid handle: %s\n", usb_strerror()); - system("PAUSE"); - return -1; - } - printf("Set configuration\n"); - if (usb_set_configuration(handle, CONFIGURATION) < 0) { - printf("error on usb_set_configuration: %s\n", usb_strerror()); - system("PAUSE"); - return -1; - } - - printf("Set altinterface (must failed)\n"); -#ifdef SET_ALTINTERFACE_ONCE - if (first) { - first = false; -#endif - if (usb_set_altinterface(handle, ALTINTERFACE) < 0){ - printf("usb_set_altinterface failed: %s\n", usb_strerror()); - } -#ifdef SET_ALTINTERFACE_ONCE - } -#endif - - printf("w=write, r=read, x=exit, t=write+read, u=write+read(2), l=r/w loop, z=reset and open\n"); - - while (run) { - scanf("%s", data); - - switch (data[0]) { - case 'w': // write - write(handle); - break; - case 'r': // read - read(handle); - break; - case 'x': // exit - run = false; - break; - case 't': // write + read - if (write(handle)) { - read(handle); - } - break; - case 'u': // write + read - readWrite(handle); - break; - case 'l': // loop - readWriteLoop(handle); - break; - case 's': // reset first flag (set_altinterface()) - first = true; - break; - case 'z': // reset and open - usb_reset(handle); - handle = usb_open(dev); - break; - default: - break; - } - } - printf("\ndone\n"); - } - } - } - free(data); - system("PAUSE"); - - return 1; -} diff --git a/LibusbJava/build.xml b/LibusbJava/build.xml index 030a79a..c8bc167 100644 --- a/LibusbJava/build.xml +++ b/LibusbJava/build.xml @@ -1,97 +1,125 @@ - - - - - Build file for LibusbJava Shared Library - - - + Build file for libusbJava Shared Library + + REQUIREMENTS: + g++ + + http://libusbJava.sourceforge.net + ====================================================================== --> + + Build file for libusbJava Shared Library + + - - + + + - - - - - + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + - - + + + + - - - - - - - - + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/LibusbJava/build_rc.cmd b/LibusbJava/build_rc.cmd new file mode 100644 index 0000000..d006092 --- /dev/null +++ b/LibusbJava/build_rc.cmd @@ -0,0 +1,35 @@ +@echo off +echo #include ^ > %1 +echo. >> %1 +echo #define RT_MANIFEST 24 >> %1 +echo #define ID_MANIFEST 1 >> %1 +echo. >> %1 +echo VS_VERSION_INFO VERSIONINFO >> %1 +echo FILEVERSION %2, %3, %4, %5 >> %1 +echo PRODUCTVERSION %2, %3, %4, %5 >> %1 +echo FILEFLAGSMASK 0x3FL >> %1 +echo FILEFLAGS 0x0L >> %1 +echo FILEOS VOS_NT_WINDOWS32 >> %1 +echo FILETYPE VFT_DLL >> %1 +echo FILESUBTYPE VFT2_UNKNOWN >> %1 +echo BEGIN >> %1 +echo BLOCK "StringFileInfo" >> %1 +echo BEGIN >> %1 +echo BLOCK "040904b0" >> %1 +echo BEGIN >> %1 +echo VALUE "CompanyName", "http://libusbjava.sourceforge.net" >> %1 +echo VALUE "FileDescription", "JNI Library for LibusbJava" >> %1 +echo VALUE "FileVersion", "%2.%3.%4.%5\0" >> %1 +echo VALUE "InternalName", "LibusbJava-1_0.dll" >> %1 +echo VALUE "LegalCopyright", "2012 NTB Interstate University of Applied Sciences of Technology Buchs/Chur/St.Gallen" >> %1 +echo VALUE "OriginalFilename","LibusbJava-1_0.dll" >> %1 +echo VALUE "ProductName", "LibusbJava" >> %1 +echo VALUE "ProductVersion", "%2.%3.%4.%5\0" >> %1 +echo END >> %1 +echo END >> %1 +echo. >> %1 +echo BLOCK "VarFileInfo" >> %1 +echo BEGIN >> %1 +echo VALUE "Translation", 0x409, 1200 >> %1 +echo END >> %1 +echo END >> %1 diff --git a/LibusbJava/common.rc b/LibusbJava/common.rc deleted file mode 100644 index b15e284..0000000 --- a/LibusbJava/common.rc +++ /dev/null @@ -1,35 +0,0 @@ -#include - -#define RT_MANIFEST 24 -#define ID_MANIFEST 1 - -VS_VERSION_INFO VERSIONINFO -FILEVERSION RC_VERSION -PRODUCTVERSION RC_VERSION -FILEFLAGSMASK 0x3FL -FILEFLAGS 0x0L -FILEOS VOS_NT_WINDOWS32 -FILETYPE RC_FILE_TYPE -FILESUBTYPE RC_FILE_SUB_TYPE -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904b0" - BEGIN - VALUE "CompanyName", "http://libusbjava.sourceforge.net" - VALUE "FileDescription", RC_PRODUCT_STR - VALUE "FileVersion", RC_VERSION_STR - VALUE "InternalName", RC_FILE_NAME_STR - VALUE "LegalCopyright", "2008 spandi@users.sourceforge.net" - VALUE "OriginalFilename",RC_FILE_NAME_STR - VALUE "ProductName", RC_PRODUCT_STR - VALUE "ProductVersion", RC_VERSION_STR - END - END - - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END - diff --git a/LibusbJava/error.h b/LibusbJava/error.h deleted file mode 100644 index a9b600c..0000000 --- a/LibusbJava/error.h +++ /dev/null @@ -1,23 +0,0 @@ -// copied from libusb-win32.sourceforge.net -#ifndef __ERROR_H__ -#define __ERROR_H__ - -/* Connection timed out */ -#define ETIMEDOUT 116 - -typedef enum { - USB_ERROR_TYPE_NONE = 0, - USB_ERROR_TYPE_STRING, - USB_ERROR_TYPE_ERRNO, -} usb_error_type_t; - - -void usb_error(char *format, ...); -void usb_message(char *format, ...); -const char *usb_win_error_to_string(void); -int usb_win_error_to_errno(void); - - - -#endif /* _ERROR_H_ */ - diff --git a/LibusbJava/libusb-1.0.def b/LibusbJava/libusb-1.0.def new file mode 100644 index 0000000..b2f3861 --- /dev/null +++ b/LibusbJava/libusb-1.0.def @@ -0,0 +1,592 @@ +LIBRARY +EXPORTS + libusb_alloc_transfer + libusb_alloc_transfer@0 = libusb_alloc_transfer + libusb_alloc_transfer@12 = libusb_alloc_transfer + libusb_alloc_transfer@16 = libusb_alloc_transfer + libusb_alloc_transfer@20 = libusb_alloc_transfer + libusb_alloc_transfer@24 = libusb_alloc_transfer + libusb_alloc_transfer@28 = libusb_alloc_transfer + libusb_alloc_transfer@32 = libusb_alloc_transfer + libusb_alloc_transfer@4 = libusb_alloc_transfer + libusb_alloc_transfer@8 = libusb_alloc_transfer + libusb_attach_kernel_driver + libusb_attach_kernel_driver@0 = libusb_attach_kernel_driver + libusb_attach_kernel_driver@12 = libusb_attach_kernel_driver + libusb_attach_kernel_driver@16 = libusb_attach_kernel_driver + libusb_attach_kernel_driver@20 = libusb_attach_kernel_driver + libusb_attach_kernel_driver@24 = libusb_attach_kernel_driver + libusb_attach_kernel_driver@28 = libusb_attach_kernel_driver + libusb_attach_kernel_driver@32 = libusb_attach_kernel_driver + libusb_attach_kernel_driver@4 = libusb_attach_kernel_driver + libusb_attach_kernel_driver@8 = libusb_attach_kernel_driver + libusb_bulk_transfer + libusb_bulk_transfer@0 = libusb_bulk_transfer + libusb_bulk_transfer@12 = libusb_bulk_transfer + libusb_bulk_transfer@16 = libusb_bulk_transfer + libusb_bulk_transfer@20 = libusb_bulk_transfer + libusb_bulk_transfer@24 = libusb_bulk_transfer + libusb_bulk_transfer@28 = libusb_bulk_transfer + libusb_bulk_transfer@32 = libusb_bulk_transfer + libusb_bulk_transfer@4 = libusb_bulk_transfer + libusb_bulk_transfer@8 = libusb_bulk_transfer + libusb_cancel_transfer + libusb_cancel_transfer@0 = libusb_cancel_transfer + libusb_cancel_transfer@12 = libusb_cancel_transfer + libusb_cancel_transfer@16 = libusb_cancel_transfer + libusb_cancel_transfer@20 = libusb_cancel_transfer + libusb_cancel_transfer@24 = libusb_cancel_transfer + libusb_cancel_transfer@28 = libusb_cancel_transfer + libusb_cancel_transfer@32 = libusb_cancel_transfer + libusb_cancel_transfer@4 = libusb_cancel_transfer + libusb_cancel_transfer@8 = libusb_cancel_transfer + libusb_claim_interface + libusb_claim_interface@0 = libusb_claim_interface + libusb_claim_interface@12 = libusb_claim_interface + libusb_claim_interface@16 = libusb_claim_interface + libusb_claim_interface@20 = libusb_claim_interface + libusb_claim_interface@24 = libusb_claim_interface + libusb_claim_interface@28 = libusb_claim_interface + libusb_claim_interface@32 = libusb_claim_interface + libusb_claim_interface@4 = libusb_claim_interface + libusb_claim_interface@8 = libusb_claim_interface + libusb_clear_halt + libusb_clear_halt@0 = libusb_clear_halt + libusb_clear_halt@12 = libusb_clear_halt + libusb_clear_halt@16 = libusb_clear_halt + libusb_clear_halt@20 = libusb_clear_halt + libusb_clear_halt@24 = libusb_clear_halt + libusb_clear_halt@28 = libusb_clear_halt + libusb_clear_halt@32 = libusb_clear_halt + libusb_clear_halt@4 = libusb_clear_halt + libusb_clear_halt@8 = libusb_clear_halt + libusb_close + libusb_close@0 = libusb_close + libusb_close@12 = libusb_close + libusb_close@16 = libusb_close + libusb_close@20 = libusb_close + libusb_close@24 = libusb_close + libusb_close@28 = libusb_close + libusb_close@32 = libusb_close + libusb_close@4 = libusb_close + libusb_close@8 = libusb_close + libusb_control_transfer + libusb_control_transfer@0 = libusb_control_transfer + libusb_control_transfer@12 = libusb_control_transfer + libusb_control_transfer@16 = libusb_control_transfer + libusb_control_transfer@20 = libusb_control_transfer + libusb_control_transfer@24 = libusb_control_transfer + libusb_control_transfer@28 = libusb_control_transfer + libusb_control_transfer@32 = libusb_control_transfer + libusb_control_transfer@4 = libusb_control_transfer + libusb_control_transfer@8 = libusb_control_transfer + libusb_detach_kernel_driver + libusb_detach_kernel_driver@0 = libusb_detach_kernel_driver + libusb_detach_kernel_driver@12 = libusb_detach_kernel_driver + libusb_detach_kernel_driver@16 = libusb_detach_kernel_driver + libusb_detach_kernel_driver@20 = libusb_detach_kernel_driver + libusb_detach_kernel_driver@24 = libusb_detach_kernel_driver + libusb_detach_kernel_driver@28 = libusb_detach_kernel_driver + libusb_detach_kernel_driver@32 = libusb_detach_kernel_driver + libusb_detach_kernel_driver@4 = libusb_detach_kernel_driver + libusb_detach_kernel_driver@8 = libusb_detach_kernel_driver + libusb_event_handler_active + libusb_event_handler_active@0 = libusb_event_handler_active + libusb_event_handler_active@12 = libusb_event_handler_active + libusb_event_handler_active@16 = libusb_event_handler_active + libusb_event_handler_active@20 = libusb_event_handler_active + libusb_event_handler_active@24 = libusb_event_handler_active + libusb_event_handler_active@28 = libusb_event_handler_active + libusb_event_handler_active@32 = libusb_event_handler_active + libusb_event_handler_active@4 = libusb_event_handler_active + libusb_event_handler_active@8 = libusb_event_handler_active + libusb_event_handling_ok + libusb_event_handling_ok@0 = libusb_event_handling_ok + libusb_event_handling_ok@12 = libusb_event_handling_ok + libusb_event_handling_ok@16 = libusb_event_handling_ok + libusb_event_handling_ok@20 = libusb_event_handling_ok + libusb_event_handling_ok@24 = libusb_event_handling_ok + libusb_event_handling_ok@28 = libusb_event_handling_ok + libusb_event_handling_ok@32 = libusb_event_handling_ok + libusb_event_handling_ok@4 = libusb_event_handling_ok + libusb_event_handling_ok@8 = libusb_event_handling_ok + libusb_exit + libusb_exit@0 = libusb_exit + libusb_exit@12 = libusb_exit + libusb_exit@16 = libusb_exit + libusb_exit@20 = libusb_exit + libusb_exit@24 = libusb_exit + libusb_exit@28 = libusb_exit + libusb_exit@32 = libusb_exit + libusb_exit@4 = libusb_exit + libusb_exit@8 = libusb_exit + libusb_free_config_descriptor + libusb_free_config_descriptor@0 = libusb_free_config_descriptor + libusb_free_config_descriptor@12 = libusb_free_config_descriptor + libusb_free_config_descriptor@16 = libusb_free_config_descriptor + libusb_free_config_descriptor@20 = libusb_free_config_descriptor + libusb_free_config_descriptor@24 = libusb_free_config_descriptor + libusb_free_config_descriptor@28 = libusb_free_config_descriptor + libusb_free_config_descriptor@32 = libusb_free_config_descriptor + libusb_free_config_descriptor@4 = libusb_free_config_descriptor + libusb_free_config_descriptor@8 = libusb_free_config_descriptor + libusb_free_device_list + libusb_free_device_list@0 = libusb_free_device_list + libusb_free_device_list@12 = libusb_free_device_list + libusb_free_device_list@16 = libusb_free_device_list + libusb_free_device_list@20 = libusb_free_device_list + libusb_free_device_list@24 = libusb_free_device_list + libusb_free_device_list@28 = libusb_free_device_list + libusb_free_device_list@32 = libusb_free_device_list + libusb_free_device_list@4 = libusb_free_device_list + libusb_free_device_list@8 = libusb_free_device_list + libusb_free_transfer + libusb_free_transfer@0 = libusb_free_transfer + libusb_free_transfer@12 = libusb_free_transfer + libusb_free_transfer@16 = libusb_free_transfer + libusb_free_transfer@20 = libusb_free_transfer + libusb_free_transfer@24 = libusb_free_transfer + libusb_free_transfer@28 = libusb_free_transfer + libusb_free_transfer@32 = libusb_free_transfer + libusb_free_transfer@4 = libusb_free_transfer + libusb_free_transfer@8 = libusb_free_transfer + libusb_get_active_config_descriptor + libusb_get_active_config_descriptor@0 = libusb_get_active_config_descriptor + libusb_get_active_config_descriptor@12 = libusb_get_active_config_descriptor + libusb_get_active_config_descriptor@16 = libusb_get_active_config_descriptor + libusb_get_active_config_descriptor@20 = libusb_get_active_config_descriptor + libusb_get_active_config_descriptor@24 = libusb_get_active_config_descriptor + libusb_get_active_config_descriptor@28 = libusb_get_active_config_descriptor + libusb_get_active_config_descriptor@32 = libusb_get_active_config_descriptor + libusb_get_active_config_descriptor@4 = libusb_get_active_config_descriptor + libusb_get_active_config_descriptor@8 = libusb_get_active_config_descriptor + libusb_get_bus_number + libusb_get_bus_number@0 = libusb_get_bus_number + libusb_get_bus_number@12 = libusb_get_bus_number + libusb_get_bus_number@16 = libusb_get_bus_number + libusb_get_bus_number@20 = libusb_get_bus_number + libusb_get_bus_number@24 = libusb_get_bus_number + libusb_get_bus_number@28 = libusb_get_bus_number + libusb_get_bus_number@32 = libusb_get_bus_number + libusb_get_bus_number@4 = libusb_get_bus_number + libusb_get_bus_number@8 = libusb_get_bus_number + libusb_get_config_descriptor + libusb_get_config_descriptor@0 = libusb_get_config_descriptor + libusb_get_config_descriptor@12 = libusb_get_config_descriptor + libusb_get_config_descriptor@16 = libusb_get_config_descriptor + libusb_get_config_descriptor@20 = libusb_get_config_descriptor + libusb_get_config_descriptor@24 = libusb_get_config_descriptor + libusb_get_config_descriptor@28 = libusb_get_config_descriptor + libusb_get_config_descriptor@32 = libusb_get_config_descriptor + libusb_get_config_descriptor@4 = libusb_get_config_descriptor + libusb_get_config_descriptor@8 = libusb_get_config_descriptor + libusb_get_config_descriptor_by_value + libusb_get_config_descriptor_by_value@0 = libusb_get_config_descriptor_by_value + libusb_get_config_descriptor_by_value@12 = libusb_get_config_descriptor_by_value + libusb_get_config_descriptor_by_value@16 = libusb_get_config_descriptor_by_value + libusb_get_config_descriptor_by_value@20 = libusb_get_config_descriptor_by_value + libusb_get_config_descriptor_by_value@24 = libusb_get_config_descriptor_by_value + libusb_get_config_descriptor_by_value@28 = libusb_get_config_descriptor_by_value + libusb_get_config_descriptor_by_value@32 = libusb_get_config_descriptor_by_value + libusb_get_config_descriptor_by_value@4 = libusb_get_config_descriptor_by_value + libusb_get_config_descriptor_by_value@8 = libusb_get_config_descriptor_by_value + libusb_get_configuration + libusb_get_configuration@0 = libusb_get_configuration + libusb_get_configuration@12 = libusb_get_configuration + libusb_get_configuration@16 = libusb_get_configuration + libusb_get_configuration@20 = libusb_get_configuration + libusb_get_configuration@24 = libusb_get_configuration + libusb_get_configuration@28 = libusb_get_configuration + libusb_get_configuration@32 = libusb_get_configuration + libusb_get_configuration@4 = libusb_get_configuration + libusb_get_configuration@8 = libusb_get_configuration + libusb_get_device + libusb_get_device@0 = libusb_get_device + libusb_get_device@12 = libusb_get_device + libusb_get_device@16 = libusb_get_device + libusb_get_device@20 = libusb_get_device + libusb_get_device@24 = libusb_get_device + libusb_get_device@28 = libusb_get_device + libusb_get_device@32 = libusb_get_device + libusb_get_device@4 = libusb_get_device + libusb_get_device@8 = libusb_get_device + libusb_get_device_address + libusb_get_device_address@0 = libusb_get_device_address + libusb_get_device_address@12 = libusb_get_device_address + libusb_get_device_address@16 = libusb_get_device_address + libusb_get_device_address@20 = libusb_get_device_address + libusb_get_device_address@24 = libusb_get_device_address + libusb_get_device_address@28 = libusb_get_device_address + libusb_get_device_address@32 = libusb_get_device_address + libusb_get_device_address@4 = libusb_get_device_address + libusb_get_device_address@8 = libusb_get_device_address + libusb_get_device_descriptor + libusb_get_device_descriptor@0 = libusb_get_device_descriptor + libusb_get_device_descriptor@12 = libusb_get_device_descriptor + libusb_get_device_descriptor@16 = libusb_get_device_descriptor + libusb_get_device_descriptor@20 = libusb_get_device_descriptor + libusb_get_device_descriptor@24 = libusb_get_device_descriptor + libusb_get_device_descriptor@28 = libusb_get_device_descriptor + libusb_get_device_descriptor@32 = libusb_get_device_descriptor + libusb_get_device_descriptor@4 = libusb_get_device_descriptor + libusb_get_device_descriptor@8 = libusb_get_device_descriptor + libusb_get_device_list + libusb_get_device_list@0 = libusb_get_device_list + libusb_get_device_list@12 = libusb_get_device_list + libusb_get_device_list@16 = libusb_get_device_list + libusb_get_device_list@20 = libusb_get_device_list + libusb_get_device_list@24 = libusb_get_device_list + libusb_get_device_list@28 = libusb_get_device_list + libusb_get_device_list@32 = libusb_get_device_list + libusb_get_device_list@4 = libusb_get_device_list + libusb_get_device_list@8 = libusb_get_device_list + libusb_get_device_speed + libusb_get_device_speed@0 = libusb_get_device_speed + libusb_get_device_speed@12 = libusb_get_device_speed + libusb_get_device_speed@16 = libusb_get_device_speed + libusb_get_device_speed@20 = libusb_get_device_speed + libusb_get_device_speed@24 = libusb_get_device_speed + libusb_get_device_speed@28 = libusb_get_device_speed + libusb_get_device_speed@32 = libusb_get_device_speed + libusb_get_device_speed@4 = libusb_get_device_speed + libusb_get_device_speed@8 = libusb_get_device_speed + libusb_get_max_iso_packet_size + libusb_get_max_iso_packet_size@0 = libusb_get_max_iso_packet_size + libusb_get_max_iso_packet_size@12 = libusb_get_max_iso_packet_size + libusb_get_max_iso_packet_size@16 = libusb_get_max_iso_packet_size + libusb_get_max_iso_packet_size@20 = libusb_get_max_iso_packet_size + libusb_get_max_iso_packet_size@24 = libusb_get_max_iso_packet_size + libusb_get_max_iso_packet_size@28 = libusb_get_max_iso_packet_size + libusb_get_max_iso_packet_size@32 = libusb_get_max_iso_packet_size + libusb_get_max_iso_packet_size@4 = libusb_get_max_iso_packet_size + libusb_get_max_iso_packet_size@8 = libusb_get_max_iso_packet_size + libusb_get_max_packet_size + libusb_get_max_packet_size@0 = libusb_get_max_packet_size + libusb_get_max_packet_size@12 = libusb_get_max_packet_size + libusb_get_max_packet_size@16 = libusb_get_max_packet_size + libusb_get_max_packet_size@20 = libusb_get_max_packet_size + libusb_get_max_packet_size@24 = libusb_get_max_packet_size + libusb_get_max_packet_size@28 = libusb_get_max_packet_size + libusb_get_max_packet_size@32 = libusb_get_max_packet_size + libusb_get_max_packet_size@4 = libusb_get_max_packet_size + libusb_get_max_packet_size@8 = libusb_get_max_packet_size + libusb_get_next_timeout + libusb_get_next_timeout@0 = libusb_get_next_timeout + libusb_get_next_timeout@12 = libusb_get_next_timeout + libusb_get_next_timeout@16 = libusb_get_next_timeout + libusb_get_next_timeout@20 = libusb_get_next_timeout + libusb_get_next_timeout@24 = libusb_get_next_timeout + libusb_get_next_timeout@28 = libusb_get_next_timeout + libusb_get_next_timeout@32 = libusb_get_next_timeout + libusb_get_next_timeout@4 = libusb_get_next_timeout + libusb_get_next_timeout@8 = libusb_get_next_timeout + libusb_get_parent + libusb_get_parent@0 = libusb_get_parent + libusb_get_parent@12 = libusb_get_parent + libusb_get_parent@16 = libusb_get_parent + libusb_get_parent@20 = libusb_get_parent + libusb_get_parent@24 = libusb_get_parent + libusb_get_parent@28 = libusb_get_parent + libusb_get_parent@32 = libusb_get_parent + libusb_get_parent@4 = libusb_get_parent + libusb_get_parent@8 = libusb_get_parent + libusb_get_pollfds + libusb_get_pollfds@0 = libusb_get_pollfds + libusb_get_pollfds@12 = libusb_get_pollfds + libusb_get_pollfds@16 = libusb_get_pollfds + libusb_get_pollfds@20 = libusb_get_pollfds + libusb_get_pollfds@24 = libusb_get_pollfds + libusb_get_pollfds@28 = libusb_get_pollfds + libusb_get_pollfds@32 = libusb_get_pollfds + libusb_get_pollfds@4 = libusb_get_pollfds + libusb_get_pollfds@8 = libusb_get_pollfds + libusb_get_port_number + libusb_get_port_number@0 = libusb_get_port_number + libusb_get_port_number@12 = libusb_get_port_number + libusb_get_port_number@16 = libusb_get_port_number + libusb_get_port_number@20 = libusb_get_port_number + libusb_get_port_number@24 = libusb_get_port_number + libusb_get_port_number@28 = libusb_get_port_number + libusb_get_port_number@32 = libusb_get_port_number + libusb_get_port_number@4 = libusb_get_port_number + libusb_get_port_number@8 = libusb_get_port_number + libusb_get_port_path + libusb_get_port_path@0 = libusb_get_port_path + libusb_get_port_path@12 = libusb_get_port_path + libusb_get_port_path@16 = libusb_get_port_path + libusb_get_port_path@20 = libusb_get_port_path + libusb_get_port_path@24 = libusb_get_port_path + libusb_get_port_path@28 = libusb_get_port_path + libusb_get_port_path@32 = libusb_get_port_path + libusb_get_port_path@4 = libusb_get_port_path + libusb_get_port_path@8 = libusb_get_port_path + libusb_get_string_descriptor_ascii + libusb_get_string_descriptor_ascii@0 = libusb_get_string_descriptor_ascii + libusb_get_string_descriptor_ascii@12 = libusb_get_string_descriptor_ascii + libusb_get_string_descriptor_ascii@16 = libusb_get_string_descriptor_ascii + libusb_get_string_descriptor_ascii@20 = libusb_get_string_descriptor_ascii + libusb_get_string_descriptor_ascii@24 = libusb_get_string_descriptor_ascii + libusb_get_string_descriptor_ascii@28 = libusb_get_string_descriptor_ascii + libusb_get_string_descriptor_ascii@32 = libusb_get_string_descriptor_ascii + libusb_get_string_descriptor_ascii@4 = libusb_get_string_descriptor_ascii + libusb_get_string_descriptor_ascii@8 = libusb_get_string_descriptor_ascii + libusb_getversion + libusb_getversion@0 = libusb_getversion + libusb_getversion@12 = libusb_getversion + libusb_getversion@16 = libusb_getversion + libusb_getversion@20 = libusb_getversion + libusb_getversion@24 = libusb_getversion + libusb_getversion@28 = libusb_getversion + libusb_getversion@32 = libusb_getversion + libusb_getversion@4 = libusb_getversion + libusb_getversion@8 = libusb_getversion + libusb_handle_events + libusb_handle_events@0 = libusb_handle_events + libusb_handle_events@12 = libusb_handle_events + libusb_handle_events@16 = libusb_handle_events + libusb_handle_events@20 = libusb_handle_events + libusb_handle_events@24 = libusb_handle_events + libusb_handle_events@28 = libusb_handle_events + libusb_handle_events@32 = libusb_handle_events + libusb_handle_events@4 = libusb_handle_events + libusb_handle_events@8 = libusb_handle_events + libusb_handle_events_locked + libusb_handle_events_locked@0 = libusb_handle_events_locked + libusb_handle_events_locked@12 = libusb_handle_events_locked + libusb_handle_events_locked@16 = libusb_handle_events_locked + libusb_handle_events_locked@20 = libusb_handle_events_locked + libusb_handle_events_locked@24 = libusb_handle_events_locked + libusb_handle_events_locked@28 = libusb_handle_events_locked + libusb_handle_events_locked@32 = libusb_handle_events_locked + libusb_handle_events_locked@4 = libusb_handle_events_locked + libusb_handle_events_locked@8 = libusb_handle_events_locked + libusb_handle_events_timeout + libusb_handle_events_timeout@0 = libusb_handle_events_timeout + libusb_handle_events_timeout@12 = libusb_handle_events_timeout + libusb_handle_events_timeout@16 = libusb_handle_events_timeout + libusb_handle_events_timeout@20 = libusb_handle_events_timeout + libusb_handle_events_timeout@24 = libusb_handle_events_timeout + libusb_handle_events_timeout@28 = libusb_handle_events_timeout + libusb_handle_events_timeout@32 = libusb_handle_events_timeout + libusb_handle_events_timeout@4 = libusb_handle_events_timeout + libusb_handle_events_timeout@8 = libusb_handle_events_timeout + libusb_init + libusb_init@0 = libusb_init + libusb_init@12 = libusb_init + libusb_init@16 = libusb_init + libusb_init@20 = libusb_init + libusb_init@24 = libusb_init + libusb_init@28 = libusb_init + libusb_init@32 = libusb_init + libusb_init@4 = libusb_init + libusb_init@8 = libusb_init + libusb_interrupt_transfer + libusb_interrupt_transfer@0 = libusb_interrupt_transfer + libusb_interrupt_transfer@12 = libusb_interrupt_transfer + libusb_interrupt_transfer@16 = libusb_interrupt_transfer + libusb_interrupt_transfer@20 = libusb_interrupt_transfer + libusb_interrupt_transfer@24 = libusb_interrupt_transfer + libusb_interrupt_transfer@28 = libusb_interrupt_transfer + libusb_interrupt_transfer@32 = libusb_interrupt_transfer + libusb_interrupt_transfer@4 = libusb_interrupt_transfer + libusb_interrupt_transfer@8 = libusb_interrupt_transfer + libusb_kernel_driver_active + libusb_kernel_driver_active@0 = libusb_kernel_driver_active + libusb_kernel_driver_active@12 = libusb_kernel_driver_active + libusb_kernel_driver_active@16 = libusb_kernel_driver_active + libusb_kernel_driver_active@20 = libusb_kernel_driver_active + libusb_kernel_driver_active@24 = libusb_kernel_driver_active + libusb_kernel_driver_active@28 = libusb_kernel_driver_active + libusb_kernel_driver_active@32 = libusb_kernel_driver_active + libusb_kernel_driver_active@4 = libusb_kernel_driver_active + libusb_kernel_driver_active@8 = libusb_kernel_driver_active + libusb_lock_event_waiters + libusb_lock_event_waiters@0 = libusb_lock_event_waiters + libusb_lock_event_waiters@12 = libusb_lock_event_waiters + libusb_lock_event_waiters@16 = libusb_lock_event_waiters + libusb_lock_event_waiters@20 = libusb_lock_event_waiters + libusb_lock_event_waiters@24 = libusb_lock_event_waiters + libusb_lock_event_waiters@28 = libusb_lock_event_waiters + libusb_lock_event_waiters@32 = libusb_lock_event_waiters + libusb_lock_event_waiters@4 = libusb_lock_event_waiters + libusb_lock_event_waiters@8 = libusb_lock_event_waiters + libusb_lock_events + libusb_lock_events@0 = libusb_lock_events + libusb_lock_events@12 = libusb_lock_events + libusb_lock_events@16 = libusb_lock_events + libusb_lock_events@20 = libusb_lock_events + libusb_lock_events@24 = libusb_lock_events + libusb_lock_events@28 = libusb_lock_events + libusb_lock_events@32 = libusb_lock_events + libusb_lock_events@4 = libusb_lock_events + libusb_lock_events@8 = libusb_lock_events + libusb_open + libusb_open@0 = libusb_open + libusb_open@12 = libusb_open + libusb_open@16 = libusb_open + libusb_open@20 = libusb_open + libusb_open@24 = libusb_open + libusb_open@28 = libusb_open + libusb_open@32 = libusb_open + libusb_open@4 = libusb_open + libusb_open@8 = libusb_open + libusb_open_device_with_vid_pid + libusb_open_device_with_vid_pid@0 = libusb_open_device_with_vid_pid + libusb_open_device_with_vid_pid@12 = libusb_open_device_with_vid_pid + libusb_open_device_with_vid_pid@16 = libusb_open_device_with_vid_pid + libusb_open_device_with_vid_pid@20 = libusb_open_device_with_vid_pid + libusb_open_device_with_vid_pid@24 = libusb_open_device_with_vid_pid + libusb_open_device_with_vid_pid@28 = libusb_open_device_with_vid_pid + libusb_open_device_with_vid_pid@32 = libusb_open_device_with_vid_pid + libusb_open_device_with_vid_pid@4 = libusb_open_device_with_vid_pid + libusb_open_device_with_vid_pid@8 = libusb_open_device_with_vid_pid + libusb_pollfds_handle_timeouts + libusb_pollfds_handle_timeouts@0 = libusb_pollfds_handle_timeouts + libusb_pollfds_handle_timeouts@12 = libusb_pollfds_handle_timeouts + libusb_pollfds_handle_timeouts@16 = libusb_pollfds_handle_timeouts + libusb_pollfds_handle_timeouts@20 = libusb_pollfds_handle_timeouts + libusb_pollfds_handle_timeouts@24 = libusb_pollfds_handle_timeouts + libusb_pollfds_handle_timeouts@28 = libusb_pollfds_handle_timeouts + libusb_pollfds_handle_timeouts@32 = libusb_pollfds_handle_timeouts + libusb_pollfds_handle_timeouts@4 = libusb_pollfds_handle_timeouts + libusb_pollfds_handle_timeouts@8 = libusb_pollfds_handle_timeouts + libusb_ref_device + libusb_ref_device@0 = libusb_ref_device + libusb_ref_device@12 = libusb_ref_device + libusb_ref_device@16 = libusb_ref_device + libusb_ref_device@20 = libusb_ref_device + libusb_ref_device@24 = libusb_ref_device + libusb_ref_device@28 = libusb_ref_device + libusb_ref_device@32 = libusb_ref_device + libusb_ref_device@4 = libusb_ref_device + libusb_ref_device@8 = libusb_ref_device + libusb_release_interface + libusb_release_interface@0 = libusb_release_interface + libusb_release_interface@12 = libusb_release_interface + libusb_release_interface@16 = libusb_release_interface + libusb_release_interface@20 = libusb_release_interface + libusb_release_interface@24 = libusb_release_interface + libusb_release_interface@28 = libusb_release_interface + libusb_release_interface@32 = libusb_release_interface + libusb_release_interface@4 = libusb_release_interface + libusb_release_interface@8 = libusb_release_interface + libusb_reset_device + libusb_reset_device@0 = libusb_reset_device + libusb_reset_device@12 = libusb_reset_device + libusb_reset_device@16 = libusb_reset_device + libusb_reset_device@20 = libusb_reset_device + libusb_reset_device@24 = libusb_reset_device + libusb_reset_device@28 = libusb_reset_device + libusb_reset_device@32 = libusb_reset_device + libusb_reset_device@4 = libusb_reset_device + libusb_reset_device@8 = libusb_reset_device + libusb_set_configuration + libusb_set_configuration@0 = libusb_set_configuration + libusb_set_configuration@12 = libusb_set_configuration + libusb_set_configuration@16 = libusb_set_configuration + libusb_set_configuration@20 = libusb_set_configuration + libusb_set_configuration@24 = libusb_set_configuration + libusb_set_configuration@28 = libusb_set_configuration + libusb_set_configuration@32 = libusb_set_configuration + libusb_set_configuration@4 = libusb_set_configuration + libusb_set_configuration@8 = libusb_set_configuration + libusb_set_debug + libusb_set_debug@0 = libusb_set_debug + libusb_set_debug@12 = libusb_set_debug + libusb_set_debug@16 = libusb_set_debug + libusb_set_debug@20 = libusb_set_debug + libusb_set_debug@24 = libusb_set_debug + libusb_set_debug@28 = libusb_set_debug + libusb_set_debug@32 = libusb_set_debug + libusb_set_debug@4 = libusb_set_debug + libusb_set_debug@8 = libusb_set_debug + libusb_set_interface_alt_setting + libusb_set_interface_alt_setting@0 = libusb_set_interface_alt_setting + libusb_set_interface_alt_setting@12 = libusb_set_interface_alt_setting + libusb_set_interface_alt_setting@16 = libusb_set_interface_alt_setting + libusb_set_interface_alt_setting@20 = libusb_set_interface_alt_setting + libusb_set_interface_alt_setting@24 = libusb_set_interface_alt_setting + libusb_set_interface_alt_setting@28 = libusb_set_interface_alt_setting + libusb_set_interface_alt_setting@32 = libusb_set_interface_alt_setting + libusb_set_interface_alt_setting@4 = libusb_set_interface_alt_setting + libusb_set_interface_alt_setting@8 = libusb_set_interface_alt_setting + libusb_set_pollfd_notifiers + libusb_set_pollfd_notifiers@0 = libusb_set_pollfd_notifiers + libusb_set_pollfd_notifiers@12 = libusb_set_pollfd_notifiers + libusb_set_pollfd_notifiers@16 = libusb_set_pollfd_notifiers + libusb_set_pollfd_notifiers@20 = libusb_set_pollfd_notifiers + libusb_set_pollfd_notifiers@24 = libusb_set_pollfd_notifiers + libusb_set_pollfd_notifiers@28 = libusb_set_pollfd_notifiers + libusb_set_pollfd_notifiers@32 = libusb_set_pollfd_notifiers + libusb_set_pollfd_notifiers@4 = libusb_set_pollfd_notifiers + libusb_set_pollfd_notifiers@8 = libusb_set_pollfd_notifiers + libusb_strerror + libusb_strerror@0 = libusb_strerror + libusb_strerror@12 = libusb_strerror + libusb_strerror@16 = libusb_strerror + libusb_strerror@20 = libusb_strerror + libusb_strerror@24 = libusb_strerror + libusb_strerror@28 = libusb_strerror + libusb_strerror@32 = libusb_strerror + libusb_strerror@4 = libusb_strerror + libusb_strerror@8 = libusb_strerror + libusb_submit_transfer + libusb_submit_transfer@0 = libusb_submit_transfer + libusb_submit_transfer@12 = libusb_submit_transfer + libusb_submit_transfer@16 = libusb_submit_transfer + libusb_submit_transfer@20 = libusb_submit_transfer + libusb_submit_transfer@24 = libusb_submit_transfer + libusb_submit_transfer@28 = libusb_submit_transfer + libusb_submit_transfer@32 = libusb_submit_transfer + libusb_submit_transfer@4 = libusb_submit_transfer + libusb_submit_transfer@8 = libusb_submit_transfer + libusb_try_lock_events + libusb_try_lock_events@0 = libusb_try_lock_events + libusb_try_lock_events@12 = libusb_try_lock_events + libusb_try_lock_events@16 = libusb_try_lock_events + libusb_try_lock_events@20 = libusb_try_lock_events + libusb_try_lock_events@24 = libusb_try_lock_events + libusb_try_lock_events@28 = libusb_try_lock_events + libusb_try_lock_events@32 = libusb_try_lock_events + libusb_try_lock_events@4 = libusb_try_lock_events + libusb_try_lock_events@8 = libusb_try_lock_events + libusb_unlock_event_waiters + libusb_unlock_event_waiters@0 = libusb_unlock_event_waiters + libusb_unlock_event_waiters@12 = libusb_unlock_event_waiters + libusb_unlock_event_waiters@16 = libusb_unlock_event_waiters + libusb_unlock_event_waiters@20 = libusb_unlock_event_waiters + libusb_unlock_event_waiters@24 = libusb_unlock_event_waiters + libusb_unlock_event_waiters@28 = libusb_unlock_event_waiters + libusb_unlock_event_waiters@32 = libusb_unlock_event_waiters + libusb_unlock_event_waiters@4 = libusb_unlock_event_waiters + libusb_unlock_event_waiters@8 = libusb_unlock_event_waiters + libusb_unlock_events + libusb_unlock_events@0 = libusb_unlock_events + libusb_unlock_events@12 = libusb_unlock_events + libusb_unlock_events@16 = libusb_unlock_events + libusb_unlock_events@20 = libusb_unlock_events + libusb_unlock_events@24 = libusb_unlock_events + libusb_unlock_events@28 = libusb_unlock_events + libusb_unlock_events@32 = libusb_unlock_events + libusb_unlock_events@4 = libusb_unlock_events + libusb_unlock_events@8 = libusb_unlock_events + libusb_unref_device + libusb_unref_device@0 = libusb_unref_device + libusb_unref_device@12 = libusb_unref_device + libusb_unref_device@16 = libusb_unref_device + libusb_unref_device@20 = libusb_unref_device + libusb_unref_device@24 = libusb_unref_device + libusb_unref_device@28 = libusb_unref_device + libusb_unref_device@32 = libusb_unref_device + libusb_unref_device@4 = libusb_unref_device + libusb_unref_device@8 = libusb_unref_device + libusb_wait_for_event + libusb_wait_for_event@0 = libusb_wait_for_event + libusb_wait_for_event@12 = libusb_wait_for_event + libusb_wait_for_event@16 = libusb_wait_for_event + libusb_wait_for_event@20 = libusb_wait_for_event + libusb_wait_for_event@24 = libusb_wait_for_event + libusb_wait_for_event@28 = libusb_wait_for_event + libusb_wait_for_event@32 = libusb_wait_for_event + libusb_wait_for_event@4 = libusb_wait_for_event + libusb_wait_for_event@8 = libusb_wait_for_event diff --git a/LibusbJava/libusb.a b/LibusbJava/libusb.a deleted file mode 100644 index 7a0cc469d4f56bd2ec94752e699fd39b3816caee..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 27984 zcmeI4&5s;M6~Ld{pIH{i-*z0w8L!tH$Fi2$`S9+7F+mVQKKMq25QX;aOs}`e?98fX z#$bs9e*lLZI3koo4xIP{azGYBIq?S|#L)*195`}7g7>PrzPhSrs&9?kB~|y#tJfb@ z_3Kx!Uw7BFyS=QxcW>zn4Kr$G<@w}i0F+N(;`!`D0Lth8$n(X215m!a#`BdQ0Z_jBJDwX)04QHS#q*600OePH z$@8m!0ib+4;(2`)fO7L!Jh%P~K)H*@r@Z+Sp0_^*pnUfP&-Zo#D8Gifl)tvj^XuyX zl;6NI%5VOG=eM5#Q2zE?Jb(As0F=M~C!T+Zb)x)ki|6-#20;1!-|+kao-^h6Up()u z0Z<;G4&~iXc;5RP0Ob!Gl;dH#Gn?!*T^agqX#HbR_M(JoW?V;Wz z$sVTtBpw~a*=⪼x_62LA+Sax1U8j;Ab!$&-#0Kmb>w8I`kaguS3VSO7#Of3Td0k zY-c~6#=Xg-QD0X#Vn?9Ijy=gig6?F@R zVw>J@nvSMPw%hAdC&~_);O@;b+9FF(o*d|kQY6c*Qr-_)GE91t1bf19I7cDhU+;jo zVLTf5d!v40P?IH&Vskt5WQ00DqwzsvG!y?%+ozLpe=i%4#JDuexq3_JA!nUV6 zX0wB7{PQfG8V$>;uNRs6zN5(<8VcsN*c=1n6y-*|glh*}jdLzp_dd*{7LUMNTkLd{ zB!dZ&H0@vLMa4<&3id*@##IaPl ze@k^twEmN1Qq&Yu+UIVTB)0X_rA#Xw4bZgFxM1vU*N{t1aR6nen4%Dq9^aXMWxDiaQxm^z*HaqgV?e6l+obkZ=jx?S#) zHSRCHbLcR-WdI*zK0-g>=%Mv=(3|#F(TC!RDhQc#U{%_`e7)qFi@@a^Gl)wOz9r+;;6Y z_ir0o+kJ-nK8hJzP_!NTbUdBI6}8>(^Z)$ZK(vX`b|2?D+DhmdeesE=kpFxvYAcG0 z|EZ;p1GPMr90zokf!g!9Xis*=3tE_+h26rm740AWbhhM+2yWpIm-A`6sGQ(-a4&QX zf_dBD#nV7n9TWD#H2KAp{pJgj{~hx=I#o=xY5?5N>5^np+dRR1Rnx=2q8E(b`Ue)= zbn6+t^-t7mx%KW~5lgGML^r>f9{=|Si9Rwes#`!NVV?8OdxLu97~A7S8S zzOG{ZC=q|0uY2r2UqtXd{Nd$G_ZeJZxolZZ)J8Z_9ewQOL~UWOEh6fa*0YT{L|xYO zu(DpFR^56QQR{9!Nfe$-Fi|%dQPy3#h&iwxqh70;)mp)GqNJ$$1{bhp1n=RRQRS_g zcK1F<#|qQrbcK5--Ii^yn%IMj=sKbGa$^o%XEZ&mw3n_cZas^xHMgFm3&U~2biLxH ztFlzRh;^f+sM_KJwv6CyT)U~#4V8tH-%7Q&!>v?v+Zy+7V_z-e=!n*zjX4~h)by~L zUXCug^(>B7+pn>j9?qroElLTofswa(Xv^B7TeC$g_c!Li+ol^QLZpj4Bn(P@&9cjl$#Too)MGzAmHJHAazm z!d%^m&}oYvinWRq0R=kQ=q0M6L8C-IR>C9Joh{ohrWnj3zxY4-sgl3jnBx~8%N^o; zCH!40Vy(xKaF;^Q@{2ujBzfu4lY~&exS?37td)5l>qALdnFjmM7ZJ4ahvG!P180=X zx$7!qZQHx4%TtT1IY;7kBK308qsrQz zmvT#^Y|mZ8_IyX#9=lq`c;zbg@l+zJ+_e3ixfTRXv#9xcE}>Nf@8Xi#7+=-2@yf5_vp(UGSC8J6_{c#FGF?h61{ywN!ca& zS}#f?cpaAoo{BGNt4~Vu5+6a~QRi;QCa5l6)5V;i;%6-46|$;Yrt5?eCPmUWxqvMr zcpuj}NxrHX*2%Br<10K;-EG;PQ(Z>A3m(3p!d8mj>7}ID`XU#wWdz^CwTCVJ?q7VJ zrM?CA$Fy4|V%jx+-}Ssfll9?TW&QD$oF7G$=Y3bfj8!#IEK7+fca2A=Q<58Vj)tnn0D?y-HIqcxoD^RBQzFt`<0t&j7dWB|x~dEX zKjBvl>F$jo^;w@1vFxt>{I)J%;h&V$sOedZNnR>Uk$3}E-QT}O(B~eS)~kj#R;4 z&YSbyDQi=Z`^YH~ZLV<)=s87>9Hy%3;{?Zmj0q46;4B)ankAyk+xA^pUA{s*!MMq% zk*x3-MYBjyQg>V{T)>tQ&}Vw=j!Vplsc?}JkA-PIi!y6XNk5&>A&xUr^w~tKdlwaK zVf5-~E{!SnaT6Y8uJgC6$2d1^j@hb?NWtH(=2PV=<01q;MxI5GLu|{@oDn(AFm6;; zR)X)b^;wg3U}Pn|^J_LsM38IzmBx{r8gs_!>XH-um4-EmwvLZkTR%f3;=?t*<37w8 z(kCddtmO&5<2L72*Wl5s=_lt|TsUORiWoWC)bvlon59)mbB7J7&(kRp7jD_JE7au+ zo0+ + * Copyright (c) 2001 Johannes Erdfelt + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef __LIBUSB_H__ +#define __LIBUSB_H__ + +#ifdef _MSC_VER +/* on MS environments, the inline keyword is available in C++ only */ +#define inline __inline +/* ssize_t is also not available (copy/paste from MinGW) */ +#ifndef _SSIZE_T_DEFINED +#define _SSIZE_T_DEFINED +#undef ssize_t +#ifdef _WIN64 + typedef __int64 ssize_t; +#else + typedef int ssize_t; +#endif /* _WIN64 */ +#endif /* _SSIZE_T_DEFINED */ +#endif /* _MSC_VER */ + +/* stdint.h is also not usually available on MS */ +#if defined(_MSC_VER) && (_MSC_VER < 1600) && (!defined(_STDINT)) && (!defined(_STDINT_H)) +typedef unsigned __int8 uint8_t; +typedef unsigned __int16 uint16_t; +#else +#include +#endif + +#include +#include +#include + +#if defined(__linux) || defined(__APPLE__) || defined(__CYGWIN__) +#include +#endif + +/* 'interface' might be defined as a macro on Windows, so we need to + * undefine it so as not to break the current libusb API, because + * libusb_config_descriptor has an 'interface' member + * As this can be problematic if you include windows.h after libusb.h + * in your sources, we force windows.h to be included first. */ +#if defined(_WIN32) || defined(__CYGWIN__) +#include +#if defined(interface) +#undef interface +#endif +#endif + +/** \def LIBUSB_CALL + * \ingroup misc + * libusb's Windows calling convention. + * + * Under Windows, the selection of available compilers and configurations + * means that, unlike other platforms, there is not one true calling + * convention (calling convention: the manner in which parameters are + * passed to funcions in the generated assembly code). + * + * Matching the Windows API itself, libusb uses the WINAPI convention (which + * translates to the stdcall convention) and guarantees that the + * library is compiled in this way. The public header file also includes + * appropriate annotations so that your own software will use the right + * convention, even if another convention is being used by default within + * your codebase. + * + * The one consideration that you must apply in your software is to mark + * all functions which you use as libusb callbacks with this LIBUSB_CALL + * annotation, so that they too get compiled for the correct calling + * convention. + * + * On non-Windows operating systems, this macro is defined as nothing. This + * means that you can apply it to your code without worrying about + * cross-platform compatibility. + */ +/* LIBUSB_CALL must be defined on both definition and declaration of libusb + * functions. You'd think that declaration would be enough, but cygwin will + * complain about conflicting types unless both are marked this way. + * The placement of this macro is important too; it must appear after the + * return type, before the function name. See internal documentation for + * API_EXPORTED. + */ +#if defined(_WIN32) +#define LIBUSB_CALL WINAPI +#else +#define LIBUSB_CALL +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/** \def libusb_cpu_to_le16 + * \ingroup misc + * 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 + * \returns the value in little-endian byte order + */ +static inline uint16_t libusb_cpu_to_le16(const uint16_t x) +{ + union { + uint8_t b8[2]; + uint16_t b16; + } _tmp; + _tmp.b8[1] = x >> 8; + _tmp.b8[0] = x & 0xff; + return _tmp.b16; +} + +/** \def libusb_le16_to_cpu + * \ingroup misc + * 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 + * \returns the value in host-endian byte order + */ +#define libusb_le16_to_cpu libusb_cpu_to_le16 + +/* standard USB stuff */ + +/** \ingroup desc + * Device and/or Interface Class codes */ +enum libusb_class_code { + /** In the context of a \ref libusb_device_descriptor "device descriptor", + * this bDeviceClass value indicates that each interface specifies its + * own class information and all interfaces operate independently. + */ + LIBUSB_CLASS_PER_INTERFACE = 0, + + /** Audio class */ + LIBUSB_CLASS_AUDIO = 1, + + /** Communications class */ + LIBUSB_CLASS_COMM = 2, + + /** Human Interface Device class */ + LIBUSB_CLASS_HID = 3, + + /** Printer dclass */ + LIBUSB_CLASS_PRINTER = 7, + + /** Picture transfer protocol class */ + LIBUSB_CLASS_PTP = 6, + + /** Mass storage class */ + LIBUSB_CLASS_MASS_STORAGE = 8, + + /** Hub class */ + LIBUSB_CLASS_HUB = 9, + + /** Data class */ + LIBUSB_CLASS_DATA = 10, + + /** Wireless class */ + LIBUSB_CLASS_WIRELESS = 0xe0, + + /** Application class */ + LIBUSB_CLASS_APPLICATION = 0xfe, + + /** Class is vendor-specific */ + LIBUSB_CLASS_VENDOR_SPEC = 0xff +}; + +/** \ingroup desc + * Descriptor types as defined by the USB specification. */ +enum libusb_descriptor_type { + /** Device descriptor. See libusb_device_descriptor. */ + LIBUSB_DT_DEVICE = 0x01, + + /** Configuration descriptor. See libusb_config_descriptor. */ + LIBUSB_DT_CONFIG = 0x02, + + /** String descriptor */ + LIBUSB_DT_STRING = 0x03, + + /** Interface descriptor. See libusb_interface_descriptor. */ + LIBUSB_DT_INTERFACE = 0x04, + + /** Endpoint descriptor. See libusb_endpoint_descriptor. */ + LIBUSB_DT_ENDPOINT = 0x05, + + /** HID descriptor */ + LIBUSB_DT_HID = 0x21, + + /** HID report descriptor */ + LIBUSB_DT_REPORT = 0x22, + + /** Physical descriptor */ + LIBUSB_DT_PHYSICAL = 0x23, + + /** Hub descriptor */ + LIBUSB_DT_HUB = 0x29 +}; + +/* Descriptor sizes per descriptor type */ +#define LIBUSB_DT_DEVICE_SIZE 18 +#define LIBUSB_DT_CONFIG_SIZE 9 +#define LIBUSB_DT_INTERFACE_SIZE 9 +#define LIBUSB_DT_ENDPOINT_SIZE 7 +#define LIBUSB_DT_ENDPOINT_AUDIO_SIZE 9 /* Audio extension */ +#define LIBUSB_DT_HUB_NONVAR_SIZE 7 + +#define LIBUSB_ENDPOINT_ADDRESS_MASK 0x0f /* in bEndpointAddress */ +#define LIBUSB_ENDPOINT_DIR_MASK 0x80 + +/** \ingroup desc + * Endpoint direction. Values for bit 7 of the + * \ref libusb_endpoint_descriptor::bEndpointAddress "endpoint address" scheme. + */ +enum libusb_endpoint_direction { + /** In: device-to-host */ + LIBUSB_ENDPOINT_IN = 0x80, + + /** Out: host-to-device */ + LIBUSB_ENDPOINT_OUT = 0x00 +}; + +#define LIBUSB_TRANSFER_TYPE_MASK 0x03 /* in bmAttributes */ + +/** \ingroup desc + * Endpoint transfer type. Values for bits 0:1 of the + * \ref libusb_endpoint_descriptor::bmAttributes "endpoint attributes" field. + */ +enum libusb_transfer_type { + /** Control endpoint */ + LIBUSB_TRANSFER_TYPE_CONTROL = 0, + + /** Isochronous endpoint */ + LIBUSB_TRANSFER_TYPE_ISOCHRONOUS = 1, + + /** Bulk endpoint */ + LIBUSB_TRANSFER_TYPE_BULK = 2, + + /** Interrupt endpoint */ + LIBUSB_TRANSFER_TYPE_INTERRUPT = 3 +}; + +/** \ingroup misc + * Standard requests, as defined in table 9-3 of the USB2 specifications */ +enum libusb_standard_request { + /** Request status of the specific recipient */ + LIBUSB_REQUEST_GET_STATUS = 0x00, + + /** Clear or disable a specific feature */ + LIBUSB_REQUEST_CLEAR_FEATURE = 0x01, + + /* 0x02 is reserved */ + + /** Set or enable a specific feature */ + LIBUSB_REQUEST_SET_FEATURE = 0x03, + + /* 0x04 is reserved */ + + /** Set device address for all future accesses */ + LIBUSB_REQUEST_SET_ADDRESS = 0x05, + + /** Get the specified descriptor */ + LIBUSB_REQUEST_GET_DESCRIPTOR = 0x06, + + /** Used to update existing descriptors or add new descriptors */ + LIBUSB_REQUEST_SET_DESCRIPTOR = 0x07, + + /** Get the current device configuration value */ + LIBUSB_REQUEST_GET_CONFIGURATION = 0x08, + + /** Set device configuration */ + LIBUSB_REQUEST_SET_CONFIGURATION = 0x09, + + /** Return the selected alternate setting for the specified interface */ + LIBUSB_REQUEST_GET_INTERFACE = 0x0A, + + /** Select an alternate interface for the specified interface */ + LIBUSB_REQUEST_SET_INTERFACE = 0x0B, + + /** Set then report an endpoint's synchronization frame */ + LIBUSB_REQUEST_SYNCH_FRAME = 0x0C +}; + +/** \ingroup misc + * Request type bits of the + * \ref libusb_control_setup::bmRequestType "bmRequestType" field in control + * transfers. */ +enum libusb_request_type { + /** Standard */ + LIBUSB_REQUEST_TYPE_STANDARD = (0x00 << 5), + + /** Class */ + LIBUSB_REQUEST_TYPE_CLASS = (0x01 << 5), + + /** Vendor */ + LIBUSB_REQUEST_TYPE_VENDOR = (0x02 << 5), + + /** Reserved */ + LIBUSB_REQUEST_TYPE_RESERVED = (0x03 << 5) +}; + +/** \ingroup misc + * Recipient bits of the + * \ref libusb_control_setup::bmRequestType "bmRequestType" field in control + * transfers. Values 4 through 31 are reserved. */ +enum libusb_request_recipient { + /** Device */ + LIBUSB_RECIPIENT_DEVICE = 0x00, + + /** Interface */ + LIBUSB_RECIPIENT_INTERFACE = 0x01, + + /** Endpoint */ + LIBUSB_RECIPIENT_ENDPOINT = 0x02, + + /** Other */ + LIBUSB_RECIPIENT_OTHER = 0x03 +}; + +#define LIBUSB_ISO_SYNC_TYPE_MASK 0x0C + +/** \ingroup desc + * Synchronization type for isochronous endpoints. Values for bits 2:3 of the + * \ref libusb_endpoint_descriptor::bmAttributes "bmAttributes" field in + * libusb_endpoint_descriptor. + */ +enum libusb_iso_sync_type { + /** No synchronization */ + LIBUSB_ISO_SYNC_TYPE_NONE = 0, + + /** Asynchronous */ + LIBUSB_ISO_SYNC_TYPE_ASYNC = 1, + + /** Adaptive */ + LIBUSB_ISO_SYNC_TYPE_ADAPTIVE = 2, + + /** Synchronous */ + LIBUSB_ISO_SYNC_TYPE_SYNC = 3 +}; + +#define LIBUSB_ISO_USAGE_TYPE_MASK 0x30 + +/** \ingroup desc + * Usage type for isochronous endpoints. Values for bits 4:5 of the + * \ref libusb_endpoint_descriptor::bmAttributes "bmAttributes" field in + * libusb_endpoint_descriptor. + */ +enum libusb_iso_usage_type { + /** Data endpoint */ + LIBUSB_ISO_USAGE_TYPE_DATA = 0, + + /** Feedback endpoint */ + LIBUSB_ISO_USAGE_TYPE_FEEDBACK = 1, + + /** Implicit feedback Data endpoint */ + LIBUSB_ISO_USAGE_TYPE_IMPLICIT = 2 +}; + +/** \ingroup desc + * A structure representing the standard USB device descriptor. This + * descriptor is documented in section 9.6.1 of the USB 2.0 specification. + * All multiple-byte fields are represented in host-endian format. + */ +struct libusb_device_descriptor { + /** Size of this descriptor (in bytes) */ + uint8_t bLength; + + /** Descriptor type. Will have value + * \ref libusb_descriptor_type::LIBUSB_DT_DEVICE LIBUSB_DT_DEVICE in this + * context. */ + uint8_t bDescriptorType; + + /** USB specification release number in binary-coded decimal. A value of + * 0x0200 indicates USB 2.0, 0x0110 indicates USB 1.1, etc. */ + uint16_t bcdUSB; + + /** USB-IF class code for the device. See \ref libusb_class_code. */ + uint8_t bDeviceClass; + + /** USB-IF subclass code for the device, qualified by the bDeviceClass + * value */ + uint8_t bDeviceSubClass; + + /** USB-IF protocol code for the device, qualified by the bDeviceClass and + * bDeviceSubClass values */ + uint8_t bDeviceProtocol; + + /** Maximum packet size for endpoint 0 */ + uint8_t bMaxPacketSize0; + + /** USB-IF vendor ID */ + uint16_t idVendor; + + /** USB-IF product ID */ + uint16_t idProduct; + + /** Device release number in binary-coded decimal */ + uint16_t bcdDevice; + + /** Index of string descriptor describing manufacturer */ + uint8_t iManufacturer; + + /** Index of string descriptor describing product */ + uint8_t iProduct; + + /** Index of string descriptor containing device serial number */ + uint8_t iSerialNumber; + + /** Number of possible configurations */ + uint8_t bNumConfigurations; +}; + +/** \ingroup desc + * A structure representing the standard USB endpoint descriptor. This + * descriptor is documented in section 9.6.3 of the USB 2.0 specification. + * All multiple-byte fields are represented in host-endian format. + */ +struct libusb_endpoint_descriptor { + /** Size of this descriptor (in bytes) */ + uint8_t bLength; + + /** Descriptor type. Will have value + * \ref libusb_descriptor_type::LIBUSB_DT_ENDPOINT LIBUSB_DT_ENDPOINT in + * this context. */ + uint8_t bDescriptorType; + + /** The address of the endpoint described by this descriptor. Bits 0:3 are + * the endpoint number. Bits 4:6 are reserved. Bit 7 indicates direction, + * see \ref libusb_endpoint_direction. + */ + uint8_t bEndpointAddress; + + /** Attributes which apply to the endpoint when it is configured using + * the bConfigurationValue. Bits 0:1 determine the transfer type and + * correspond to \ref libusb_transfer_type. Bits 2:3 are only used for + * isochronous endpoints and correspond to \ref libusb_iso_sync_type. + * Bits 4:5 are also only used for isochronous endpoints and correspond to + * \ref libusb_iso_usage_type. Bits 6:7 are reserved. + */ + uint8_t bmAttributes; + + /** Maximum packet size this endpoint is capable of sending/receiving. */ + uint16_t wMaxPacketSize; + + /** Interval for polling endpoint for data transfers. */ + uint8_t bInterval; + + /** For audio devices only: the rate at which synchronization feedback + * is provided. */ + uint8_t bRefresh; + + /** For audio devices only: the address if the synch endpoint */ + uint8_t bSynchAddress; + + /** Extra descriptors. If libusb encounters unknown endpoint descriptors, + * it will store them here, should you wish to parse them. */ + const unsigned char *extra; + + /** Length of the extra descriptors, in bytes. */ + int extra_length; +}; + +/** \ingroup desc + * A structure representing the standard USB interface descriptor. This + * descriptor is documented in section 9.6.5 of the USB 2.0 specification. + * All multiple-byte fields are represented in host-endian format. + */ +struct libusb_interface_descriptor { + /** Size of this descriptor (in bytes) */ + uint8_t bLength; + + /** Descriptor type. Will have value + * \ref libusb_descriptor_type::LIBUSB_DT_INTERFACE LIBUSB_DT_INTERFACE + * in this context. */ + uint8_t bDescriptorType; + + /** Number of this interface */ + uint8_t bInterfaceNumber; + + /** Value used to select this alternate setting for this interface */ + uint8_t bAlternateSetting; + + /** Number of endpoints used by this interface (excluding the control + * endpoint). */ + uint8_t bNumEndpoints; + + /** USB-IF class code for this interface. See \ref libusb_class_code. */ + uint8_t bInterfaceClass; + + /** USB-IF subclass code for this interface, qualified by the + * bInterfaceClass value */ + uint8_t bInterfaceSubClass; + + /** USB-IF protocol code for this interface, qualified by the + * bInterfaceClass and bInterfaceSubClass values */ + uint8_t bInterfaceProtocol; + + /** Index of string descriptor describing this interface */ + uint8_t iInterface; + + /** Array of endpoint descriptors. This length of this array is determined + * by the bNumEndpoints field. */ + const struct libusb_endpoint_descriptor *endpoint; + + /** Extra descriptors. If libusb encounters unknown interface descriptors, + * it will store them here, should you wish to parse them. */ + const unsigned char *extra; + + /** Length of the extra descriptors, in bytes. */ + int extra_length; +}; + +/** \ingroup desc + * A collection of alternate settings for a particular USB interface. + */ +struct libusb_interface { + /** Array of interface descriptors. The length of this array is determined + * by the num_altsetting field. */ + const struct libusb_interface_descriptor *altsetting; + + /** The number of alternate settings that belong to this interface */ + int num_altsetting; +}; + +/** \ingroup desc + * A structure representing the standard USB configuration descriptor. This + * descriptor is documented in section 9.6.3 of the USB 2.0 specification. + * All multiple-byte fields are represented in host-endian format. + */ +struct libusb_config_descriptor { + /** Size of this descriptor (in bytes) */ + uint8_t bLength; + + /** Descriptor type. Will have value + * \ref libusb_descriptor_type::LIBUSB_DT_CONFIG LIBUSB_DT_CONFIG + * in this context. */ + uint8_t bDescriptorType; + + /** Total length of data returned for this configuration */ + uint16_t wTotalLength; + + /** Number of interfaces supported by this configuration */ + uint8_t bNumInterfaces; + + /** Identifier value for this configuration */ + uint8_t bConfigurationValue; + + /** Index of string descriptor describing this configuration */ + uint8_t iConfiguration; + + /** Configuration characteristics */ + uint8_t bmAttributes; + + /** Maximum power consumption of the USB device from this bus in this + * configuration when the device is fully opreation. Expressed in units + * of 2 mA. */ + uint8_t MaxPower; + + /** Array of interfaces supported by this configuration. The length of + * this array is determined by the bNumInterfaces field. */ + const struct libusb_interface *interface; + + /** Extra descriptors. If libusb encounters unknown configuration + * descriptors, it will store them here, should you wish to parse them. */ + const unsigned char *extra; + + /** Length of the extra descriptors, in bytes. */ + int extra_length; +}; + +/** \ingroup asyncio + * Setup packet for control transfers. */ +struct libusb_control_setup { + /** Request type. Bits 0:4 determine recipient, see + * \ref libusb_request_recipient. Bits 5:6 determine type, see + * \ref libusb_request_type. Bit 7 determines data transfer direction, see + * \ref libusb_endpoint_direction. + */ + uint8_t bmRequestType; + + /** Request. If the type bits of bmRequestType are equal to + * \ref libusb_request_type::LIBUSB_REQUEST_TYPE_STANDARD + * "LIBUSB_REQUEST_TYPE_STANDARD" then this field refers to + * \ref libusb_standard_request. For other cases, use of this field is + * application-specific. */ + uint8_t bRequest; + + /** Value. Varies according to request */ + uint16_t wValue; + + /** Index. Varies according to request, typically used to pass an index + * or offset */ + uint16_t wIndex; + + /** Number of bytes to transfer */ + uint16_t wLength; +}; + +#define LIBUSB_CONTROL_SETUP_SIZE (sizeof(struct libusb_control_setup)) + +/* libusb */ + +struct libusb_context; +struct libusb_device; +struct libusb_device_handle; + +/** \ingroup lib + * Structure providing the version of libusb being used + */ +struct libusb_version { + uint16_t major; + uint16_t minor; + uint16_t micro; + uint16_t nano; +}; + +/** \ingroup lib + * Structure representing a libusb session. The concept of individual libusb + * sessions allows for your program to use two libraries (or dynamically + * load two modules) which both independently use libusb. This will prevent + * interference between the individual libusb users - for example + * libusb_set_debug() will not affect the other user of the library, and + * libusb_exit() will not destroy resources that the other user is still + * using. + * + * Sessions are created by libusb_init() and destroyed through libusb_exit(). + * 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. + * + * For more information, see \ref contexts. + */ +typedef struct libusb_context libusb_context; + +/** \ingroup dev + * 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 libusb_get_device_list(). + * + * 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 libusb_open(). + * + * Devices are reference counted with libusb_device_ref() and + * libusb_device_unref(), and are freed when the reference count reaches 0. + * New devices presented by libusb_get_device_list() have a reference count of + * 1, and libusb_free_device_list() can optionally decrease the reference count + * on all devices in the list. libusb_open() adds another reference which is + * later destroyed by libusb_close(). + */ +typedef struct libusb_device libusb_device; + + +/** \ingroup dev + * 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 + * libusb_open(). + * + * A device handle is used to perform I/O and other operations. When finished + * with a device handle, you should call libusb_close(). + */ +typedef struct libusb_device_handle libusb_device_handle; + + +/** \ingroup misc + * Error codes. Most libusb functions return 0 on success or one of these + * codes on failure. + * You can use libusb_strerror() to retrieve a short string description of + * a libusb_error enumeration value. + */ +enum libusb_error { + /** Success (no error) */ + LIBUSB_SUCCESS = 0, + + /** Input/output error */ + LIBUSB_ERROR_IO = -1, + + /** Invalid parameter */ + LIBUSB_ERROR_INVALID_PARAM = -2, + + /** Access denied (insufficient permissions) */ + LIBUSB_ERROR_ACCESS = -3, + + /** No such device (it may have been disconnected) */ + LIBUSB_ERROR_NO_DEVICE = -4, + + /** Entity not found */ + LIBUSB_ERROR_NOT_FOUND = -5, + + /** Resource busy */ + LIBUSB_ERROR_BUSY = -6, + + /** Operation timed out */ + LIBUSB_ERROR_TIMEOUT = -7, + + /** Overflow */ + LIBUSB_ERROR_OVERFLOW = -8, + + /** Pipe error */ + LIBUSB_ERROR_PIPE = -9, + + /** System call interrupted (perhaps due to signal) */ + LIBUSB_ERROR_INTERRUPTED = -10, + + /** Insufficient memory */ + LIBUSB_ERROR_NO_MEM = -11, + + /** Operation not supported or unimplemented on this platform */ + LIBUSB_ERROR_NOT_SUPPORTED = -12, + + /** Other error */ + LIBUSB_ERROR_OTHER = -99 + + /* IMPORTANT: when adding new values to this enum, remember to + update the libusb_strerror() function implementation! */ +}; + +/** \ingroup asyncio + * Transfer status codes */ +enum libusb_transfer_status { + /** Transfer completed without error. Note that this does not indicate + * that the entire amount of requested data was transferred. */ + LIBUSB_TRANSFER_COMPLETED, + + /** Transfer failed */ + LIBUSB_TRANSFER_ERROR, + + /** Transfer timed out */ + LIBUSB_TRANSFER_TIMED_OUT, + + /** Transfer was cancelled */ + LIBUSB_TRANSFER_CANCELLED, + + /** For bulk/interrupt endpoints: halt condition detected (endpoint + * stalled). For control endpoints: control request not supported. */ + LIBUSB_TRANSFER_STALL, + + /** Device was disconnected */ + LIBUSB_TRANSFER_NO_DEVICE, + + /** Device sent more data than requested */ + LIBUSB_TRANSFER_OVERFLOW +}; + +/** \ingroup asyncio + * libusb_transfer.flags values */ +enum libusb_transfer_flags { + /** Report short frames as errors */ + LIBUSB_TRANSFER_SHORT_NOT_OK = 1<<0, + + /** Automatically free() transfer buffer during libusb_free_transfer() */ + LIBUSB_TRANSFER_FREE_BUFFER = 1<<1, + + /** Automatically call libusb_free_transfer() after callback returns. + * If this flag is set, it is illegal to call libusb_free_transfer() + * from your transfer callback, as this will result in a double-free + * when this flag is acted upon. */ + LIBUSB_TRANSFER_FREE_TRANSFER = 1<<2 +}; + +/** \ingroup asyncio + * Isochronous packet descriptor. */ +struct libusb_iso_packet_descriptor { + /** Length of data to request in this packet */ + unsigned int length; + + /** Amount of data that was actually transferred */ + unsigned int actual_length; + + /** Status code for this packet */ + enum libusb_transfer_status status; +}; + +struct libusb_transfer; + +/** \ingroup asyncio + * Asynchronous transfer callback function type. When submitting asynchronous + * transfers, you pass a pointer to a callback function of this type via the + * \ref libusb_transfer::callback "callback" member of the libusb_transfer + * structure. libusb will call this function later, when the transfer has + * completed or failed. See \ref asyncio for more information. + * \param transfer The libusb_transfer struct the callback function is being + * notified about. + */ +typedef void (LIBUSB_CALL *libusb_transfer_cb_fn)(struct libusb_transfer *transfer); + +/** \ingroup asyncio + * 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. + */ +struct libusb_transfer { + /** Handle of the device that this transfer will be submitted to */ + libusb_device_handle *dev_handle; + + /** A bitwise OR combination of \ref libusb_transfer_flags. */ + uint8_t flags; + + /** Address of the endpoint where this transfer will be sent. */ + unsigned char endpoint; + + /** Type of the endpoint from \ref libusb_transfer_type */ + unsigned char type; + + /** Timeout for this transfer in millseconds. A value of 0 indicates no + * timeout. */ + unsigned int timeout; + + /** 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 COMPLETED even + * if there were errors in the frames. Use the + * \ref libusb_iso_packet_descriptor::status "status" field in each packet + * to determine if errors occurred. */ + enum libusb_transfer_status status; + + /** Length of the data buffer */ + int length; + + /** Actual length of data that was transferred. Read-only, and only for + * use within transfer callback function. Not valid for isochronous + * endpoint transfers. */ + int actual_length; + + /** Callback function. This will be invoked when the transfer completes, + * fails, or is cancelled. */ + libusb_transfer_cb_fn callback; + + /** User context data to pass to the callback function. */ + void *user_data; + + /** Data buffer */ + unsigned char *buffer; + + /** Number of isochronous packets. Only used for I/O with isochronous + * endpoints. */ + int num_iso_packets; + + /** Isochronous packet descriptors, for isochronous transfers only. */ + struct libusb_iso_packet_descriptor iso_packet_desc +#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) + [] /* valid C99 code */ +#else + [0] /* non-standard, but usually working code */ +#endif + ; +}; + +int LIBUSB_CALL libusb_init(libusb_context **ctx); +void LIBUSB_CALL libusb_exit(libusb_context *ctx); +void LIBUSB_CALL libusb_set_debug(libusb_context *ctx, int level); +const char * LIBUSB_CALL libusb_strerror(enum libusb_error errcode); +const struct libusb_version * LIBUSB_CALL libusb_getversion(void); + +ssize_t LIBUSB_CALL libusb_get_device_list(libusb_context *ctx, + libusb_device ***list); +void LIBUSB_CALL libusb_free_device_list(libusb_device **list, + int unref_devices); +libusb_device * LIBUSB_CALL libusb_ref_device(libusb_device *dev); +void LIBUSB_CALL libusb_unref_device(libusb_device *dev); + +int LIBUSB_CALL libusb_get_configuration(libusb_device_handle *dev, + int *config); +int LIBUSB_CALL libusb_get_device_descriptor(libusb_device *dev, + struct libusb_device_descriptor *desc); +int LIBUSB_CALL libusb_get_active_config_descriptor(libusb_device *dev, + struct libusb_config_descriptor **config); +int LIBUSB_CALL libusb_get_config_descriptor(libusb_device *dev, + uint8_t config_index, struct libusb_config_descriptor **config); +int LIBUSB_CALL libusb_get_config_descriptor_by_value(libusb_device *dev, + uint8_t bConfigurationValue, struct libusb_config_descriptor **config); +void LIBUSB_CALL libusb_free_config_descriptor( + struct libusb_config_descriptor *config); +uint8_t LIBUSB_CALL libusb_get_bus_number(libusb_device *dev); +uint8_t LIBUSB_CALL libusb_get_port_number(libusb_device *dev); +libusb_device * LIBUSB_CALL libusb_get_parent(libusb_device *dev); +int LIBUSB_CALL libusb_get_port_path(libusb_context *ctx, libusb_device *dev, uint8_t* path, uint8_t path_length); +uint8_t LIBUSB_CALL libusb_get_device_address(libusb_device *dev); +int LIBUSB_CALL libusb_get_max_packet_size(libusb_device *dev, + unsigned char endpoint); +int LIBUSB_CALL libusb_get_max_iso_packet_size(libusb_device *dev, + unsigned char endpoint); + +int LIBUSB_CALL libusb_open(libusb_device *dev, libusb_device_handle **handle); +void LIBUSB_CALL libusb_close(libusb_device_handle *dev_handle); +libusb_device * LIBUSB_CALL libusb_get_device(libusb_device_handle *dev_handle); + +int LIBUSB_CALL libusb_set_configuration(libusb_device_handle *dev, + int configuration); +int LIBUSB_CALL libusb_claim_interface(libusb_device_handle *dev, + int interface_number); +int LIBUSB_CALL libusb_release_interface(libusb_device_handle *dev, + int interface_number); + +libusb_device_handle * LIBUSB_CALL libusb_open_device_with_vid_pid( + libusb_context *ctx, uint16_t vendor_id, uint16_t product_id); + +int LIBUSB_CALL libusb_set_interface_alt_setting(libusb_device_handle *dev, + int interface_number, int alternate_setting); +int LIBUSB_CALL libusb_clear_halt(libusb_device_handle *dev, + unsigned char endpoint); +int LIBUSB_CALL libusb_reset_device(libusb_device_handle *dev); + +int LIBUSB_CALL libusb_kernel_driver_active(libusb_device_handle *dev, + int interface_number); +int LIBUSB_CALL libusb_detach_kernel_driver(libusb_device_handle *dev, + int interface_number); +int LIBUSB_CALL libusb_attach_kernel_driver(libusb_device_handle *dev, + int interface_number); + +/* async I/O */ + +/** \ingroup asyncio + * Get the data section of a control transfer. This convenience function is here + * to remind you that the data does not start until 8 bytes into the actual + * buffer, as the setup packet comes first. + * + * Calling this function only makes sense from a transfer callback function, + * or situations where you have already allocated a suitably sized buffer at + * transfer->buffer. + * + * \param transfer a transfer + * \returns pointer to the first byte of the data section + */ +static inline unsigned char *libusb_control_transfer_get_data( + struct libusb_transfer *transfer) +{ + return transfer->buffer + LIBUSB_CONTROL_SETUP_SIZE; +} + +/** \ingroup asyncio + * Get the control setup packet of a control transfer. This convenience + * function is here to remind you that the control setup occupies the first + * 8 bytes of the transfer data buffer. + * + * Calling this function only makes sense from a transfer callback function, + * or situations where you have already allocated a suitably sized buffer at + * transfer->buffer. + * + * \param transfer a transfer + * \returns a casted pointer to the start of the transfer data buffer + */ +static inline struct libusb_control_setup *libusb_control_transfer_get_setup( + struct libusb_transfer *transfer) +{ + return (struct libusb_control_setup *) transfer->buffer; +} + +/** \ingroup asyncio + * Helper function to populate the setup packet (first 8 bytes of the data + * buffer) for a control transfer. The wIndex, wValue and wLength values should + * be given in host-endian byte order. + * + * \param buffer buffer to output the setup packet into + * \param bmRequestType see the + * \ref libusb_control_setup::bmRequestType "bmRequestType" field of + * \ref libusb_control_setup + * \param bRequest see the + * \ref libusb_control_setup::bRequest "bRequest" field of + * \ref libusb_control_setup + * \param wValue see the + * \ref libusb_control_setup::wValue "wValue" field of + * \ref libusb_control_setup + * \param wIndex see the + * \ref libusb_control_setup::wIndex "wIndex" field of + * \ref libusb_control_setup + * \param wLength see the + * \ref libusb_control_setup::wLength "wLength" field of + * \ref libusb_control_setup + */ +static inline void libusb_fill_control_setup(unsigned char *buffer, + uint8_t bmRequestType, uint8_t bRequest, uint16_t wValue, uint16_t wIndex, + uint16_t wLength) +{ + struct libusb_control_setup *setup = (struct libusb_control_setup *) buffer; + setup->bmRequestType = bmRequestType; + setup->bRequest = bRequest; + setup->wValue = libusb_cpu_to_le16(wValue); + setup->wIndex = libusb_cpu_to_le16(wIndex); + setup->wLength = libusb_cpu_to_le16(wLength); +} + +struct libusb_transfer * LIBUSB_CALL libusb_alloc_transfer(int iso_packets); +int LIBUSB_CALL libusb_submit_transfer(struct libusb_transfer *transfer); +int LIBUSB_CALL libusb_cancel_transfer(struct libusb_transfer *transfer); +void LIBUSB_CALL libusb_free_transfer(struct libusb_transfer *transfer); + +/** \ingroup asyncio + * Helper function to populate the required \ref libusb_transfer fields + * for a control transfer. + * + * If you pass a transfer buffer to this function, the first 8 bytes will + * be interpreted as a control setup packet, and the wLength field will be + * used to automatically populate the \ref libusb_transfer::length "length" + * field of the transfer. Therefore the recommended approach is: + * -# Allocate a suitably sized data buffer (including space for control setup) + * -# Call libusb_fill_control_setup() + * -# If this is a host-to-device transfer with a data stage, put the data + * in place after the setup packet + * -# Call this function + * -# Call libusb_submit_transfer() + * + * It is also legal to pass a NULL buffer to this function, in which case this + * function will not attempt to populate the length field. Remember that you + * must then populate the buffer and length fields later. + * + * \param transfer the transfer to populate + * \param dev_handle handle of the device that will handle the transfer + * \param buffer data buffer. If provided, this function will interpret the + * first 8 bytes as a setup packet and infer the transfer length from that. + * \param callback callback function to be invoked on transfer completion + * \param user_data user data to pass to callback function + * \param timeout timeout for the transfer in milliseconds + */ +static inline void libusb_fill_control_transfer( + struct libusb_transfer *transfer, libusb_device_handle *dev_handle, + unsigned char *buffer, libusb_transfer_cb_fn callback, void *user_data, + unsigned int timeout) +{ + struct libusb_control_setup *setup = (struct libusb_control_setup *) buffer; + transfer->dev_handle = dev_handle; + transfer->endpoint = 0; + transfer->type = LIBUSB_TRANSFER_TYPE_CONTROL; + transfer->timeout = timeout; + transfer->buffer = buffer; + if (setup) + transfer->length = LIBUSB_CONTROL_SETUP_SIZE + + libusb_le16_to_cpu(setup->wLength); + transfer->user_data = user_data; + transfer->callback = callback; +} + +/** \ingroup asyncio + * Helper function to populate the required \ref libusb_transfer fields + * for a bulk transfer. + * + * \param transfer the transfer to populate + * \param dev_handle handle of the device that will handle the transfer + * \param endpoint address of the endpoint where this transfer will be sent + * \param buffer data buffer + * \param length length of data buffer + * \param callback callback function to be invoked on transfer completion + * \param user_data user data to pass to callback function + * \param timeout timeout for the transfer in milliseconds + */ +static inline void libusb_fill_bulk_transfer(struct libusb_transfer *transfer, + libusb_device_handle *dev_handle, unsigned char endpoint, + unsigned char *buffer, int length, libusb_transfer_cb_fn callback, + void *user_data, unsigned int timeout) +{ + transfer->dev_handle = dev_handle; + transfer->endpoint = endpoint; + transfer->type = LIBUSB_TRANSFER_TYPE_BULK; + transfer->timeout = timeout; + transfer->buffer = buffer; + transfer->length = length; + transfer->user_data = user_data; + transfer->callback = callback; +} + +/** \ingroup asyncio + * Helper function to populate the required \ref libusb_transfer fields + * for an interrupt transfer. + * + * \param transfer the transfer to populate + * \param dev_handle handle of the device that will handle the transfer + * \param endpoint address of the endpoint where this transfer will be sent + * \param buffer data buffer + * \param length length of data buffer + * \param callback callback function to be invoked on transfer completion + * \param user_data user data to pass to callback function + * \param timeout timeout for the transfer in milliseconds + */ +static inline void libusb_fill_interrupt_transfer( + struct libusb_transfer *transfer, libusb_device_handle *dev_handle, + unsigned char endpoint, unsigned char *buffer, int length, + libusb_transfer_cb_fn callback, void *user_data, unsigned int timeout) +{ + transfer->dev_handle = dev_handle; + transfer->endpoint = endpoint; + transfer->type = LIBUSB_TRANSFER_TYPE_INTERRUPT; + transfer->timeout = timeout; + transfer->buffer = buffer; + transfer->length = length; + transfer->user_data = user_data; + transfer->callback = callback; +} + +/** \ingroup asyncio + * Helper function to populate the required \ref libusb_transfer fields + * for an isochronous transfer. + * + * \param transfer the transfer to populate + * \param dev_handle handle of the device that will handle the transfer + * \param endpoint address of the endpoint where this transfer will be sent + * \param buffer data buffer + * \param length length of data buffer + * \param num_iso_packets the number of isochronous packets + * \param callback callback function to be invoked on transfer completion + * \param user_data user data to pass to callback function + * \param timeout timeout for the transfer in milliseconds + */ +static inline void libusb_fill_iso_transfer(struct libusb_transfer *transfer, + libusb_device_handle *dev_handle, unsigned char endpoint, + unsigned char *buffer, int length, int num_iso_packets, + libusb_transfer_cb_fn callback, void *user_data, unsigned int timeout) +{ + transfer->dev_handle = dev_handle; + transfer->endpoint = endpoint; + transfer->type = LIBUSB_TRANSFER_TYPE_ISOCHRONOUS; + transfer->timeout = timeout; + transfer->buffer = buffer; + transfer->length = length; + transfer->num_iso_packets = num_iso_packets; + transfer->user_data = user_data; + transfer->callback = callback; +} + +/** \ingroup asyncio + * Convenience function to set the length of all packets in an isochronous + * transfer, based on the num_iso_packets field in the transfer structure. + * + * \param transfer a transfer + * \param length the length to set in each isochronous packet descriptor + * \see libusb_get_max_packet_size() + */ +static inline void libusb_set_iso_packet_lengths( + struct libusb_transfer *transfer, unsigned int length) +{ + int i; + for (i = 0; i < transfer->num_iso_packets; i++) + transfer->iso_packet_desc[i].length = length; +} + +/** \ingroup asyncio + * Convenience function to locate the position of an isochronous packet + * within the buffer of an isochronous transfer. + * + * This is a thorough function which loops through all preceding packets, + * accumulating their lengths to find the position of the specified packet. + * Typically you will assign equal lengths to each packet in the transfer, + * and hence the above method is sub-optimal. You may wish to use + * libusb_get_iso_packet_buffer_simple() instead. + * + * \param transfer a transfer + * \param packet the packet to return the address of + * \returns the base address of the packet buffer inside the transfer buffer, + * or NULL if the packet does not exist. + * \see libusb_get_iso_packet_buffer_simple() + */ +static inline unsigned char *libusb_get_iso_packet_buffer( + struct libusb_transfer *transfer, unsigned int packet) +{ + int i; + size_t offset = 0; + int _packet; + + /* oops..slight bug in the API. packet is an unsigned int, but we use + * signed integers almost everywhere else. range-check and convert to + * signed to avoid compiler warnings. FIXME for libusb-2. */ + if (packet > INT_MAX) + return NULL; + _packet = packet; + + if (_packet >= transfer->num_iso_packets) + return NULL; + + for (i = 0; i < _packet; i++) + offset += transfer->iso_packet_desc[i].length; + + return transfer->buffer + offset; +} + +/** \ingroup asyncio + * Convenience function to locate the position of an isochronous packet + * within the buffer of an isochronous transfer, for transfers where each + * packet is of identical size. + * + * This function relies on the assumption that every packet within the transfer + * is of identical size to the first packet. Calculating the location of + * the packet buffer is then just a simple calculation: + * buffer + (packet_size * packet) + * + * Do not use this function on transfers other than those that have identical + * packet lengths for each packet. + * + * \param transfer a transfer + * \param packet the packet to return the address of + * \returns the base address of the packet buffer inside the transfer buffer, + * or NULL if the packet does not exist. + * \see libusb_get_iso_packet_buffer() + */ +static inline unsigned char *libusb_get_iso_packet_buffer_simple( + struct libusb_transfer *transfer, unsigned int packet) +{ + int _packet; + + /* oops..slight bug in the API. packet is an unsigned int, but we use + * signed integers almost everywhere else. range-check and convert to + * signed to avoid compiler warnings. FIXME for libusb-2. */ + if (packet > INT_MAX) + return NULL; + _packet = packet; + + if (_packet >= transfer->num_iso_packets) + return NULL; + + return transfer->buffer + (transfer->iso_packet_desc[0].length * _packet); +} + +/* sync I/O */ + +int LIBUSB_CALL libusb_control_transfer(libusb_device_handle *dev_handle, + uint8_t request_type, uint8_t bRequest, uint16_t wValue, uint16_t wIndex, + unsigned char *data, uint16_t wLength, unsigned int timeout); + +int LIBUSB_CALL libusb_bulk_transfer(libusb_device_handle *dev_handle, + unsigned char endpoint, unsigned char *data, int length, + int *actual_length, unsigned int timeout); + +int LIBUSB_CALL libusb_interrupt_transfer(libusb_device_handle *dev_handle, + unsigned char endpoint, unsigned char *data, int length, + int *actual_length, unsigned int timeout); + +/** \ingroup desc + * Retrieve a descriptor from the default control pipe. + * This is a convenience function which formulates the appropriate control + * message to retrieve the descriptor. + * + * \param dev a device handle + * \param desc_type the descriptor type, see \ref libusb_descriptor_type + * \param desc_index the index of the descriptor to retrieve + * \param data output buffer for descriptor + * \param length size of data buffer + * \returns number of bytes returned in data, or LIBUSB_ERROR code on failure + */ +static inline int libusb_get_descriptor(libusb_device_handle *dev, + uint8_t desc_type, uint8_t desc_index, unsigned char *data, int length) +{ + return libusb_control_transfer(dev, LIBUSB_ENDPOINT_IN, + LIBUSB_REQUEST_GET_DESCRIPTOR, (desc_type << 8) | desc_index, 0, data, + (uint16_t) length, 1000); +} + +/** \ingroup desc + * 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 dev a device handle + * \param desc_index the index of the descriptor to retrieve + * \param langid the language ID for the string descriptor + * \param data output buffer for descriptor + * \param length size of data buffer + * \returns number of bytes returned in data, or LIBUSB_ERROR code on failure + * \see libusb_get_string_descriptor_ascii() + */ +static inline int libusb_get_string_descriptor(libusb_device_handle *dev, + uint8_t desc_index, uint16_t langid, unsigned char *data, int length) +{ + return libusb_control_transfer(dev, LIBUSB_ENDPOINT_IN, + LIBUSB_REQUEST_GET_DESCRIPTOR, (LIBUSB_DT_STRING << 8) | desc_index, + langid, data, (uint16_t) length, 1000); +} + +int LIBUSB_CALL libusb_get_string_descriptor_ascii(libusb_device_handle *dev, + uint8_t desc_index, unsigned char *data, int length); + +/* polling and timeouts */ + +int LIBUSB_CALL libusb_try_lock_events(libusb_context *ctx); +void LIBUSB_CALL libusb_lock_events(libusb_context *ctx); +void LIBUSB_CALL libusb_unlock_events(libusb_context *ctx); +int LIBUSB_CALL libusb_event_handling_ok(libusb_context *ctx); +int LIBUSB_CALL libusb_event_handler_active(libusb_context *ctx); +void LIBUSB_CALL libusb_lock_event_waiters(libusb_context *ctx); +void LIBUSB_CALL libusb_unlock_event_waiters(libusb_context *ctx); +int LIBUSB_CALL libusb_wait_for_event(libusb_context *ctx, struct timeval *tv); + +int LIBUSB_CALL libusb_handle_events_timeout(libusb_context *ctx, + struct timeval *tv); +int LIBUSB_CALL libusb_handle_events(libusb_context *ctx); +int LIBUSB_CALL libusb_handle_events_locked(libusb_context *ctx, + struct timeval *tv); +int LIBUSB_CALL libusb_pollfds_handle_timeouts(libusb_context *ctx); +int LIBUSB_CALL libusb_get_next_timeout(libusb_context *ctx, + struct timeval *tv); + +/** \ingroup poll + * File descriptor for polling + */ +struct libusb_pollfd { + /** Numeric file descriptor */ + int fd; + + /** Event flags to poll for from . POLLIN indicates that you + * should monitor this file descriptor for becoming ready to read from, + * and POLLOUT indicates that you should monitor this file descriptor for + * nonblocking write readiness. */ + short events; +}; + +/** \ingroup poll + * 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 events to monitor for, see \ref libusb_pollfd for a + * description + * \param user_data User data pointer specified in + * libusb_set_pollfd_notifiers() call + * \see libusb_set_pollfd_notifiers() + */ +typedef void (LIBUSB_CALL *libusb_pollfd_added_cb)(int fd, short events, + void *user_data); + +/** \ingroup poll + * 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 user_data User data pointer specified in + * libusb_set_pollfd_notifiers() call + * \see libusb_set_pollfd_notifiers() + */ +typedef void (LIBUSB_CALL *libusb_pollfd_removed_cb)(int fd, void *user_data); + +const struct libusb_pollfd ** LIBUSB_CALL libusb_get_pollfds( + libusb_context *ctx); +void LIBUSB_CALL libusb_set_pollfd_notifiers(libusb_context *ctx, + libusb_pollfd_added_cb added_cb, libusb_pollfd_removed_cb removed_cb, + void *user_data); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/LibusbJava/resource.rc b/LibusbJava/resource.rc deleted file mode 100644 index ed5bed5..0000000 --- a/LibusbJava/resource.rc +++ /dev/null @@ -1,7 +0,0 @@ -#define RC_FILE_TYPE VFT_DLL -#define RC_FILE_SUB_TYPE VFT2_UNKNOWN -#define RC_PRODUCT_STR "Java LibUsb-Win32 wrapper - DLL" -#define RC_FILE_NAME_STR "LibusbJava.dll" -#define RC_VERSION_STR "0.2.4.0" - -#include "common.rc" diff --git a/LibusbJava/usb.h b/LibusbJava/usb.h deleted file mode 100644 index 4f814df..0000000 --- a/LibusbJava/usb.h +++ /dev/null @@ -1,394 +0,0 @@ -#ifndef __USB_H__ -#define __USB_H__ - -#include -#include - -/* - * 'interface' is defined somewhere in the Windows header files. This macro - * is deleted here to avoid conflicts and compile errors. - */ - -#ifdef interface -#undef interface -#endif - -/* - * PATH_MAX from limits.h can't be used on Windows if the dll and - * import libraries are build/used by different compilers - */ - -#define LIBUSB_PATH_MAX 512 - - -/* - * USB spec information - * - * This is all stuff grabbed from various USB specs and is pretty much - * not subject to change - */ - -/* - * Device and/or Interface Class codes - */ -#define USB_CLASS_PER_INTERFACE 0 /* for DeviceClass */ -#define USB_CLASS_AUDIO 1 -#define USB_CLASS_COMM 2 -#define USB_CLASS_HID 3 -#define USB_CLASS_PRINTER 7 -#define USB_CLASS_MASS_STORAGE 8 -#define USB_CLASS_HUB 9 -#define USB_CLASS_DATA 10 -#define USB_CLASS_VENDOR_SPEC 0xff - -/* - * Descriptor types - */ -#define USB_DT_DEVICE 0x01 -#define USB_DT_CONFIG 0x02 -#define USB_DT_STRING 0x03 -#define USB_DT_INTERFACE 0x04 -#define USB_DT_ENDPOINT 0x05 - -#define USB_DT_HID 0x21 -#define USB_DT_REPORT 0x22 -#define USB_DT_PHYSICAL 0x23 -#define USB_DT_HUB 0x29 - -/* - * Descriptor sizes per descriptor type - */ -#define USB_DT_DEVICE_SIZE 18 -#define USB_DT_CONFIG_SIZE 9 -#define USB_DT_INTERFACE_SIZE 9 -#define USB_DT_ENDPOINT_SIZE 7 -#define USB_DT_ENDPOINT_AUDIO_SIZE 9 /* Audio extension */ -#define USB_DT_HUB_NONVAR_SIZE 7 - - -/* ensure byte-packed structures */ -#include - - -/* All standard descriptors have these 2 fields in common */ -struct usb_descriptor_header { - unsigned char bLength; - unsigned char bDescriptorType; -}; - -/* String descriptor */ -struct usb_string_descriptor { - unsigned char bLength; - unsigned char bDescriptorType; - unsigned short wData[1]; -}; - -/* HID descriptor */ -struct usb_hid_descriptor { - unsigned char bLength; - unsigned char bDescriptorType; - unsigned short bcdHID; - unsigned char bCountryCode; - unsigned char bNumDescriptors; -}; - -/* Endpoint descriptor */ -#define USB_MAXENDPOINTS 32 -struct usb_endpoint_descriptor { - unsigned char bLength; - unsigned char bDescriptorType; - unsigned char bEndpointAddress; - unsigned char bmAttributes; - unsigned short wMaxPacketSize; - unsigned char bInterval; - unsigned char bRefresh; - unsigned char bSynchAddress; - - unsigned char *extra; /* Extra descriptors */ - int extralen; -}; - -#define USB_ENDPOINT_ADDRESS_MASK 0x0f /* in bEndpointAddress */ -#define USB_ENDPOINT_DIR_MASK 0x80 - -#define USB_ENDPOINT_TYPE_MASK 0x03 /* in bmAttributes */ -#define USB_ENDPOINT_TYPE_CONTROL 0 -#define USB_ENDPOINT_TYPE_ISOCHRONOUS 1 -#define USB_ENDPOINT_TYPE_BULK 2 -#define USB_ENDPOINT_TYPE_INTERRUPT 3 - -/* Interface descriptor */ -#define USB_MAXINTERFACES 32 -struct usb_interface_descriptor { - unsigned char bLength; - unsigned char bDescriptorType; - unsigned char bInterfaceNumber; - unsigned char bAlternateSetting; - unsigned char bNumEndpoints; - unsigned char bInterfaceClass; - unsigned char bInterfaceSubClass; - unsigned char bInterfaceProtocol; - unsigned char iInterface; - - struct usb_endpoint_descriptor *endpoint; - - unsigned char *extra; /* Extra descriptors */ - int extralen; -}; - -#define USB_MAXALTSETTING 128 /* Hard limit */ - -struct usb_interface { - struct usb_interface_descriptor *altsetting; - - int num_altsetting; -}; - -/* Configuration descriptor information.. */ -#define USB_MAXCONFIG 8 -struct usb_config_descriptor { - unsigned char bLength; - unsigned char bDescriptorType; - unsigned short wTotalLength; - unsigned char bNumInterfaces; - unsigned char bConfigurationValue; - unsigned char iConfiguration; - unsigned char bmAttributes; - unsigned char MaxPower; - - struct usb_interface *interface; - - unsigned char *extra; /* Extra descriptors */ - int extralen; -}; - -/* Device descriptor */ -struct usb_device_descriptor { - unsigned char bLength; - unsigned char bDescriptorType; - unsigned short bcdUSB; - unsigned char bDeviceClass; - unsigned char bDeviceSubClass; - unsigned char bDeviceProtocol; - unsigned char bMaxPacketSize0; - unsigned short idVendor; - unsigned short idProduct; - unsigned short bcdDevice; - unsigned char iManufacturer; - unsigned char iProduct; - unsigned char iSerialNumber; - unsigned char bNumConfigurations; -}; - -struct usb_ctrl_setup { - unsigned char bRequestType; - unsigned char bRequest; - unsigned short wValue; - unsigned short wIndex; - unsigned short wLength; -}; - -/* - * Standard requests - */ -#define USB_REQ_GET_STATUS 0x00 -#define USB_REQ_CLEAR_FEATURE 0x01 -/* 0x02 is reserved */ -#define USB_REQ_SET_FEATURE 0x03 -/* 0x04 is reserved */ -#define USB_REQ_SET_ADDRESS 0x05 -#define USB_REQ_GET_DESCRIPTOR 0x06 -#define USB_REQ_SET_DESCRIPTOR 0x07 -#define USB_REQ_GET_CONFIGURATION 0x08 -#define USB_REQ_SET_CONFIGURATION 0x09 -#define USB_REQ_GET_INTERFACE 0x0A -#define USB_REQ_SET_INTERFACE 0x0B -#define USB_REQ_SYNCH_FRAME 0x0C - -#define USB_TYPE_STANDARD (0x00 << 5) -#define USB_TYPE_CLASS (0x01 << 5) -#define USB_TYPE_VENDOR (0x02 << 5) -#define USB_TYPE_RESERVED (0x03 << 5) - -#define USB_RECIP_DEVICE 0x00 -#define USB_RECIP_INTERFACE 0x01 -#define USB_RECIP_ENDPOINT 0x02 -#define USB_RECIP_OTHER 0x03 - -/* - * Various libusb API related stuff - */ - -#define USB_ENDPOINT_IN 0x80 -#define USB_ENDPOINT_OUT 0x00 - -/* Error codes */ -#define USB_ERROR_BEGIN 500000 - -/* - * This is supposed to look weird. This file is generated from autoconf - * and I didn't want to make this too complicated. - */ -#define USB_LE16_TO_CPU(x) - -/* Data types */ -/* struct usb_device; */ -/* struct usb_bus; */ - -struct usb_device { - struct usb_device *next, *prev; - - char filename[LIBUSB_PATH_MAX]; - - struct usb_bus *bus; - - struct usb_device_descriptor descriptor; - struct usb_config_descriptor *config; - - void *dev; /* Darwin support */ - - unsigned char devnum; - - unsigned char num_children; - struct usb_device **children; -}; - -struct usb_bus { - struct usb_bus *next, *prev; - - char dirname[LIBUSB_PATH_MAX]; - - struct usb_device *devices; - unsigned long location; - - struct usb_device *root_dev; -}; - -/* Version information, Windows specific */ -struct usb_version { - struct { - int major; - int minor; - int micro; - int nano; - } dll; - struct { - int major; - int minor; - int micro; - int nano; - } driver; -}; - - -struct usb_dev_handle; -typedef struct usb_dev_handle usb_dev_handle; - -/* Variables */ -#ifndef __USB_C__ -#define usb_busses usb_get_busses() -#endif - - - -#include - - -#ifdef __cplusplus -extern "C" { -#endif - - /* Function prototypes */ - - /* usb.c */ - usb_dev_handle *usb_open(struct usb_device *dev); - int usb_close(usb_dev_handle *dev); - int usb_get_string(usb_dev_handle *dev, int index, int langid, char *buf, - size_t buflen); - int usb_get_string_simple(usb_dev_handle *dev, int index, char *buf, - size_t buflen); - - /* descriptors.c */ - int usb_get_descriptor_by_endpoint(usb_dev_handle *udev, int ep, - unsigned char type, unsigned char index, - void *buf, int size); - int usb_get_descriptor(usb_dev_handle *udev, unsigned char type, - unsigned char index, void *buf, int size); - - /* .c */ - int usb_bulk_write(usb_dev_handle *dev, int ep, char *bytes, int size, - int timeout); - int usb_bulk_read(usb_dev_handle *dev, int ep, char *bytes, int size, - int timeout); - int usb_interrupt_write(usb_dev_handle *dev, int ep, char *bytes, int size, - int timeout); - int usb_interrupt_read(usb_dev_handle *dev, int ep, char *bytes, int size, - int timeout); - int usb_control_msg(usb_dev_handle *dev, int requesttype, int request, - int value, int index, char *bytes, int size, - int timeout); - int usb_set_configuration(usb_dev_handle *dev, int configuration); - int usb_claim_interface(usb_dev_handle *dev, int interface); - int usb_release_interface(usb_dev_handle *dev, int interface); - int usb_set_altinterface(usb_dev_handle *dev, int alternate); - int usb_resetep(usb_dev_handle *dev, unsigned int ep); - int usb_clear_halt(usb_dev_handle *dev, unsigned int ep); - int usb_reset(usb_dev_handle *dev); - - char *usb_strerror(void); - - void usb_init(void); - void usb_set_debug(int level); - int usb_find_busses(void); - int usb_find_devices(void); - struct usb_device *usb_device(usb_dev_handle *dev); - struct usb_bus *usb_get_busses(void); - - - /* Windows specific functions */ - - #define LIBUSB_HAS_INSTALL_SERVICE_NP 1 - int usb_install_service_np(void); - void CALLBACK usb_install_service_np_rundll(HWND wnd, HINSTANCE instance, - LPSTR cmd_line, int cmd_show); - - #define LIBUSB_HAS_UNINSTALL_SERVICE_NP 1 - int usb_uninstall_service_np(void); - void CALLBACK usb_uninstall_service_np_rundll(HWND wnd, HINSTANCE instance, - LPSTR cmd_line, int cmd_show); - - #define LIBUSB_HAS_INSTALL_DRIVER_NP 1 - int usb_install_driver_np(const char *inf_file); - void CALLBACK usb_install_driver_np_rundll(HWND wnd, HINSTANCE instance, - LPSTR cmd_line, int cmd_show); - - #define LIBUSB_HAS_TOUCH_INF_FILE_NP 1 - int usb_touch_inf_file_np(const char *inf_file); - void CALLBACK usb_touch_inf_file_np_rundll(HWND wnd, HINSTANCE instance, - LPSTR cmd_line, int cmd_show); - - #define LIBUSB_HAS_INSTALL_NEEDS_RESTART_NP 1 - int usb_install_needs_restart_np(void); - - const struct usb_version *usb_get_version(void); - - int usb_isochronous_setup_async(usb_dev_handle *dev, void **context, - unsigned char ep, int pktsize); - int usb_bulk_setup_async(usb_dev_handle *dev, void **context, - unsigned char ep); - int usb_interrupt_setup_async(usb_dev_handle *dev, void **context, - unsigned char ep); - - int usb_submit_async(void *context, char *bytes, int size); - int usb_reap_async(void *context, int timeout); - int usb_reap_async_nocancel(void *context, int timeout); - int usb_cancel_async(void *context); - int usb_free_async(void **context); - - -#ifdef __cplusplus -} -#endif - -#endif /* __USB_H__ */ - diff --git a/LibusbJava/version.properties b/LibusbJava/version.properties index 52e5578..597ca4d 100644 --- a/LibusbJava/version.properties +++ b/LibusbJava/version.properties @@ -1,5 +1,4 @@ -# NOTE: if the version is changed -> change the define in resource.rc -version.major=0 -version.minor=2 -version.micro=4 +version.major=1 +version.minor=0 +version.micro=0 version.nano=0 \ No newline at end of file