usb

  • Version 2.14.0
  • Published
  • 6.82 MB
  • 3 dependencies
  • MIT license

Install

npm i usb
yarn add usb
pnpm add usb

Overview

Library to access USB devices

Index

Variables

Functions

Classes

Interfaces

Namespaces

Variables

variable webusb

const webusb: WebUSB;

    Functions

    function findByIds

    findByIds: (vid: number, pid: number) => usb.Device | undefined;
    • Convenience method to get the first device with the specified VID and PID, or undefined if no such device is present.

      Parameter vid

      Parameter pid

    function findBySerialNumber

    findBySerialNumber: (serialNumber: string) => Promise<usb.Device | undefined>;
    • Convenience method to get the device with the specified serial number, or undefined if no such device is present.

      Parameter serialNumber

    function getDeviceList

    getDeviceList: () => Device[];
    • Return a list of Device objects for the USB devices attached to the system.

    function getWebUsb

    getWebUsb: () => USB;
    • Convenience method to get the WebUSB interface available

    function useUsbDkBackend

    useUsbDkBackend: () => void;
    • Use USBDK Backend (Windows only)

    Classes

    class Capability

    class Capability {}

      constructor

      constructor(device: Device, id: number);

        property data

        data: Buffer;
        • Buffer capability data.

        property descriptor

        descriptor: CapabilityDescriptor;
        • Object with fields from the capability descriptor -- see libusb documentation or USB spec.

        property device

        protected device: Device;

          property id

          protected id: number;

            property type

            type: number;
            • Integer capability type.

            class Device

            class Device {}
            • Represents a USB device.

            property busNumber

            busNumber: number;
            • Integer USB device number

            property deviceAddress

            deviceAddress: number;
            • Integer USB device address

            property deviceDescriptor

            deviceDescriptor: DeviceDescriptor;
            • Object with properties for the fields of the device descriptor.

            property portNumbers

            portNumbers: number[];
            • Array containing the USB device port numbers, or undefined if not supported on this platform.

            method reset

            reset: (callback: (error?: LibUSBException) => void) => void;
            • Performs a reset of the device. Callback is called when complete.

              The device must be open to use this method.

              Parameter callback

            class Endpoint

            abstract class Endpoint extends EventEmitter {}
            • Common base for InEndpoint and OutEndpoint.

            constructor

            constructor(device: Device, descriptor: EndpointDescriptor);

              property address

              address: number;

                property descriptor

                descriptor: EndpointDescriptor;
                • Object with fields from the endpoint descriptor -- see libusb documentation or USB spec.

                property device

                protected device: Device;

                  property direction

                  abstract direction: 'in' | 'out';
                  • Endpoint direction: "in" or "out".

                  property timeout

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

                  property transferType

                  transferType: number;
                  • Endpoint type: usb.LIBUSB_TRANSFER_TYPE_BULK, usb.LIBUSB_TRANSFER_TYPE_INTERRUPT, or usb.LIBUSB_TRANSFER_TYPE_ISOCHRONOUS.

                  method clearHalt

                  clearHalt: (callback: (error: LibUSBException | undefined) => void) => void;
                  • Clear the halt/stall condition for this endpoint.

                  method makeTransfer

                  makeTransfer: (
                  timeout: number,
                  callback: (
                  error: LibUSBException | undefined,
                  buffer: Buffer,
                  actualLength: number
                  ) => void
                  ) => Transfer;
                  • 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).

                    Parameter timeout

                    Timeout for the transfer (0 means unlimited).

                    Parameter callback

                    Transfer completion callback.

                  class InEndpoint

                  class InEndpoint extends Endpoint {}
                  • Endpoints in the IN direction (device->PC) have this type.

                  constructor

                  constructor(device: Device, descriptor: EndpointDescriptor);

                    property direction

                    direction: 'in' | 'out';
                    • Endpoint direction.

                    property pollActive

                    pollActive: boolean;

                      property pollPending

                      protected pollPending: number;

                        property pollTransfers

                        protected pollTransfers: Transfer[];

                          property pollTransferSize

                          protected pollTransferSize: number;

                            property transferAsync

                            transferAsync: (length: number) => Promise<Buffer | undefined>;

                              method startPoll

                              startPoll: (
                              nTransfers?: number,
                              transferSize?: number,
                              callback?: (
                              error: LibUSBException | undefined,
                              buffer: Buffer,
                              actualLength: number,
                              cancelled: boolean
                              ) => void
                              ) => 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.

                                Parameter nTransfers

                                Parameter transferSize

                                Parameter callback

                              method startPollTransfers

                              protected startPollTransfers: (
                              nTransfers: number | undefined,
                              transferSize: number | undefined,
                              callback: (
                              error: LibUSBException | undefined,
                              buffer: Buffer,
                              actualLength: number
                              ) => void
                              ) => Transfer[];

                                method stopPoll

                                stopPoll: (callback?: () => void) => void;
                                • 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.

                                  Parameter callback

                                method transfer

                                transfer: (
                                length: number,
                                callback: (error: LibUSBException | undefined, data?: Buffer) => void
                                ) => InEndpoint;
                                • 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.

                                  Parameter length

                                  Parameter callback

                                class Interface

                                class Interface {}

                                  constructor

                                  constructor(device: Device, id: number);

                                    property altSetting

                                    altSetting: number;
                                    • Integer alternate setting number.

                                    property descriptor

                                    descriptor: InterfaceDescriptor;
                                    • Object with fields from the interface descriptor -- see libusb documentation or USB spec.

                                    property device

                                    protected device: Device;

                                      property endpoints

                                      endpoints: Endpoint[];
                                      • List of endpoints on this interface: InEndpoint and OutEndpoint objects.

                                      property id

                                      protected id: number;

                                        property interfaceNumber

                                        interfaceNumber: number;
                                        • Integer interface number.

                                        property releaseAsync

                                        releaseAsync: () => Promise<void>;

                                          property setAltSettingAsync

                                          setAltSettingAsync: (alternateSetting: number) => Promise<void>;

                                            method attachKernelDriver

                                            attachKernelDriver: () => void;
                                            • Re-attaches the kernel driver for the interface.

                                              The device must be open to use this method.

                                            method claim

                                            claim: () => void;
                                            • Claims the interface. This method must be called before using any endpoints of this interface.

                                              The device must be open to use this method.

                                            method detachKernelDriver

                                            detachKernelDriver: () => void;
                                            • Detaches the kernel driver from the interface.

                                              The device must be open to use this method.

                                            method endpoint

                                            endpoint: (addr: number) => Endpoint | undefined;
                                            • Return the InEndpoint or OutEndpoint with the specified address.

                                              The device must be open to use this method.

                                              Parameter addr

                                            method isKernelDriverActive

                                            isKernelDriverActive: () => boolean;
                                            • Returns false if a kernel driver is not active; true if active.

                                              The device must be open to use this method.

                                            method refresh

                                            protected refresh: () => void;

                                              method release

                                              release: {
                                              (callback?: (error?: LibUSBException) => void): void;
                                              (
                                              closeEndpoints?: boolean,
                                              callback?: (error?: LibUSBException) => void
                                              ): void;
                                              };
                                              • Releases the interface and resets the alternate setting. Calls callback when complete.

                                                It is an error to release an interface with pending transfers.

                                                The device must be open to use this method.

                                                Parameter callback

                                              • Releases the interface and resets the alternate setting. Calls callback when complete.

                                                It is an error to release an interface with pending transfers. If the optional closeEndpoints parameter is true, any active endpoint streams are stopped (see Endpoint.stopStream), and the interface is released after the stream transfers are cancelled. Transfers submitted individually with Endpoint.transfer are not affected by this parameter.

                                                The device must be open to use this method.

                                                Parameter closeEndpoints

                                                Parameter callback

                                              method setAltSetting

                                              setAltSetting: (
                                              altSetting: number,
                                              callback?: (error: LibUSBException | undefined) => void
                                              ) => void;
                                              • Sets the alternate setting. It updates the interface.endpoints array to reflect the endpoints found in the alternate setting.

                                                The device must be open to use this method.

                                                Parameter altSetting

                                                Parameter callback

                                              class LibUSBException

                                              class LibUSBException extends Error {}

                                                property errno

                                                errno: number;

                                                  class OutEndpoint

                                                  class OutEndpoint extends Endpoint {}
                                                  • Endpoints in the OUT direction (PC->device) have this type.

                                                  constructor

                                                  constructor(device: Device, descriptor: EndpointDescriptor);

                                                    property direction

                                                    direction: 'in' | 'out';
                                                    • Endpoint direction.

                                                    property transferAsync

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

                                                      method transfer

                                                      transfer: (
                                                      buffer: Buffer,
                                                      callback?: (error: LibUSBException | undefined, actual: number) => void
                                                      ) => OutEndpoint;
                                                      • 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.

                                                        Parameter buffer

                                                        Parameter callback

                                                      method transferWithZLP

                                                      transferWithZLP: (
                                                      buffer: Buffer,
                                                      callback: (error: LibUSBException | undefined) => void
                                                      ) => void;

                                                        class Transfer

                                                        class Transfer {}
                                                        • Represents a USB transfer

                                                        constructor

                                                        constructor(
                                                        device: Device,
                                                        endpointAddr: number,
                                                        type: number,
                                                        timeout: number,
                                                        callback: (error: LibUSBException, buf: Buffer, actual: number) => void
                                                        );

                                                          method cancel

                                                          cancel: () => boolean;
                                                          • Cancel the transfer.

                                                            Returns true if the transfer was canceled, false if it wasn't in pending state.

                                                          method submit

                                                          submit: (
                                                          buffer: Buffer,
                                                          callback?: (
                                                          error: LibUSBException | undefined,
                                                          buffer: Buffer,
                                                          actualLength: number
                                                          ) => void
                                                          ) => Transfer;
                                                          • (Re-)submit the transfer.

                                                            Parameter buffer

                                                            Buffer where data will be written (for IN transfers) or read from (for OUT transfers).

                                                          class WebUSB

                                                          class WebUSB implements USB {}

                                                            constructor

                                                            constructor(options?: USBOptions);

                                                              property authorisedDevices

                                                              protected authorisedDevices: Set<USBDeviceFilter>;

                                                                property emitter

                                                                protected emitter: EventEmitter<[never]>;

                                                                  property knownDevices

                                                                  protected knownDevices: Map<usb.Device, WebUSBDevice>;

                                                                    method addEventListener

                                                                    addEventListener: {
                                                                    (
                                                                    type: 'connect' | 'disconnect',
                                                                    listener: (this: this, ev: USBConnectionEvent) => void
                                                                    ): void;
                                                                    (type: 'connect' | 'disconnect', listener: EventListener): void;
                                                                    };

                                                                      method dispatchEvent

                                                                      dispatchEvent: (_event: Event) => boolean;

                                                                        method getDevices

                                                                        getDevices: () => Promise<USBDevice[]>;
                                                                        • Gets all allowed Web USB devices which are connected

                                                                          Returns

                                                                          Promise containing an array of devices

                                                                        method removeEventListener

                                                                        removeEventListener: {
                                                                        (
                                                                        type: 'connect' | 'disconnect',
                                                                        callback: (this: this, ev: USBConnectionEvent) => void
                                                                        ): void;
                                                                        (type: 'connect' | 'disconnect', callback: EventListener): void;
                                                                        };

                                                                          method requestDevice

                                                                          requestDevice: (options?: USBDeviceRequestOptions) => Promise<USBDevice>;
                                                                          • Requests a single Web USB device

                                                                            Parameter options

                                                                            The options to use when scanning

                                                                            Returns

                                                                            Promise containing the selected device

                                                                          class WebUSBDevice

                                                                          class WebUSBDevice implements USBDevice {}
                                                                          • Wrapper to make a node-usb device look like a webusb device

                                                                          property configuration

                                                                          readonly configuration: any;

                                                                            property configurations

                                                                            configurations: USBConfiguration[];

                                                                              property deviceClass

                                                                              readonly deviceClass: number;

                                                                                property deviceProtocol

                                                                                readonly deviceProtocol: number;

                                                                                  property deviceSubclass

                                                                                  readonly deviceSubclass: number;

                                                                                    property deviceVersionMajor

                                                                                    readonly deviceVersionMajor: number;

                                                                                      property deviceVersionMinor

                                                                                      readonly deviceVersionMinor: number;

                                                                                        property deviceVersionSubminor

                                                                                        readonly deviceVersionSubminor: number;

                                                                                          property manufacturerName

                                                                                          manufacturerName?: string;

                                                                                            property opened

                                                                                            readonly opened: boolean;

                                                                                              property productId

                                                                                              readonly productId: number;

                                                                                                property productName

                                                                                                productName?: string;

                                                                                                  property serialNumber

                                                                                                  serialNumber?: string;

                                                                                                    property usbVersionMajor

                                                                                                    readonly usbVersionMajor: number;

                                                                                                      property usbVersionMinor

                                                                                                      readonly usbVersionMinor: number;

                                                                                                        property usbVersionSubminor

                                                                                                        readonly usbVersionSubminor: number;

                                                                                                          property vendorId

                                                                                                          readonly vendorId: number;

                                                                                                            method claimInterface

                                                                                                            claimInterface: (interfaceNumber: number) => Promise<void>;

                                                                                                              method clearHalt

                                                                                                              clearHalt: (direction: USBDirection, endpointNumber: number) => Promise<void>;

                                                                                                                method close

                                                                                                                close: () => Promise<void>;

                                                                                                                  method controlTransferIn

                                                                                                                  controlTransferIn: (
                                                                                                                  setup: USBControlTransferParameters,
                                                                                                                  length: number
                                                                                                                  ) => Promise<USBInTransferResult>;

                                                                                                                    method controlTransferOut

                                                                                                                    controlTransferOut: (
                                                                                                                    setup: USBControlTransferParameters,
                                                                                                                    data?: ArrayBuffer
                                                                                                                    ) => Promise<USBOutTransferResult>;

                                                                                                                      method createInstance

                                                                                                                      static createInstance: (device: usb.Device) => Promise<WebUSBDevice>;

                                                                                                                        method forget

                                                                                                                        forget: () => Promise<void>;

                                                                                                                          method isochronousTransferIn

                                                                                                                          isochronousTransferIn: (
                                                                                                                          _endpointNumber: number,
                                                                                                                          _packetLengths: number[]
                                                                                                                          ) => Promise<USBIsochronousInTransferResult>;

                                                                                                                            method isochronousTransferOut

                                                                                                                            isochronousTransferOut: (
                                                                                                                            _endpointNumber: number,
                                                                                                                            _data: BufferSource,
                                                                                                                            _packetLengths: number[]
                                                                                                                            ) => Promise<USBIsochronousOutTransferResult>;

                                                                                                                              method open

                                                                                                                              open: () => Promise<void>;

                                                                                                                                method releaseInterface

                                                                                                                                releaseInterface: (interfaceNumber: number) => Promise<void>;

                                                                                                                                  method reset

                                                                                                                                  reset: () => Promise<void>;

                                                                                                                                    method selectAlternateInterface

                                                                                                                                    selectAlternateInterface: (
                                                                                                                                    interfaceNumber: number,
                                                                                                                                    alternateSetting: number
                                                                                                                                    ) => Promise<void>;

                                                                                                                                      method selectConfiguration

                                                                                                                                      selectConfiguration: (configurationValue: number) => Promise<void>;

                                                                                                                                        method transferIn

                                                                                                                                        transferIn: (
                                                                                                                                        endpointNumber: number,
                                                                                                                                        length: number
                                                                                                                                        ) => Promise<USBInTransferResult>;

                                                                                                                                          method transferOut

                                                                                                                                          transferOut: (
                                                                                                                                          endpointNumber: number,
                                                                                                                                          data: ArrayBuffer
                                                                                                                                          ) => Promise<USBOutTransferResult>;

                                                                                                                                            Interfaces

                                                                                                                                            interface BosDescriptor

                                                                                                                                            interface BosDescriptor {}
                                                                                                                                            • A structure representing the Binary Device Object Store (BOS) descriptor

                                                                                                                                            property bDescriptorType

                                                                                                                                            bDescriptorType: number;
                                                                                                                                            • Descriptor type.

                                                                                                                                            property bLength

                                                                                                                                            bLength: number;
                                                                                                                                            • Size of this descriptor (in bytes)

                                                                                                                                            property bNumDeviceCaps

                                                                                                                                            bNumDeviceCaps: number;
                                                                                                                                            • The number of separate device capability descriptors in the BOS.

                                                                                                                                            property capabilities

                                                                                                                                            capabilities: CapabilityDescriptor[];
                                                                                                                                            • Device Capability Descriptors

                                                                                                                                            property wTotalLength

                                                                                                                                            wTotalLength: number;
                                                                                                                                            • Length of this descriptor and all of its sub descriptors.

                                                                                                                                            interface CapabilityDescriptor

                                                                                                                                            interface CapabilityDescriptor {}
                                                                                                                                            • A generic representation of a BOS Device Capability descriptor

                                                                                                                                            property bDescriptorType

                                                                                                                                            bDescriptorType: number;
                                                                                                                                            • Descriptor type.

                                                                                                                                            property bDevCapabilityType

                                                                                                                                            bDevCapabilityType: number;
                                                                                                                                            • Device Capability type.

                                                                                                                                            property bLength

                                                                                                                                            bLength: number;
                                                                                                                                            • Size of this descriptor (in bytes)

                                                                                                                                            property dev_capability_data

                                                                                                                                            dev_capability_data: Buffer;
                                                                                                                                            • Device Capability data (bLength - 3 bytes)

                                                                                                                                            interface ConfigDescriptor

                                                                                                                                            interface ConfigDescriptor {}
                                                                                                                                            • A structure representing the standard USB configuration descriptor

                                                                                                                                            property bConfigurationValue

                                                                                                                                            bConfigurationValue: number;
                                                                                                                                            • Identifier value for this configuration.

                                                                                                                                            property bDescriptorType

                                                                                                                                            bDescriptorType: number;
                                                                                                                                            • Descriptor type.

                                                                                                                                            property bLength

                                                                                                                                            bLength: number;
                                                                                                                                            • Size of this descriptor (in bytes)

                                                                                                                                            property bmAttributes

                                                                                                                                            bmAttributes: number;
                                                                                                                                            • Configuration characteristics.

                                                                                                                                            property bMaxPower

                                                                                                                                            bMaxPower: number;
                                                                                                                                            • Maximum power consumption of the USB device from this bus in this configuration when the device is fully operation.

                                                                                                                                            property bNumInterfaces

                                                                                                                                            bNumInterfaces: number;
                                                                                                                                            • Number of interfaces supported by this configuration.

                                                                                                                                            property extra

                                                                                                                                            extra: Buffer;
                                                                                                                                            • Extra descriptors.

                                                                                                                                            property iConfiguration

                                                                                                                                            iConfiguration: number;
                                                                                                                                            • Index of string descriptor describing this configuration.

                                                                                                                                            property interfaces

                                                                                                                                            interfaces: InterfaceDescriptor[][];
                                                                                                                                            • Array of interfaces supported by this configuration.

                                                                                                                                            property wTotalLength

                                                                                                                                            wTotalLength: number;
                                                                                                                                            • Total length of data returned for this configuration.

                                                                                                                                            interface Device

                                                                                                                                            interface Device extends ExtendedDevice {}

                                                                                                                                              interface DeviceDescriptor

                                                                                                                                              interface DeviceDescriptor {}
                                                                                                                                              • A structure representing the standard USB device descriptor

                                                                                                                                              property bcdDevice

                                                                                                                                              bcdDevice: number;
                                                                                                                                              • Device release number in binary-coded decimal.

                                                                                                                                              property bcdUSB

                                                                                                                                              bcdUSB: number;
                                                                                                                                              • USB specification release number in binary-coded decimal.

                                                                                                                                              property bDescriptorType

                                                                                                                                              bDescriptorType: number;
                                                                                                                                              • Descriptor type.

                                                                                                                                              property bDeviceClass

                                                                                                                                              bDeviceClass: number;
                                                                                                                                              • USB-IF class code for the device.

                                                                                                                                              property bDeviceProtocol

                                                                                                                                              bDeviceProtocol: number;
                                                                                                                                              • USB-IF protocol code for the device, qualified by the bDeviceClass and bDeviceSubClass values.

                                                                                                                                              property bDeviceSubClass

                                                                                                                                              bDeviceSubClass: number;
                                                                                                                                              • USB-IF subclass code for the device, qualified by the bDeviceClass value.

                                                                                                                                              property bLength

                                                                                                                                              bLength: number;
                                                                                                                                              • Size of this descriptor (in bytes)

                                                                                                                                              property bMaxPacketSize0

                                                                                                                                              bMaxPacketSize0: number;
                                                                                                                                              • Maximum packet size for endpoint 0.

                                                                                                                                              property bNumConfigurations

                                                                                                                                              bNumConfigurations: number;
                                                                                                                                              • Number of possible configurations.

                                                                                                                                              property idProduct

                                                                                                                                              idProduct: number;
                                                                                                                                              • USB-IF product ID.

                                                                                                                                              property idVendor

                                                                                                                                              idVendor: number;
                                                                                                                                              • USB-IF vendor ID.

                                                                                                                                              property iManufacturer

                                                                                                                                              iManufacturer: number;
                                                                                                                                              • Index of string descriptor describing manufacturer.

                                                                                                                                              property iProduct

                                                                                                                                              iProduct: number;
                                                                                                                                              • Index of string descriptor describing product.

                                                                                                                                              property iSerialNumber

                                                                                                                                              iSerialNumber: number;
                                                                                                                                              • Index of string descriptor containing device serial number.

                                                                                                                                              interface DeviceEvents

                                                                                                                                              interface DeviceEvents extends EventListeners<DeviceEvents> {}

                                                                                                                                                property attach

                                                                                                                                                attach: Device;

                                                                                                                                                  property attachIds

                                                                                                                                                  attachIds: DeviceIds;

                                                                                                                                                    property detach

                                                                                                                                                    detach: Device;

                                                                                                                                                      property detachIds

                                                                                                                                                      detachIds: DeviceIds;

                                                                                                                                                        interface EndpointDescriptor

                                                                                                                                                        interface EndpointDescriptor {}
                                                                                                                                                        • A structure representing the standard USB endpoint descriptor

                                                                                                                                                        property bDescriptorType

                                                                                                                                                        bDescriptorType: number;
                                                                                                                                                        • Descriptor type.

                                                                                                                                                        property bEndpointAddress

                                                                                                                                                        bEndpointAddress: number;
                                                                                                                                                        • The address of the endpoint described by this descriptor.

                                                                                                                                                        property bInterval

                                                                                                                                                        bInterval: number;
                                                                                                                                                        • Interval for polling endpoint for data transfers.

                                                                                                                                                        property bLength

                                                                                                                                                        bLength: number;
                                                                                                                                                        • Size of this descriptor (in bytes)

                                                                                                                                                        property bmAttributes

                                                                                                                                                        bmAttributes: number;
                                                                                                                                                        • Attributes which apply to the endpoint when it is configured using the bConfigurationValue.

                                                                                                                                                        property bRefresh

                                                                                                                                                        bRefresh: number;
                                                                                                                                                        • For audio devices only: the rate at which synchronization feedback is provided.

                                                                                                                                                        property bSynchAddress

                                                                                                                                                        bSynchAddress: number;
                                                                                                                                                        • For audio devices only: the address if the synch endpoint.

                                                                                                                                                        property extra

                                                                                                                                                        extra: Buffer;
                                                                                                                                                        • Extra descriptors.

                                                                                                                                                          If libusb encounters unknown endpoint descriptors, it will store them here, should you wish to parse them.

                                                                                                                                                        property wMaxPacketSize

                                                                                                                                                        wMaxPacketSize: number;
                                                                                                                                                        • Maximum packet size this endpoint is capable of sending/receiving.

                                                                                                                                                        interface InterfaceDescriptor

                                                                                                                                                        interface InterfaceDescriptor {}
                                                                                                                                                        • A structure representing the standard USB interface descriptor

                                                                                                                                                        property bAlternateSetting

                                                                                                                                                        bAlternateSetting: number;
                                                                                                                                                        • Value used to select this alternate setting for this interface.

                                                                                                                                                        property bDescriptorType

                                                                                                                                                        bDescriptorType: number;
                                                                                                                                                        • Descriptor type.

                                                                                                                                                        property bInterfaceClass

                                                                                                                                                        bInterfaceClass: number;
                                                                                                                                                        • USB-IF class code for this interface.

                                                                                                                                                        property bInterfaceNumber

                                                                                                                                                        bInterfaceNumber: number;
                                                                                                                                                        • Number of this interface.

                                                                                                                                                        property bInterfaceProtocol

                                                                                                                                                        bInterfaceProtocol: number;
                                                                                                                                                        • USB-IF protocol code for this interface, qualified by the bInterfaceClass and bInterfaceSubClass values.

                                                                                                                                                        property bInterfaceSubClass

                                                                                                                                                        bInterfaceSubClass: number;
                                                                                                                                                        • USB-IF subclass code for this interface, qualified by the bInterfaceClass value.

                                                                                                                                                        property bLength

                                                                                                                                                        bLength: number;
                                                                                                                                                        • Size of this descriptor (in bytes)

                                                                                                                                                        property bNumEndpoints

                                                                                                                                                        bNumEndpoints: number;
                                                                                                                                                        • Number of endpoints used by this interface (excluding the control endpoint).

                                                                                                                                                        property endpoints

                                                                                                                                                        endpoints: EndpointDescriptor[];
                                                                                                                                                        • Array of endpoint descriptors.

                                                                                                                                                        property extra

                                                                                                                                                        extra: Buffer;
                                                                                                                                                        • Extra descriptors.

                                                                                                                                                        property iInterface

                                                                                                                                                        iInterface: number;
                                                                                                                                                        • Index of string descriptor describing this interface.

                                                                                                                                                        interface USBOptions

                                                                                                                                                        interface USBOptions {}
                                                                                                                                                        • USB Options

                                                                                                                                                        property allowAllDevices

                                                                                                                                                        allowAllDevices?: boolean;
                                                                                                                                                        • Optional flag to automatically allow all devices

                                                                                                                                                        property allowedDevices

                                                                                                                                                        allowedDevices?: USBDeviceFilter[];
                                                                                                                                                        • Optional array of preconfigured allowed devices

                                                                                                                                                        property devicesFound

                                                                                                                                                        devicesFound?: (devices: USBDevice[]) => Promise<USBDevice | void>;
                                                                                                                                                        • Optional device found callback function to allow the user to select a device

                                                                                                                                                        property deviceTimeout

                                                                                                                                                        deviceTimeout?: number;
                                                                                                                                                        • Optional timeout (in milliseconds) to use for the device control transfers

                                                                                                                                                        Namespaces

                                                                                                                                                        namespace usb

                                                                                                                                                        module 'dist/usb/bindings.d.ts' {}
                                                                                                                                                        • Return a list of Device objects for the USB devices attached to the system.

                                                                                                                                                        variable INIT_ERROR

                                                                                                                                                        const INIT_ERROR: number;

                                                                                                                                                          variable LIBUSB_CAP_HAS_CAPABILITY

                                                                                                                                                          const LIBUSB_CAP_HAS_CAPABILITY: number;

                                                                                                                                                            variable LIBUSB_CAP_HAS_HID_ACCESS

                                                                                                                                                            const LIBUSB_CAP_HAS_HID_ACCESS: number;

                                                                                                                                                              variable LIBUSB_CAP_HAS_HOTPLUG

                                                                                                                                                              const LIBUSB_CAP_HAS_HOTPLUG: number;

                                                                                                                                                                variable LIBUSB_CAP_SUPPORTS_DETACH_KERNEL_DRIVER

                                                                                                                                                                const LIBUSB_CAP_SUPPORTS_DETACH_KERNEL_DRIVER: number;

                                                                                                                                                                  variable LIBUSB_CLASS_APPLICATION

                                                                                                                                                                  const LIBUSB_CLASS_APPLICATION: number;
                                                                                                                                                                  • Application class

                                                                                                                                                                  variable LIBUSB_CLASS_AUDIO

                                                                                                                                                                  const LIBUSB_CLASS_AUDIO: number;
                                                                                                                                                                  • Audio class

                                                                                                                                                                  variable LIBUSB_CLASS_COMM

                                                                                                                                                                  const LIBUSB_CLASS_COMM: number;
                                                                                                                                                                  • Communications class

                                                                                                                                                                  variable LIBUSB_CLASS_DATA

                                                                                                                                                                  const LIBUSB_CLASS_DATA: number;
                                                                                                                                                                  • Data class

                                                                                                                                                                  variable LIBUSB_CLASS_HID

                                                                                                                                                                  const LIBUSB_CLASS_HID: number;
                                                                                                                                                                  • Human Interface Device class

                                                                                                                                                                  variable LIBUSB_CLASS_HUB

                                                                                                                                                                  const LIBUSB_CLASS_HUB: number;
                                                                                                                                                                  • Hub class

                                                                                                                                                                  variable LIBUSB_CLASS_MASS_STORAGE

                                                                                                                                                                  const LIBUSB_CLASS_MASS_STORAGE: number;
                                                                                                                                                                  • Mass storage class

                                                                                                                                                                  variable LIBUSB_CLASS_PER_INTERFACE

                                                                                                                                                                  const LIBUSB_CLASS_PER_INTERFACE: number;
                                                                                                                                                                  • In the context of a \ref libusb_device_descriptor "device descriptor", this bDeviceClass value indicates that each interface specifies its own class information and all interfaces operate independently.

                                                                                                                                                                  variable LIBUSB_CLASS_PRINTER

                                                                                                                                                                  const LIBUSB_CLASS_PRINTER: number;
                                                                                                                                                                  • Printer class

                                                                                                                                                                  variable LIBUSB_CLASS_PTP

                                                                                                                                                                  const LIBUSB_CLASS_PTP: number;
                                                                                                                                                                  • Image class

                                                                                                                                                                  variable LIBUSB_CLASS_VENDOR_SPEC

                                                                                                                                                                  const LIBUSB_CLASS_VENDOR_SPEC: number;
                                                                                                                                                                  • Class is vendor-specific

                                                                                                                                                                  variable LIBUSB_CLASS_WIRELESS

                                                                                                                                                                  const LIBUSB_CLASS_WIRELESS: number;
                                                                                                                                                                  • Wireless class

                                                                                                                                                                  variable LIBUSB_CONTROL_SETUP_SIZE

                                                                                                                                                                  const LIBUSB_CONTROL_SETUP_SIZE: number;

                                                                                                                                                                    variable LIBUSB_DT_BOS

                                                                                                                                                                    const LIBUSB_DT_BOS: number;

                                                                                                                                                                      variable LIBUSB_DT_BOS_SIZE

                                                                                                                                                                      const LIBUSB_DT_BOS_SIZE: number;

                                                                                                                                                                        variable LIBUSB_DT_CONFIG

                                                                                                                                                                        const LIBUSB_DT_CONFIG: number;
                                                                                                                                                                        • Configuration descriptor. See libusb_config_descriptor.

                                                                                                                                                                        variable LIBUSB_DT_DEVICE

                                                                                                                                                                        const LIBUSB_DT_DEVICE: number;
                                                                                                                                                                        • Device descriptor. See libusb_device_descriptor.

                                                                                                                                                                        variable LIBUSB_DT_ENDPOINT

                                                                                                                                                                        const LIBUSB_DT_ENDPOINT: number;
                                                                                                                                                                        • Endpoint descriptor. See libusb_endpoint_descriptor.

                                                                                                                                                                        variable LIBUSB_DT_HID

                                                                                                                                                                        const LIBUSB_DT_HID: number;
                                                                                                                                                                        • HID descriptor

                                                                                                                                                                        variable LIBUSB_DT_HUB

                                                                                                                                                                        const LIBUSB_DT_HUB: number;
                                                                                                                                                                        • Hub descriptor

                                                                                                                                                                        variable LIBUSB_DT_INTERFACE

                                                                                                                                                                        const LIBUSB_DT_INTERFACE: number;
                                                                                                                                                                        • Interface descriptor. See libusb_interface_descriptor.

                                                                                                                                                                        variable LIBUSB_DT_PHYSICAL

                                                                                                                                                                        const LIBUSB_DT_PHYSICAL: number;
                                                                                                                                                                        • Physical descriptor

                                                                                                                                                                        variable LIBUSB_DT_REPORT

                                                                                                                                                                        const LIBUSB_DT_REPORT: number;
                                                                                                                                                                        • HID report descriptor

                                                                                                                                                                        variable LIBUSB_DT_STRING

                                                                                                                                                                        const LIBUSB_DT_STRING: number;
                                                                                                                                                                        • String descriptor

                                                                                                                                                                        variable LIBUSB_ENDPOINT_IN

                                                                                                                                                                        const LIBUSB_ENDPOINT_IN: number;
                                                                                                                                                                        • In: device-to-host

                                                                                                                                                                        variable LIBUSB_ENDPOINT_OUT

                                                                                                                                                                        const LIBUSB_ENDPOINT_OUT: number;
                                                                                                                                                                        • Out: host-to-device

                                                                                                                                                                        variable LIBUSB_ERROR_ACCESS

                                                                                                                                                                        const LIBUSB_ERROR_ACCESS: number;
                                                                                                                                                                        • Access denied (insufficient permissions)

                                                                                                                                                                        variable LIBUSB_ERROR_BUSY

                                                                                                                                                                        const LIBUSB_ERROR_BUSY: number;
                                                                                                                                                                        • Resource busy

                                                                                                                                                                        variable LIBUSB_ERROR_INTERRUPTED

                                                                                                                                                                        const LIBUSB_ERROR_INTERRUPTED: number;
                                                                                                                                                                        • System call interrupted (perhaps due to signal)

                                                                                                                                                                        variable LIBUSB_ERROR_INVALID_PARAM

                                                                                                                                                                        const LIBUSB_ERROR_INVALID_PARAM: number;
                                                                                                                                                                        • Invalid parameter

                                                                                                                                                                        variable LIBUSB_ERROR_IO

                                                                                                                                                                        const LIBUSB_ERROR_IO: number;
                                                                                                                                                                        • Input/output error

                                                                                                                                                                        variable LIBUSB_ERROR_NO_DEVICE

                                                                                                                                                                        const LIBUSB_ERROR_NO_DEVICE: number;
                                                                                                                                                                        • No such device (it may have been disconnected)

                                                                                                                                                                        variable LIBUSB_ERROR_NO_MEM

                                                                                                                                                                        const LIBUSB_ERROR_NO_MEM: number;
                                                                                                                                                                        • Insufficient memory

                                                                                                                                                                        variable LIBUSB_ERROR_NOT_FOUND

                                                                                                                                                                        const LIBUSB_ERROR_NOT_FOUND: number;
                                                                                                                                                                        • Entity not found

                                                                                                                                                                        variable LIBUSB_ERROR_NOT_SUPPORTED

                                                                                                                                                                        const LIBUSB_ERROR_NOT_SUPPORTED: number;
                                                                                                                                                                        • Operation not supported or unimplemented on this platform

                                                                                                                                                                        variable LIBUSB_ERROR_OTHER

                                                                                                                                                                        const LIBUSB_ERROR_OTHER: number;
                                                                                                                                                                        • Other error

                                                                                                                                                                        variable LIBUSB_ERROR_OVERFLOW

                                                                                                                                                                        const LIBUSB_ERROR_OVERFLOW: number;
                                                                                                                                                                        • Overflow

                                                                                                                                                                        variable LIBUSB_ERROR_PIPE

                                                                                                                                                                        const LIBUSB_ERROR_PIPE: number;
                                                                                                                                                                        • Pipe error

                                                                                                                                                                        variable LIBUSB_ERROR_TIMEOUT

                                                                                                                                                                        const LIBUSB_ERROR_TIMEOUT: number;
                                                                                                                                                                        • Operation timed out

                                                                                                                                                                        variable LIBUSB_ISO_SYNC_TYPE_ADAPTIVE

                                                                                                                                                                        const LIBUSB_ISO_SYNC_TYPE_ADAPTIVE: number;
                                                                                                                                                                        • Adaptive

                                                                                                                                                                        variable LIBUSB_ISO_SYNC_TYPE_ASYNC

                                                                                                                                                                        const LIBUSB_ISO_SYNC_TYPE_ASYNC: number;
                                                                                                                                                                        • Asynchronous

                                                                                                                                                                        variable LIBUSB_ISO_SYNC_TYPE_NONE

                                                                                                                                                                        const LIBUSB_ISO_SYNC_TYPE_NONE: number;
                                                                                                                                                                        • No synchronization

                                                                                                                                                                        variable LIBUSB_ISO_SYNC_TYPE_SYNC

                                                                                                                                                                        const LIBUSB_ISO_SYNC_TYPE_SYNC: number;
                                                                                                                                                                        • Synchronous

                                                                                                                                                                        variable LIBUSB_ISO_USAGE_TYPE_DATA

                                                                                                                                                                        const LIBUSB_ISO_USAGE_TYPE_DATA: number;
                                                                                                                                                                        • Data endpoint

                                                                                                                                                                        variable LIBUSB_ISO_USAGE_TYPE_FEEDBACK

                                                                                                                                                                        const LIBUSB_ISO_USAGE_TYPE_FEEDBACK: number;
                                                                                                                                                                        • Feedback endpoint

                                                                                                                                                                        variable LIBUSB_ISO_USAGE_TYPE_IMPLICIT

                                                                                                                                                                        const LIBUSB_ISO_USAGE_TYPE_IMPLICIT: number;
                                                                                                                                                                        • Implicit feedback Data endpoint

                                                                                                                                                                        variable LIBUSB_RECIPIENT_DEVICE

                                                                                                                                                                        const LIBUSB_RECIPIENT_DEVICE: number;
                                                                                                                                                                        • Device

                                                                                                                                                                        variable LIBUSB_RECIPIENT_ENDPOINT

                                                                                                                                                                        const LIBUSB_RECIPIENT_ENDPOINT: number;
                                                                                                                                                                        • Endpoint

                                                                                                                                                                        variable LIBUSB_RECIPIENT_INTERFACE

                                                                                                                                                                        const LIBUSB_RECIPIENT_INTERFACE: number;
                                                                                                                                                                        • Interface

                                                                                                                                                                        variable LIBUSB_RECIPIENT_OTHER

                                                                                                                                                                        const LIBUSB_RECIPIENT_OTHER: number;
                                                                                                                                                                        • Other

                                                                                                                                                                        variable LIBUSB_REQUEST_CLEAR_FEATURE

                                                                                                                                                                        const LIBUSB_REQUEST_CLEAR_FEATURE: number;
                                                                                                                                                                        • Clear or disable a specific feature

                                                                                                                                                                        variable LIBUSB_REQUEST_GET_CONFIGURATION

                                                                                                                                                                        const LIBUSB_REQUEST_GET_CONFIGURATION: number;
                                                                                                                                                                        • Get the current device configuration value

                                                                                                                                                                        variable LIBUSB_REQUEST_GET_DESCRIPTOR

                                                                                                                                                                        const LIBUSB_REQUEST_GET_DESCRIPTOR: number;
                                                                                                                                                                        • Get the specified descriptor

                                                                                                                                                                        variable LIBUSB_REQUEST_GET_INTERFACE

                                                                                                                                                                        const LIBUSB_REQUEST_GET_INTERFACE: number;
                                                                                                                                                                        • Return the selected alternate setting for the specified interface

                                                                                                                                                                        variable LIBUSB_REQUEST_GET_STATUS

                                                                                                                                                                        const LIBUSB_REQUEST_GET_STATUS: number;
                                                                                                                                                                        • Request status of the specific recipient

                                                                                                                                                                        variable LIBUSB_REQUEST_SET_ADDRESS

                                                                                                                                                                        const LIBUSB_REQUEST_SET_ADDRESS: number;
                                                                                                                                                                        • Set device address for all future accesses

                                                                                                                                                                        variable LIBUSB_REQUEST_SET_CONFIGURATION

                                                                                                                                                                        const LIBUSB_REQUEST_SET_CONFIGURATION: number;
                                                                                                                                                                        • Set device configuration

                                                                                                                                                                        variable LIBUSB_REQUEST_SET_DESCRIPTOR

                                                                                                                                                                        const LIBUSB_REQUEST_SET_DESCRIPTOR: number;
                                                                                                                                                                        • Used to update existing descriptors or add new descriptors

                                                                                                                                                                        variable LIBUSB_REQUEST_SET_FEATURE

                                                                                                                                                                        const LIBUSB_REQUEST_SET_FEATURE: number;
                                                                                                                                                                        • Set or enable a specific feature

                                                                                                                                                                        variable LIBUSB_REQUEST_SET_INTERFACE

                                                                                                                                                                        const LIBUSB_REQUEST_SET_INTERFACE: number;
                                                                                                                                                                        • Select an alternate interface for the specified interface

                                                                                                                                                                        variable LIBUSB_REQUEST_SYNCH_FRAME

                                                                                                                                                                        const LIBUSB_REQUEST_SYNCH_FRAME: number;
                                                                                                                                                                        • Set then report an endpoint's synchronization frame

                                                                                                                                                                        variable LIBUSB_REQUEST_TYPE_CLASS

                                                                                                                                                                        const LIBUSB_REQUEST_TYPE_CLASS: number;
                                                                                                                                                                        • Class

                                                                                                                                                                        variable LIBUSB_REQUEST_TYPE_RESERVED

                                                                                                                                                                        const LIBUSB_REQUEST_TYPE_RESERVED: number;
                                                                                                                                                                        • Reserved

                                                                                                                                                                        variable LIBUSB_REQUEST_TYPE_STANDARD

                                                                                                                                                                        const LIBUSB_REQUEST_TYPE_STANDARD: number;
                                                                                                                                                                        • Standard

                                                                                                                                                                        variable LIBUSB_REQUEST_TYPE_VENDOR

                                                                                                                                                                        const LIBUSB_REQUEST_TYPE_VENDOR: number;
                                                                                                                                                                        • Vendor

                                                                                                                                                                        variable LIBUSB_TRANSFER_CANCELLED

                                                                                                                                                                        const LIBUSB_TRANSFER_CANCELLED: number;
                                                                                                                                                                        • Transfer was cancelled

                                                                                                                                                                        variable LIBUSB_TRANSFER_COMPLETED

                                                                                                                                                                        const LIBUSB_TRANSFER_COMPLETED: number;
                                                                                                                                                                        • Transfer completed without error. Note that this does not indicate that the entire amount of requested data was transferred.

                                                                                                                                                                        variable LIBUSB_TRANSFER_ERROR

                                                                                                                                                                        const LIBUSB_TRANSFER_ERROR: number;
                                                                                                                                                                        • Transfer failed

                                                                                                                                                                        variable LIBUSB_TRANSFER_FREE_BUFFER

                                                                                                                                                                        const LIBUSB_TRANSFER_FREE_BUFFER: number;
                                                                                                                                                                        • Automatically free() transfer buffer during libusb_free_transfer(). Note that buffers allocated with libusb_dev_mem_alloc() should not be attempted freed in this way, since free() is not an appropriate way to release such memory.

                                                                                                                                                                        variable LIBUSB_TRANSFER_FREE_TRANSFER

                                                                                                                                                                        const LIBUSB_TRANSFER_FREE_TRANSFER: number;
                                                                                                                                                                        • Automatically call libusb_free_transfer() after callback returns. If this flag is set, it is illegal to call libusb_free_transfer() from your transfer callback, as this will result in a double-free when this flag is acted upon.

                                                                                                                                                                        variable LIBUSB_TRANSFER_NO_DEVICE

                                                                                                                                                                        const LIBUSB_TRANSFER_NO_DEVICE: number;
                                                                                                                                                                        • Device was disconnected

                                                                                                                                                                        variable LIBUSB_TRANSFER_OVERFLOW

                                                                                                                                                                        const LIBUSB_TRANSFER_OVERFLOW: number;
                                                                                                                                                                        • Device sent more data than requested

                                                                                                                                                                        variable LIBUSB_TRANSFER_SHORT_NOT_OK

                                                                                                                                                                        const LIBUSB_TRANSFER_SHORT_NOT_OK: number;
                                                                                                                                                                        • Report short frames as errors

                                                                                                                                                                        variable LIBUSB_TRANSFER_STALL

                                                                                                                                                                        const LIBUSB_TRANSFER_STALL: number;
                                                                                                                                                                        • For bulk/interrupt endpoints: halt condition detected (endpoint stalled). For control endpoints: control request not supported.

                                                                                                                                                                        variable LIBUSB_TRANSFER_TIMED_OUT

                                                                                                                                                                        const LIBUSB_TRANSFER_TIMED_OUT: number;
                                                                                                                                                                        • Transfer timed out

                                                                                                                                                                        variable LIBUSB_TRANSFER_TYPE_BULK

                                                                                                                                                                        const LIBUSB_TRANSFER_TYPE_BULK: number;
                                                                                                                                                                        • Bulk endpoint

                                                                                                                                                                        variable LIBUSB_TRANSFER_TYPE_CONTROL

                                                                                                                                                                        const LIBUSB_TRANSFER_TYPE_CONTROL: number;
                                                                                                                                                                        • Control endpoint

                                                                                                                                                                        variable LIBUSB_TRANSFER_TYPE_INTERRUPT

                                                                                                                                                                        const LIBUSB_TRANSFER_TYPE_INTERRUPT: number;
                                                                                                                                                                        • Interrupt endpoint

                                                                                                                                                                        variable LIBUSB_TRANSFER_TYPE_ISOCHRONOUS

                                                                                                                                                                        const LIBUSB_TRANSFER_TYPE_ISOCHRONOUS: number;
                                                                                                                                                                        • Isochronous endpoint

                                                                                                                                                                        variable pollHotplug

                                                                                                                                                                        let pollHotplug: boolean;
                                                                                                                                                                        • Force polling loop for hotplug events

                                                                                                                                                                        variable pollHotplugDelay

                                                                                                                                                                        let pollHotplugDelay: number;
                                                                                                                                                                        • Hotplug polling loop delay (ms)

                                                                                                                                                                        function getDeviceList

                                                                                                                                                                        getDeviceList: () => Device[];
                                                                                                                                                                        • Return a list of Device objects for the USB devices attached to the system.

                                                                                                                                                                        function refHotplugEvents

                                                                                                                                                                        refHotplugEvents: () => void;
                                                                                                                                                                        • Restore (re-reference) the hotplug events unreferenced by unrefHotplugEvents()

                                                                                                                                                                        function setDebugLevel

                                                                                                                                                                        setDebugLevel: (level: number) => void;
                                                                                                                                                                        • Set the libusb debug level (between 0 and 4)

                                                                                                                                                                          Parameter level

                                                                                                                                                                          libusb debug level (between 0 and 4)

                                                                                                                                                                        function unrefHotplugEvents

                                                                                                                                                                        unrefHotplugEvents: () => void;
                                                                                                                                                                        • Unreference the hotplug events from the event loop, allowing the process to exit even when listening for the attach and detach events

                                                                                                                                                                        function useUsbDkBackend

                                                                                                                                                                        useUsbDkBackend: () => void;
                                                                                                                                                                        • Use USBDK Backend (Windows only)

                                                                                                                                                                        class Device

                                                                                                                                                                        class Device {}
                                                                                                                                                                        • Represents a USB device.

                                                                                                                                                                        property busNumber

                                                                                                                                                                        busNumber: number;
                                                                                                                                                                        • Integer USB device number

                                                                                                                                                                        property deviceAddress

                                                                                                                                                                        deviceAddress: number;
                                                                                                                                                                        • Integer USB device address

                                                                                                                                                                        property deviceDescriptor

                                                                                                                                                                        deviceDescriptor: DeviceDescriptor;
                                                                                                                                                                        • Object with properties for the fields of the device descriptor.

                                                                                                                                                                        property portNumbers

                                                                                                                                                                        portNumbers: number[];
                                                                                                                                                                        • Array containing the USB device port numbers, or undefined if not supported on this platform.

                                                                                                                                                                        method reset

                                                                                                                                                                        reset: (callback: (error?: LibUSBException) => void) => void;
                                                                                                                                                                        • Performs a reset of the device. Callback is called when complete.

                                                                                                                                                                          The device must be open to use this method.

                                                                                                                                                                          Parameter callback

                                                                                                                                                                        class LibUSBException

                                                                                                                                                                        class LibUSBException extends Error {}

                                                                                                                                                                          property errno

                                                                                                                                                                          errno: number;

                                                                                                                                                                            class Transfer

                                                                                                                                                                            class Transfer {}
                                                                                                                                                                            • Represents a USB transfer

                                                                                                                                                                            constructor

                                                                                                                                                                            constructor(
                                                                                                                                                                            device: Device,
                                                                                                                                                                            endpointAddr: number,
                                                                                                                                                                            type: number,
                                                                                                                                                                            timeout: number,
                                                                                                                                                                            callback: (error: LibUSBException, buf: Buffer, actual: number) => void
                                                                                                                                                                            );

                                                                                                                                                                              method cancel

                                                                                                                                                                              cancel: () => boolean;
                                                                                                                                                                              • Cancel the transfer.

                                                                                                                                                                                Returns true if the transfer was canceled, false if it wasn't in pending state.

                                                                                                                                                                              method submit

                                                                                                                                                                              submit: (
                                                                                                                                                                              buffer: Buffer,
                                                                                                                                                                              callback?: (
                                                                                                                                                                              error: LibUSBException | undefined,
                                                                                                                                                                              buffer: Buffer,
                                                                                                                                                                              actualLength: number
                                                                                                                                                                              ) => void
                                                                                                                                                                              ) => Transfer;
                                                                                                                                                                              • (Re-)submit the transfer.

                                                                                                                                                                                Parameter buffer

                                                                                                                                                                                Buffer where data will be written (for IN transfers) or read from (for OUT transfers).

                                                                                                                                                                              namespace usb

                                                                                                                                                                              namespace usb {}

                                                                                                                                                                                function addListener

                                                                                                                                                                                addListener: <K extends keyof DeviceEvents>(
                                                                                                                                                                                event: K,
                                                                                                                                                                                listener: (arg: DeviceEvents[K]) => void
                                                                                                                                                                                ) => void;

                                                                                                                                                                                  function emit

                                                                                                                                                                                  emit: <K extends keyof DeviceEvents>(event: K, arg: DeviceEvents[K]) => boolean;

                                                                                                                                                                                    function listenerCount

                                                                                                                                                                                    listenerCount: <K extends keyof DeviceEvents>(event: K) => number;

                                                                                                                                                                                      function listeners

                                                                                                                                                                                      listeners: <K extends keyof DeviceEvents>(
                                                                                                                                                                                      event: K
                                                                                                                                                                                      ) => ((arg: DeviceEvents[K]) => void)[];

                                                                                                                                                                                        function off

                                                                                                                                                                                        off: <K extends keyof DeviceEvents>(
                                                                                                                                                                                        event: K,
                                                                                                                                                                                        listener: (arg: DeviceEvents[K]) => void
                                                                                                                                                                                        ) => void;

                                                                                                                                                                                          function on

                                                                                                                                                                                          on: <K extends keyof DeviceEvents>(
                                                                                                                                                                                          event: K,
                                                                                                                                                                                          listener: (arg: DeviceEvents[K]) => void
                                                                                                                                                                                          ) => void;

                                                                                                                                                                                            function once

                                                                                                                                                                                            once: <K extends keyof DeviceEvents>(
                                                                                                                                                                                            event: K,
                                                                                                                                                                                            listener: (arg: DeviceEvents[K]) => void
                                                                                                                                                                                            ) => void;

                                                                                                                                                                                              function rawListeners

                                                                                                                                                                                              rawListeners: <K extends keyof DeviceEvents>(
                                                                                                                                                                                              event: K
                                                                                                                                                                                              ) => ((arg: DeviceEvents[K]) => void)[];

                                                                                                                                                                                                function removeAllListeners

                                                                                                                                                                                                removeAllListeners: <K extends keyof DeviceEvents>(event?: K) => void;

                                                                                                                                                                                                  function removeListener

                                                                                                                                                                                                  removeListener: <K extends keyof DeviceEvents>(
                                                                                                                                                                                                  event: K,
                                                                                                                                                                                                  listener: (arg: DeviceEvents[K]) => void
                                                                                                                                                                                                  ) => void;

                                                                                                                                                                                                    interface Device

                                                                                                                                                                                                    interface Device extends ExtendedDevice {}

                                                                                                                                                                                                      interface DeviceEvents

                                                                                                                                                                                                      interface DeviceEvents extends EventListeners<DeviceEvents> {}

                                                                                                                                                                                                        property attach

                                                                                                                                                                                                        attach: Device;

                                                                                                                                                                                                          property attachIds

                                                                                                                                                                                                          attachIds: DeviceIds;

                                                                                                                                                                                                            property detach

                                                                                                                                                                                                            detach: Device;

                                                                                                                                                                                                              property detachIds

                                                                                                                                                                                                              detachIds: DeviceIds;

                                                                                                                                                                                                                Package Files (9)

                                                                                                                                                                                                                Dependencies (3)

                                                                                                                                                                                                                Dev Dependencies (12)

                                                                                                                                                                                                                Peer Dependencies (0)

                                                                                                                                                                                                                No peer dependencies.

                                                                                                                                                                                                                Badge

                                                                                                                                                                                                                To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                                                                                                                                                                You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/usb.

                                                                                                                                                                                                                • Markdown
                                                                                                                                                                                                                  [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/usb)
                                                                                                                                                                                                                • HTML
                                                                                                                                                                                                                  <a href="https://www.jsdocs.io/package/usb"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>