Class InEndpoint

Endpoints in the IN direction (device->PC) 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" = 'in'

Endpoint direction.

pollActive: boolean = false
pollPending: number = 0
pollTransfers: Transfer[] = []
pollTransferSize: number = 0
timeout: number = 0

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

transferAsync: ((length: number) => Promise<undefined | Buffer>)
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: undefined | LibUSBException, buffer: Buffer, actualLength: number) => void)

      Transfer completion callback.

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

          Returns void

    Returns Transfer

  • Start polling the endpoint.

    The library will keep nTransfers transfers of size transferSize pending in the kernel at all times to ensure continuous data flow. This is handled by the libusb event thread, so it continues even if the Node v8 thread is busy. The data and error events are emitted as transfers complete.

    The device must be open to use this method.

    Parameters

    • OptionalnTransfers: number
    • OptionaltransferSize: number
    • Optionalcallback: ((error: undefined | LibUSBException, buffer: Buffer, actualLength: number, cancelled: boolean) => void)
        • (error, buffer, actualLength, cancelled): void
        • Parameters

          • error: undefined | LibUSBException
          • buffer: Buffer
          • actualLength: number
          • cancelled: boolean

          Returns void

    Returns Transfer[]

  • Parameters

    • nTransfers: number = 3
    • transferSize: number = ...
    • callback: ((error: undefined | LibUSBException, buffer: Buffer, actualLength: number) => void)
        • (error, buffer, actualLength): void
        • Parameters

          Returns void

    Returns Transfer[]

  • Stop polling.

    Further data may still be received. The end event is emitted and the callback is called once all transfers have completed or canceled.

    The device must be open to use this method.

    Parameters

    • Optionalcallback: (() => void)
        • (): void
        • Returns void

    Returns void

  • Perform a transfer to read data from the endpoint.

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

    this in the callback is the InEndpoint object.

    The device must be open to use this method.

    Parameters

    • length: number
    • callback: ((error: undefined | LibUSBException, data?: Buffer) => void)
        • (error, data?): void
        • Parameters

          Returns void

    Returns InEndpoint