On 8/12/07, Kielogl <[EMAIL PROTECTED]> wrote: > 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?
I believe the difference is javax.usb provides device topology while libusb doesn't, so libusb doesn't need read-write access to the hub devices. > > 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? > javax.usb manually polls for newly connected devices as I found that using the select() notification on the devices was unreliable. This is configurable, there are settings in the javax.usb.properties file. Also, it is quite possible that using dnotify() or some other method to detect topology changes may be more reliable. As far as performance, it seems javax.usb has some perfomance issues recently which I assume is due to some change in java or the kernel, as the javax.usb code hasn't changed in years...I am looking into slowly to see if I can find the problem. > 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); > Is there some reason that using the static ClassLoader method doesn't work? > @@ -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"; What is the purpose of this change? > 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> This file is part of libusb, and I would prefer not to create a dependency on libusb just for this header file. Unfortunately, the Linux headers keep changing so it may be better to just re-define what is needed in our own javax.usb header files. :( > > // 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 > > ------------------------------------------------------------------------- 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