usb.core
Class Endpoint

java.lang.Object
  |
  +--usb.core.Descriptor
        |
        +--usb.core.Endpoint
All Implemented Interfaces:
java.io.Serializable

public final class Endpoint
extends Descriptor

Provides access to a USB endpoint descriptor, structuring device data input or output in a given device configuration. Only one thread at a time may use an endpoint for I/O.

Bulk endpoints look like standard byte I/O streams. Interrupt endpoints send and receive short buffers directly; at this writing there is no asynchronous notification framework. ISO endpoints are not currently supported here. (ControlMessages are effectively device methods.)

Most fields of this descriptor are specified in section 9.6.4 of the USB 1.1 specification.

See Also:
Serialized Form

Field Summary
static int ENDPOINT_HALT
          Endpoint feature selector that sets or clears the halt state.
 
Fields inherited from class usb.core.Descriptor
CLASS_APP_SPECIFIC, CLASS_AUDIO, CLASS_COMM, CLASS_DATA, CLASS_HID, CLASS_HUB, CLASS_MASS_STORAGE, CLASS_PRINTER, CLASS_VENDOR_SPECIFIC, TYPE_CONFIGURATION, TYPE_DEVICE, TYPE_DEVICE_QUALIFIER, TYPE_ENDPOINT, TYPE_HID, TYPE_HUB, TYPE_INTERFACE, TYPE_INTERFACE_POWER, TYPE_OTHER_SPEED, TYPE_PHYSICAL, TYPE_REPORT, TYPE_STRING
 
Method Summary
 void clearHalt()
          Clears a halt status (stall) on the bulk endpoint.
 int getAttributes()
          Returns the endpoint attributes (a bitmask describing its type).
 Device getDevice()
          Returns the device with which this USB object is associated.
 int getEndpoint()
          Returns an identifier composing the endpoint address and the flag controlling its input.
 int getEndpointAddress()
          Returns the endpoint address (a number from 0 to 15).
 java.io.InputStream getInputStream()
          Returns an input stream used to read from this bulk input stream.
 Interface getInterface()
          Returns the interface with which the endpoint is associated
 int getInterval()
          Returns interrupt polling interval (in microseconds).
 int getMaxPacketSize()
          Maximum packet size this endpoint can send or receive.
 java.io.OutputStream getOutputStream()
          Returns the output stream used to write to this bulk output stream.
 java.lang.String getType()
          Returns the type of endpoint ("bulk", "iso", or "interrupt"; "control" won't normally be seen).
 boolean isInput()
          Returns true if this is an input endpoint (data flows to host), false if it is instead an output endpoint (data flows to device).
 byte[] recvInterrupt()
          Blocks until an interrupt message is sent from device to host, and then returns that message.
 void sendInterrupt(byte[] buf)
          Sends interrupt message from host to device.
 
Methods inherited from class usb.core.Descriptor
getBCD, getClassName, getDescriptorType, getDescriptorTypeName, getLength, getU16, getU32, getU8, nextDescriptor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ENDPOINT_HALT

public static final int ENDPOINT_HALT
Endpoint feature selector that sets or clears the halt state. This is also used as the bit position in the status word which indicates the halted state.
Method Detail

getEndpointAddress

public int getEndpointAddress()
Returns the endpoint address (a number from 0 to 15).

isInput

public boolean isInput()
Returns true if this is an input endpoint (data flows to host), false if it is instead an output endpoint (data flows to device).

getEndpoint

public int getEndpoint()
Returns an identifier composing the endpoint address and the flag controlling its input.

getAttributes

public int getAttributes()
Returns the endpoint attributes (a bitmask describing its type).

getType

public java.lang.String getType()
Returns the type of endpoint ("bulk", "iso", or "interrupt"; "control" won't normally be seen).

getMaxPacketSize

public int getMaxPacketSize()
Maximum packet size this endpoint can send or receive. Note that for "high bandwidth" mode (some USB 2.0 periodic endpoints) this packet size accomodates the "multiplier".

getInterval

public int getInterval()
Returns interrupt polling interval (in microseconds). Polling intervals are typically measurable in milliseconds, except that high speed periodic transactions may be polled in intervals smaller than a frame.

For high speed bulk or contrul OUT endpoints, this value exposes the maximum NAK rate of the endpoint.


getInterface

public Interface getInterface()
Returns the interface with which the endpoint is associated

getDevice

public Device getDevice()
Description copied from class: Descriptor
Returns the device with which this USB object is associated.
Overrides:
getDevice in class Descriptor

getInputStream

public java.io.InputStream getInputStream()
Returns an input stream used to read from this bulk input stream. This stream has a maximum packet size, which application protocols may rely on.

getOutputStream

public java.io.OutputStream getOutputStream()
Returns the output stream used to write to this bulk output stream. This stream has a maximum packet size, which application protocols may rely on.

recvInterrupt

public byte[] recvInterrupt()
                     throws java.io.IOException
Blocks until an interrupt message is sent from device to host, and then returns that message. You must allocate a thread to poll for such interrupts every getInterval() milliseconds. Examples of such messages include mouse, keyboard, and joystick events. (Hub events too, but the kernel driver will always claim those.)

Note: not yet known to work on Linux; this starts with the implementation model that's supposed to work.

Returns:
the number of bytes actually read, or negative errno

sendInterrupt

public void sendInterrupt(byte[] buf)
                   throws java.io.IOException
Sends interrupt message from host to device. The data, with a maximum size, is written in the next available interrupt slot for this endpoint. (Note that Interrupt "out" capabilities were added in the 1.1 revision of the USB spec.) An example of such interrupts: at least one force-feedback joystick uses them for the feedback.

clearHalt

public void clearHalt()
               throws java.io.IOException
Clears a halt status (stall) on the bulk endpoint.


Associated source code is licenced under the LGPL.
See http://jusb.sourceforge.net
This documentation was derived from that source code on 24-Jul-2002.