Package usb.windows

This package has a partial Windows implementation of a usb.core.Host object, bootstrapping support, and other classes leveraging Windows USB support.

See:
          Description

Class Summary
DeviceImpl Provides access to all USB devices on a bus in limited fashion.
JUSB Provides access to the devices using and configured with the jUSB driver.
NonJUSB Provides all functionality from the DeviceImpl class.
USB Represents a Universal Serial Bus (USB) which hosts a set of devices.
Windows Provides access to native USB host objects
 

Package usb.windows Description

This package has a partial Windows implementation of a usb.core.Host object, bootstrapping support, and other classes leveraging Windows USB support.

Sources and Documentation of the implementation is presented at the end of this site. The usb.core functionality is partly supported by the usb.windows package.

Enumeration and monitoring the USB is complete and fully functional. Every device on the USB will either be an instance of JUSB class or a NonJUSB class. Devices within the JUSB class uses the jUSB driver and allow partial using the methods provided in the DeviceSPIinterface. The NonJUSB devices are all other devices on the USB not using the jUSB driver. The superclass of JUSB and NonJUSB is DeviceImpl class. All devices, instance of DeviceImpl class have the ability to read the device and default configuration descriptor. Further, they are aware about the bus structure of the USB. They know how many children they have and to what port they are connected to.

Control Transfer
Supported are the following standard request: GET_DESCRIPTOR, GET_STATUS
All the other request still needs to be implemented

Interrupt Transfer
Only JUSB.readIntr(int ep, int len) is supported so far the device has a corresponding endpoint.
WriteIntr should not be difficult to add.

Bulk Transfer Not supported yet.

Use jUSB API for Windows (Binaries)

You have to download the JavaUSBComplete.ZIP and install according to chapter 7 and when using a jUSB device you will need the driver replacement instruction (Appendix D) for an USB device.

Introduction to the implementation and the framework of jUSB API

The core Java USB API provides a singleton host that monitors all USB busses. The host is responsible for enumerating the USB devices on the Java side and update its listeners as soon as a device has been attached or removed. We can see a close correlation to the work of the USB hub driver (USBHUB.sys) and the USB driver (USBD.sys) in the USB driver stack for Windows. In fact, they are responsible for the tree structure and to enumerate the devices.



According to the usbview example delivered with the DDK, we know that it is possible to enumerate all the devices (hubs included) and even the host controllers. John Hyde shows another example how to display the USB tree structure in Windows. The common thing both examples have in common is that they are executed in user mode. The conclusion is that we do not have to write a driver to enumerate and control the USB tree structure for the Java USB API. Of course, these user mode functions are performed with the DeviceIoControl WinAPI function which uses the handle to the corresponding hub driver. A driver is still required but it is already supplied by the Microsoft operating system. A small disadvantage is that undocumented I/O Control (IOCTL) codes are used. This forces one to use the examples as documenta-tion, which is far away from an optimal documentation. Anyway, creating a framework using existing user mode functions simplifies the writing of the Java USB driver. We use the Win API user mode function as shown in the usbview example to enumerate and monitor the USB tree structure as shown in Figure 1.

To perform device specific operations we need to write a device driver mapping the user mode function to the related kernel mode function as shown in the right part of Figure 1. This involves the jUSB driver to handle different kinds of IOCTL codes to maintain all the functionality supported by the Java USB API. The Question may arise of how to assign the jUSB driver to any kind of USB device. Usually, a USB device is plugged in and the driver is loaded automatically. This is still preferable but instead of loading the original driver for the USB device we want the system to load the jUSB driver ( details about the installation of a new jUSB device). Of course, this will take away all the functionality the origin driver supported but this functionality should now be provided by the Java USB API. Using the new API we can build the functionality we want from the device in Java and do no longer have to care about C, JNI and driver writing on the Windows platform. Chapter 5 is going to present the implementation of functions not using the JUSB driver while chapter 6 describes the driver implementation for the Java USB API. A lot of useful information about driver writing can be found in the book "Programming The Microsoft Windows Driver Model" by Walter Oney.

Sources and Documentation (Sources)

The Java USB API for Windows was my diploma thesis. As I could not reach the goal to implement all the functionality from the usb.core API in 4 month time, I appreciate any help of developers who want to extend the jUSB API to a fully working and stable API. Therefore all the souces are downloadable to extend and modify the usb.windows package, the jUSB DLL and the jUSB driver. For documentation you can use my diploma thesis.

Source Package for Developers
Download JavaUSBComplete.ZIP and follow the installation instruction given at chapter 8.
JavaUSBComplete.ZIP file contains the usb.windows package, the jUSB DLL and the jUSB source code.

Documentation Java USB API for Windows
Download Java USB for Windows documentation(Sept. 2003).