2013-08-30

Java USB HOWTO


?jUSB and JSR 80 but both seem to be dead projects (at least for Windows).

we had to build our own custom C wrappers to the USB drivers and communicate with them through JNI


libusb-win32 requires you to install their generic driver, which then makes a USB device available to you. I'm not sure that it's possible to do driver-less access of an USB device unless the device belongs to one of several standard classes (storage and HID, in particular).
There is a Java wrapper for libusb-win32 which might work for you. I haven't used it myself, though.


The fastest and easiest way is to hack some native code :) I wrote a small wrapper for HID devices that enabled my Java applications to read data from CalComp digitizers, so it's definitely doable and not too hard. The bad thing is that my work is still proprietary code owned by my former employer, so for legal reasons I can't release that as open-source -- yet.
The good thing is that you can get a flying start with the HID example code from the Microsoft DDK :)

See the Libusb java binding on github
alternativly there is usb4java from which The low-level part is based on the native libusb 0.1


http://stackoverflow.com/questions/3803871/android-apps-communicating-with-a-device-plugged-in-the-usb-port
https://today.java.net/pub/a/today/2006/07/06/java-and-usb.html
http://www.ibm.com/developerworks/library/j-usb/index.html 

The only USB API I could find for Windows is here. Seems as if it has limited functionality, but it might suit your needs. A more complete UNIX API is also available.
ETA: Found a link to the official Java USB implementation, but looks like the windows version is still in alpha.
The above link to javax-usb.org is dead. However I found these two: javax.usb (This seems to be the official one) and javax-usb-libusb1

The native code API I referred to was the Windows DDK, i.e. the Driver Development Kit. The modern version seem to be called Windows Driver Kit, so google for Windows WDK :) There should be a few C samples on how to communicate with USB devices, and it should be pretty straightforward to write a JNI wrapper from those.

found this page that explains how to perform a communication between a microcontroller and a java application: http://javausbapi.blogspot.com/

http://www.math.ucla.edu/~anderson/JAVAclass/JavaInterface/JavaInterface.html 

No comments: