Thanks for providing a easy to use and well documented standard for USB access 
from Java! I have managed to get javax-usb working in a Tomcat 5.5 Web app on 
Fedora 7, and come across a couple of issues along the way.

1. I found hub devices (eg. /dev/bus/usb/001/001) need to be writable (as well 
as the device itself) otherwise ioctl() calls in 
javax-usb-ri-linux/jni/JavaxUsbTopologyUpdater.c will fail when retrieving port 
or connect info from the hub. I added the following to my local udev rules file 
to automatically set the correct permissions:

SUBSYSTEMS=="usb", DRIVERS=="usb", ATTRS{product}=="<my product string>", 
MODE="0666"
KERNELS=="usb1", SUBSYSTEMS=="usb", MODE="0666"

My previous implementation used JNI direct and libusb to find and access my 
device. libusb does not need write access to the hub device, so I guess this is 
a limitation of using file I/O for usb access in the javax-usb implementation?

2. Using my libusb implementation the Tomcat java process rarely appears in the 
process list from top. Using the javax-usb implementation, the Tomcat java 
process is continually using 5-6% CPU, once the usb device has been accessed. I 
guess javax-usb must be polling usb devices?

3. I had to make a couple of changes as per the diff output below. The first 
change enables the Tomcat classloader to find the properties file (also works 
for plain java too). The second change corrects the location of usb.h for 
Fedora 7.

Thanks again,

Mark.
========================================================
diff -Naur old/javax-usb/src/javax/usb/UsbHostManager.java 
new/javax-usb/src/javax/usb/UsbHostManager.java
--- old/javax-usb/src/javax/usb/UsbHostManager.java 2007-08-12 
15:42:40.000000000 +1000
+++ new/javax-usb/src/javax/usb/UsbHostManager.java 2007-08-12 
16:04:22.000000000 +1000
@@ -96,7 +96,7 @@
   */
  private static void setupProperties() throws  UsbException,SecurityException
  {
-  InputStream i = 
ClassLoader.getSystemResourceAsStream(JAVAX_USB_PROPERTIES_FILE);
+  InputStream i = 
UsbHostManager.class.getResourceAsStream(JAVAX_USB_PROPERTIES_FILE);
   if (null == i)
    throw new UsbException(PROPERTIES_FILE_NOT_FOUND);

@@ -116,7 +116,7 @@
   }
  }

- public static final String JAVAX_USB_PROPERTIES_FILE = "javax.usb.properties";
+ public static final String JAVAX_USB_PROPERTIES_FILE = 
"/javax.usb.properties";
  public static final String JAVAX_USB_USBSERVICES_PROPERTY = 
"javax.usb.services";

  private static final String PROPERTIES_FILE_NOT_FOUND = "Properties file " + 
JAVAX_USB_PROPERTIES_FILE + " not found.";
diff -Naur old/javax-usb-ri-linux/jni/JavaxUsbKernel.h 
new/javax-usb-ri-linux/jni/JavaxUsbKernel.h
--- old/javax-usb-ri-linux/jni/JavaxUsbKernel.h 2007-08-12 15:42:40.000000000 
+1000
+++  new/javax-usb-ri-linux/jni/JavaxUsbKernel.h 2007-08-12 16:03:11.000000000 
+1000
@@ -16,7 +16,7 @@

 #include <sys/utsname.h>
 #include <linux/usbdevice_fs.h>
-#include <linux/usb.h>
+#include <usb.h>

 // The names of this struct's fields change from 2.4 to 2.6.
 // But it's binary compatible, so let's just define it here.
========================================================
       
---------------------------------
Sick sense of humor? Visit Yahoo! TV's Comedy with an Edge to see what's on, 
when. 
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
javax-usb-devel mailing list
javax-usb-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/javax-usb-devel

Reply via email to