Class OutEndpoint

Endpoints in the OUT direction (PC->device) have this type.

Hierarchy (view full)

Constructors

Properties

address: number
descriptor: EndpointDescriptor

Object with fields from the endpoint descriptor -- see libusb documentation or USB spec.

device: Device
direction: "in" | "out" = 'out'

Endpoint direction.

timeout: number = 0

Sets the timeout in milliseconds for transfers on this endpoint. The default, 0, is infinite timeout.

transferAsync: ((buffer) => Promise<number>)

Type declaration

    • (buffer): Promise<number>
    • Parameters

      • buffer: Buffer

      Returns Promise<number>

transferType: number

Endpoint type: usb.LIBUSB_TRANSFER_TYPE_BULK, usb.LIBUSB_TRANSFER_TYPE_INTERRUPT, or usb.LIBUSB_TRANSFER_TYPE_ISOCHRONOUS.

Methods

  • Create a new Transfer object for this endpoint.

    The passed callback will be called when the transfer is submitted and finishes. Its arguments are the error (if any), the submitted buffer, and the amount of data actually written (for OUT transfers) or read (for IN transfers).

    Parameters

    • timeout: number

      Timeout for the transfer (0 means unlimited).

    • callback: ((error, buffer, actualLength) => void)

      Transfer completion callback.

        • (error, buffer, actualLength): void
        • Parameters

          Returns void

    Returns Transfer

  • Perform a transfer to write data to the endpoint.

    If length is greater than maxPacketSize, libusb will automatically split the transfer in multiple packets, and you will receive one callback once all packets are complete.

    this in the callback is the OutEndpoint object.

    The device must be open to use this method.

    Parameters

    • buffer: Buffer
    • Optional callback: ((error, actual) => void)
        • (error, actual): void
        • Parameters

          Returns void

    Returns OutEndpoint

  • Parameters

    • buffer: Buffer
    • callback: ((error) => void)

    Returns void