O'Reilly logo

Java I/O, 2nd Edition by Elliotte Rusty Harold

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 23. USB

RS-232 serial ports are one of the oldest I/O technologies still in use today. They really haven’t changed a lot in the last 20 years. RS-232 serial ports work reliably and work well, but a 20-year-old technology designed for 300-baud modems, daisy-wheel printers, and 16-bit processors with 4.77-MHz clock rates doesn’t suffice for digital video, DVD burners, and optical mice. Consequently, more modern computers have switched to a different serial protocol known as Universal Serial Bus (USB).

Hardware-wise, USB is much faster and thus better suited for the data transfer needs of today’s more bandwidth-hungry devices. USB also uses a different connector that’s much easier to plug in and unplug and less susceptible to bent pins and broken ports. USB cables carry power as well as data, so small USB devices that don’t draw a lot of current don’t need separate power cords. However, to a Java programmer there are two key differences:

  1. Many different devices can be connected to the same USB port. Indeed, up to 127 different devices may be daisy chained to a single USB controller.

  2. Data is sent to and received from USB devices in individual I/O request packets (IRPs). The stream classes are not used.

This makes communicating with USB devices more complex than reading and writing the streams from the single device on a serial port.

There are several extant versions of USB. The basic architecture and APIs are the same regardless of version. As a software developer or end user, the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required