Class Device

Represents a USB device.

Hierarchy

  • ExtendedDevice
    • Device

Constructors

Properties

_bosDescriptor?: BosDescriptor
busNumber: number

Integer USB device number

deviceAddress: number

Integer USB device address

deviceDescriptor: DeviceDescriptor

Object with properties for the fields of the device descriptor.

interfaces: undefined | Interface[]

List of Interface objects for the interfaces of the default configuration of the device.

portNumbers: number[]

Array containing the USB device port numbers, or undefined if not supported on this platform.

Accessors

  • get parent(): Device
  • Contains the parent of the device, such as a hub. If there is no parent this property is set to null.

    Returns Device

  • get timeout(): number
  • Timeout in milliseconds to use for control transfers.

    Returns number

  • set timeout(value): void
  • Parameters

    • value: number

    Returns void

Methods

  • Close the device.

    The device must be open to use this method.

    Parameters

    Returns void

  • Perform a control transfer with libusb_control_transfer.

    Parameter data_or_length can be an integer length for an IN transfer, or a Buffer for an OUT transfer. The type must match the direction specified in the MSB of bmRequestType.

    The data parameter of the callback is actual transferred for OUT transfers, or will be passed a Buffer for IN transfers.

    The device must be open to use this method.

    Parameters

    • this: Device
    • bmRequestType: number
    • bRequest: number
    • wValue: number
    • wIndex: number
    • data_or_length: number | Buffer
    • Optionalcallback: ((error: undefined | LibUSBException, buffer: undefined | number | Buffer) => void)
        • (error, buffer): void
        • Parameters

          Returns void

    Returns Device

  • Perform a control transfer to retrieve an object with properties for the fields of the Binary Object Store descriptor.

    The device must be open to use this method.

    Parameters

    Returns void

  • Retrieve a list of Capability objects for the Binary Object Store capabilities of the device.

    The device must be open to use this method.

    Parameters

    Returns void

  • Perform a control transfer to retrieve a string descriptor

    The device must be open to use this method.

    Parameters

    • this: Device
    • desc_index: number
    • callback: ((error?: LibUSBException, value?: string) => void)
        • (error?, value?): void
        • Parameters

          Returns void

    Returns void

  • Open the device.

    Parameters

    • this: Device
    • defaultConfig: boolean = true

    Returns void

  • Performs a reset of the device. Callback is called when complete.

    The device must be open to use this method.

    Parameters

    Returns void

  • Set the device configuration to something other than the default (0). To use this, first call .open(false) (which tells it not to auto configure), then before claiming an interface, call this method.

    The device must be open to use this method.

    Parameters

    Returns void