- only load references once (flag)
- interrupt read/write corrected - log messages updated - text header inserted git-svn-id: https://svn.code.sf.net/p/libusbjava/code/trunk@109 94ad28fe-ef68-46b1-9651-e7ae4fcf1c4c
This commit is contained in:
@@ -53,23 +53,8 @@
|
||||
<pathentry kind="out" path=""/>
|
||||
<pathentry kind="con" path="org.eclipse.cdt.make.core.DISCOVERED_SCANNER_INFO"/>
|
||||
</item>
|
||||
|
||||
<item id="org.eclipse.cdt.make.core.buildtargets">
|
||||
<buildTargets>
|
||||
<target name="cleanDll" path="" targetID="org.eclipse.cdt.make.MakeTargetBuilder">
|
||||
<buildCommand>make</buildCommand>
|
||||
<buildArguments></buildArguments>
|
||||
<buildTarget>cleanDll</buildTarget>
|
||||
<stopOnError>false</stopOnError>
|
||||
<useDefaultCommand>true</useDefaultCommand>
|
||||
</target>
|
||||
<target name="testExe" path="" targetID="org.eclipse.cdt.make.MakeTargetBuilder">
|
||||
<buildCommand>make</buildCommand>
|
||||
<buildArguments></buildArguments>
|
||||
<buildTarget>testExe</buildTarget>
|
||||
<stopOnError>false</stopOnError>
|
||||
<useDefaultCommand>true</useDefaultCommand>
|
||||
</target>
|
||||
<target name="dll" path="" targetID="org.eclipse.cdt.make.MakeTargetBuilder">
|
||||
<buildCommand>make</buildCommand>
|
||||
<buildArguments></buildArguments>
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* 2005/2006
|
||||
* Interstate University of Applied Sciences of Technology Buchs NTB
|
||||
* Computer Science Laboratory, inf.ntb.ch
|
||||
* Andreas Schl<68>pfer, aschlaepfer@ntb.ch
|
||||
*
|
||||
*/
|
||||
|
||||
#include <jni.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
@@ -9,10 +17,54 @@
|
||||
|
||||
// global bus (updated when usb_get_busses() is called)
|
||||
struct usb_bus *busses;
|
||||
// device class
|
||||
jclass usb_devClazz;
|
||||
// usb_device.devnum
|
||||
jfieldID usb_devFID_devnum;
|
||||
|
||||
// global flag for loading all class, method and field ID references
|
||||
int java_references_loaded = 0;
|
||||
|
||||
// class references
|
||||
jclass usb_busClazz, usb_devClazz, usb_devDescClazz, usb_confDescClazz, \
|
||||
usb_intClazz, usb_intDescClazz, usb_epDescClazz;
|
||||
|
||||
// method ID references
|
||||
jmethodID usb_busMid, usb_devMid, usb_devDescMid, usb_confDescMid, \
|
||||
usb_intMid, usb_intDescMid, usb_epDescMid;
|
||||
|
||||
// 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_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;
|
||||
|
||||
/*
|
||||
* Class: ch_ntb_usb_LibusbWin
|
||||
@@ -55,48 +107,9 @@ JNIEXPORT jint JNICALL Java_ch_ntb_usb_LibusbWin_usb_1find_1devices
|
||||
JNIEXPORT jobject JNICALL Java_ch_ntb_usb_LibusbWin_usb_1get_1busses
|
||||
(JNIEnv *env, jobject obj)
|
||||
{
|
||||
// classes
|
||||
jclass usb_busClazz, /*usb_devClazz,*/ usb_devDescClazz, usb_confDescClazz, \
|
||||
usb_intClazz, usb_intDescClazz, usb_epDescClazz;
|
||||
// method IDs
|
||||
jmethodID usb_busMid, usb_devMid, usb_devDescMid, usb_confDescMid, \
|
||||
usb_intMid, usb_intDescMid, usb_epDescMid;
|
||||
// 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_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;
|
||||
|
||||
// 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");
|
||||
@@ -111,7 +124,6 @@ JNIEXPORT jobject JNICALL Java_ch_ntb_usb_LibusbWin_usb_1get_1busses
|
||||
usb_busFID_location = env->GetFieldID(usb_busClazz, "location", "J");
|
||||
usb_busFID_root_dev = env->GetFieldID(usb_busClazz, "root_dev", "Lch/ntb/usb/Usb_Device;");
|
||||
|
||||
|
||||
// usb_device
|
||||
usb_devClazz = env->FindClass("ch/ntb/usb/Usb_Device");
|
||||
if (usb_devClazz == NULL) { return NULL; /* exception thrown */ }
|
||||
@@ -150,7 +162,6 @@ JNIEXPORT jobject JNICALL Java_ch_ntb_usb_LibusbWin_usb_1get_1busses
|
||||
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 */ }
|
||||
@@ -213,12 +224,12 @@ JNIEXPORT jobject JNICALL Java_ch_ntb_usb_LibusbWin_usb_1get_1busses
|
||||
usb_epDescFID_bSynchAddress = env->GetFieldID(usb_epDescClazz, "bSynchAddress", "B");
|
||||
usb_epDescFID_extra = env->GetFieldID(usb_epDescClazz, "extra", "Lch/ntb/usb/Usb_Endpoint_Descriptor;");
|
||||
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;
|
||||
@@ -247,13 +258,13 @@ JNIEXPORT jobject JNICALL Java_ch_ntb_usb_LibusbWin_usb_1get_1busses
|
||||
|
||||
while (bus){
|
||||
#ifdef DEBUGON
|
||||
printf("\tusb_get_busses: bus %x (2)\n", bus);
|
||||
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) { printf("Error NewObject 1\n"); return NULL; }
|
||||
if (!usb_busObj) { printf("Error NewObject (usb_busObj)\n"); return NULL; }
|
||||
main_usb_busObj = usb_busObj;
|
||||
}
|
||||
|
||||
@@ -261,7 +272,7 @@ JNIEXPORT jobject JNICALL Java_ch_ntb_usb_LibusbWin_usb_1get_1busses
|
||||
usb_busObj_next = NULL;
|
||||
if (bus->next){
|
||||
usb_busObj_next = env->NewObject(usb_busClazz, usb_busMid);
|
||||
if (!usb_busObj_next) { printf("Error NewObject 2\n"); return NULL; }
|
||||
if (!usb_busObj_next) { printf("Error NewObject (usb_busObj_next)\n"); return NULL; }
|
||||
}
|
||||
env->SetObjectField(usb_busObj, usb_busFID_next, usb_busObj_next);
|
||||
env->SetObjectField(usb_busObj, usb_busFID_prev, usb_busObj_prev);
|
||||
@@ -275,19 +286,19 @@ JNIEXPORT jobject JNICALL Java_ch_ntb_usb_LibusbWin_usb_1get_1busses
|
||||
|
||||
while (dev){
|
||||
#ifdef DEBUGON
|
||||
printf("\tusb_get_busses: dev %x (3)\n", dev);
|
||||
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) { printf("Error NewObject 3\n"); return NULL; }
|
||||
if (!usb_devObj) { printf("Error NewObject (usb_devObj)\n"); 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) { printf("Error NewObject 4\n"); return NULL; }
|
||||
if (!usb_devObj_next) { printf("Error NewObject (usb_devObj_next)\n"); return NULL; }
|
||||
}
|
||||
env->SetObjectField(usb_devObj, usb_devFID_next, usb_devObj_next);
|
||||
env->SetObjectField(usb_devObj, usb_devFID_prev, usb_devObj_prev);
|
||||
@@ -298,7 +309,7 @@ JNIEXPORT jobject JNICALL Java_ch_ntb_usb_LibusbWin_usb_1get_1busses
|
||||
|
||||
// device descriptor
|
||||
usb_devDescObj = env->NewObject(usb_devDescClazz, usb_devDescMid);
|
||||
if (!usb_devDescObj) { printf("Error NewObject 5\n"); return NULL; }
|
||||
if (!usb_devDescObj) { printf("Error NewObject (usb_devDescObj)\n"); 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);
|
||||
@@ -321,15 +332,16 @@ JNIEXPORT jobject JNICALL Java_ch_ntb_usb_LibusbWin_usb_1get_1busses
|
||||
if (!usb_confDescObjArray) { printf("Error NewObject 6\n"); return NULL; }
|
||||
for (int c = 0; c < dev->descriptor.bNumConfigurations; c++){
|
||||
#ifdef DEBUGON
|
||||
printf("\t\tusb_get_busses: configuration %x (4)\n", c);
|
||||
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)
|
||||
printf("dev->config == NULL\n");
|
||||
return main_usb_busObj;
|
||||
}
|
||||
|
||||
usb_confDescObj = env->NewObject(usb_confDescClazz, usb_confDescMid);
|
||||
if (!usb_confDescObj) { printf("Error NewObject 7\n"); return NULL; }
|
||||
if (!usb_confDescObj) { printf("Error NewObject (usb_confDescObj)\n"); 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);
|
||||
@@ -348,34 +360,36 @@ JNIEXPORT jobject JNICALL Java_ch_ntb_usb_LibusbWin_usb_1get_1busses
|
||||
}
|
||||
// interface
|
||||
usb_intObjArray = env->NewObjectArray(dev->config[c].bNumInterfaces, usb_intClazz, NULL);
|
||||
if (!usb_intObjArray) { printf("Error NewObject 8\n"); return NULL; }
|
||||
if (!usb_intObjArray) { printf("Error NewObject (usb_intObjArray)\n"); return NULL; }
|
||||
for (int i = 0; i < dev->config[c].bNumInterfaces; i++){
|
||||
#ifdef DEBUGON
|
||||
printf("\t\t\tusb_get_busses: interface %x (5)\n", i);
|
||||
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\n");
|
||||
return main_usb_busObj;
|
||||
}
|
||||
|
||||
usb_intObj = env->NewObject(usb_intClazz, usb_intMid);
|
||||
if (!usb_intObj) { printf("Error NewObject 9\n"); return NULL; }
|
||||
if (!usb_intObj) { printf("Error NewObject (usb_intObj)\n"); 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 = env->NewObjectArray(dev->config[c].interface[i].num_altsetting, usb_intDescClazz, NULL);
|
||||
if (!usb_intDescObjArray) { printf("Error NewObject 10\n"); return NULL; }
|
||||
if (!usb_intDescObjArray) { printf("Error NewObject (usb_intDescObjArray)\n"); 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 (6)\n", a);
|
||||
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("dev->config[c].interface[i].altsetting == NULL\n");
|
||||
return main_usb_busObj;
|
||||
}
|
||||
|
||||
usb_intDescObj = env->NewObject(usb_intDescClazz, usb_intDescMid);
|
||||
if (!usb_intDescObj) { printf("Error NewObject 11\n"); return NULL; }
|
||||
if (!usb_intDescObj) { printf("Error NewObject (usb_intDescObj)\n"); 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);
|
||||
@@ -395,10 +409,10 @@ JNIEXPORT jobject JNICALL Java_ch_ntb_usb_LibusbWin_usb_1get_1busses
|
||||
env->SetObjectField(usb_intDescObj, usb_intDescFID_extra, NULL);
|
||||
// endpoint descriptor
|
||||
usb_epDescObjArray = env->NewObjectArray(dev->config[c].interface[i].altsetting[a].bNumEndpoints, usb_epDescClazz, NULL);
|
||||
if (!usb_epDescObjArray) { printf("Error NewObject 12\n"); return NULL; }
|
||||
if (!usb_epDescObjArray) { printf("Error NewObject (usb_epDescObjArray)\n"); 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 (7)\n", e);
|
||||
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("dev->config[c].interface[i].altsetting[a].endpoint == NULL\n");
|
||||
@@ -406,7 +420,7 @@ JNIEXPORT jobject JNICALL Java_ch_ntb_usb_LibusbWin_usb_1get_1busses
|
||||
}
|
||||
|
||||
usb_epDescObj = env->NewObject(usb_epDescClazz, usb_epDescMid);
|
||||
if (!usb_epDescObj) { printf("Error NewObject 13\n"); return NULL; }
|
||||
if (!usb_epDescObj) { printf("Error NewObject (usb_epDescObj)\n"); 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);
|
||||
@@ -642,7 +656,6 @@ JNIEXPORT jint JNICALL Java_ch_ntb_usb_LibusbWin_usb_1bulk_1read
|
||||
char *bytes = (char *) malloc(size * sizeof(char));
|
||||
int retVal = usb_bulk_read((usb_dev_handle *) dev_handle, ep, bytes, size, timeout);
|
||||
if (!bytes) { return retVal; }
|
||||
// jbytes = env->NewByteArray(size);
|
||||
env->SetByteArrayRegion(jbytes, 0, size, (jbyte *) bytes);
|
||||
free(bytes);
|
||||
return retVal;
|
||||
@@ -668,11 +681,11 @@ JNIEXPORT jint JNICALL Java_ch_ntb_usb_LibusbWin_usb_1interrupt_1write
|
||||
JNIEXPORT jint JNICALL Java_ch_ntb_usb_LibusbWin_usb_1interrupt_1read
|
||||
(JNIEnv *env, jobject obj, jint dev_handle, jint ep, jbyteArray jbytes, jint size, jint timeout)
|
||||
{
|
||||
jbyte *bytes;
|
||||
int retVal = usb_interrupt_write((usb_dev_handle *) dev_handle, ep, (char *) bytes, size, timeout);
|
||||
if (bytes) { return retVal; }
|
||||
jbytes = env->NewByteArray(size);
|
||||
env->SetByteArrayRegion(jbytes, 0, size, bytes);
|
||||
char *bytes = (char *) malloc(size * sizeof(char));
|
||||
int retVal = usb_interrupt_write((usb_dev_handle *) dev_handle, ep, bytes, size, timeout);
|
||||
if (!bytes) { return retVal; }
|
||||
env->SetByteArrayRegion(jbytes, 0, size, (jbyte *) bytes);
|
||||
free(bytes);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user