USB Pipe Types
Control pipes are the simplest form of pipes used for
communication. They are further divided into normal control
pipes and default control pipes. Default control pipes are not
directly accessible to the client but take requests from a
client. Normal control pipes can be directly accessed by the
client but require a specific data format where the first eight
bytes of the data buffer is the setup packet. The first byte of
the setup byte determines the direction and the rest of the
seven bytes are used for the properties of the request.
Isochronous pipes are more complicated. The direction of data
transfer in the pipe is determined by the end point. Isochronous
transfers are time sensitive. When the host receives an
isochronous transfer it identifies the frame number for the
first frame. The specification does not provide the application
the flexibility to specify the first frame, so the application
needs to schedule its packets for the earliest possible frame,
so each submission is treated as a single independent packet.
Frame synchronization becomes the responsibility of the
application, so it needs to provide enough packets to ensure
frame synchronization.
USB Pipe State Model
A pipe exists in a two states: active or inactive. A pipe needs
to be in the active state for any communication to happen.
Within the Active state a pipe can be in three substates: idle,
busy and error. When the pipe is opened it is in the idle state,
once data starts to communicate it changes to the busy state and
will remain there till completion of the transmission or till an
error occurs. Once transmission is completed it gets back to the
idle state and waits for further communication requests. The
pipe cannot be closed during the busy state, but can be closed
in the error state and busy state.
I/O Request Packets (IRP)
For simple communication a data buffer (byte []) can be used,
but for complex communications I/O request packets are required.
An IRP consists of a data buffer, communication policy
information, and other meta data all packaged into a single
object. IRPs give more control to the application on how the
data is submitted; they can be programmed to resubmit themselves
on completion. For more complicated submissions another type of
IRP called the composite UsbIrp (UsbCompositeIrp) is used. They
behave like normal UsbIrps but can encapsulate multiple IRPs
which can be submitted uninterrupted. They also provide better
optimization techniques to handle UsbIrps more efficiently.
Conclusion
The Java USB API is still in the public draft stage of the Java
Community Process, so many aspects of the API are not very
clear. The intent of the Java USB API is to provide a unified
specification API that would allow developers and vendors to
create drivers for their own application. This specification
strives to provide a standard library for all platforms and is
targeted for the J2ME and J2SE platforms. However we can hope
that by the end of the JCP the specification team will provide a
good API for USB access. It could throw open a wide range of
devices and services into the market.
As of now www.SourceForge.net
has an open source implementation of a Java USB specification
called jUsb. The jUsb is an implementation specific to Linux and
has no support for Windows based systems. jUsb also has a
parallel windows version of the API being made but only a
mention of it is provided on the website.
Benoy Jose is a web developer with over six years of experience
in J2EE and Microsoft technologies. He is a Sun Cetified
programmer and enjoys writing technical and non-technical
articles for various magazines.
New on the Java Boutique:
New Review:
Time Management Made Easy with the Quartz Enterprise Job Scheduler
Why not just use the Java timer API? This open source scheduling
API boasts simplicity, ease-of-integration, a well-rounded feature
set, and it's free!
New Applet:
Reverse Complement
Reverse Complement is a simple applet that converts DNA or RNA
sequences into three useful formats.
Elsewhere on internet.com:
WebDeveloper Java
Lots of Java information on webdeveloper.com
WDVL Java
Thorough Java resource at the Web Developer's Virtual Library.
ScriptSearch Java
Hundreds of free Java code files to download.
jGuru: Your View of the Java Universe
Customizable portal with online training, FAQs, regular news updates, and tutorials.