USB Device

Hierarchy

  • USBDevice

Implements

  • W3CUSBDevice

Index

Properties

deviceClass

deviceClass: number

Communication interface class of the device

deviceProtocol

deviceProtocol: number

Communication interface protocol of the device

deviceSubclass

deviceSubclass: number

Communication interface sub class of the device

deviceVersionMajor

deviceVersionMajor: number

Major version of the device

deviceVersionMinor

deviceVersionMinor: number

Minor version of the device

deviceVersionSubminor

deviceVersionSubminor: number

Sub minor version of the device

manufacturerName

manufacturerName: string = null

Manufacturer name of the device

productId

productId: number

Product Identifier of the device

productName

productName: string = null

Product name of the device

serialNumber

serialNumber: string = null

Serial number of the device

url

url: string = null

URL advertised by the device (not part of Web USB specification)

usbVersionMajor

usbVersionMajor: number

Major USB protocol version supported by the device

usbVersionMinor

usbVersionMinor: number

Minor USB protocol version supported by the device

usbVersionSubminor

usbVersionSubminor: number

Sub minor USB protocol version supported by the device

vendorId

vendorId: number

Vendor Identifier of the device

Accessors

configuration

configurations

  • List of configurations supported by the device

    Returns Array<USBConfiguration>

opened

  • get opened(): boolean
  • A flag indicating whether the device is open

    Returns boolean

Methods

claimInterface

  • claimInterface(interfaceNumber: number): Promise<void>
  • Claim an interface on the device

    Parameters

    • interfaceNumber: number

      The interface number to claim

    Returns Promise<void>

    Promise containing any error

clearHalt

  • clearHalt(direction: USBDirection, endpointNumber: number): Promise<void>
  • Clear a halt condition on an endpoint

    Parameters

    • direction: USBDirection

      The direction of the endpoint to clear

    • endpointNumber: number

      The endpoint number of the endpoint to clear

    Returns Promise<void>

    Promise containing any error

close

  • close(): Promise<void>
  • Closes the device

    Returns Promise<void>

controlTransferIn

  • controlTransferIn(setup: USBControlTransferParameters, length: number): Promise<USBInTransferResult>
  • Undertake a control transfer in from the device

    Parameters

    • setup: USBControlTransferParameters

      The USB control transfer parameters

    • length: number

      The amount of data to transfer

    Returns Promise<USBInTransferResult>

    Promise containing a result

controlTransferOut

  • controlTransferOut(setup: USBControlTransferParameters, data?: BufferSource): Promise<USBOutTransferResult>
  • Undertake a control transfer out to the device

    Note: The bytesWritten always set to the length of the data

    Parameters

    • setup: USBControlTransferParameters

      The USB control transfer parameters

    • Optional data: BufferSource

      The data to transfer

    Returns Promise<USBOutTransferResult>

    Promise containing a result

open

  • open(): Promise<void>
  • Opens the device

    Returns Promise<void>

releaseInterface

  • releaseInterface(interfaceNumber: number): Promise<void>
  • Release an interface on the device

    Parameters

    • interfaceNumber: number

      The interface number to release

    Returns Promise<void>

    Promise containing any error

reset

  • reset(): Promise<void>
  • Soft reset the device

    Returns Promise<void>

    Promise containing any error

selectAlternateInterface

  • selectAlternateInterface(interfaceNumber: number, alternateSetting: number): Promise<void>
  • Select an alternate interface on the device

    Parameters

    • interfaceNumber: number

      The interface number to change

    • alternateSetting: number

      The alternate setting to use

    Returns Promise<void>

    Promise containing any error

selectConfiguration

  • selectConfiguration(configurationValue: number): Promise<void>
  • Select a configuration for the device

    Parameters

    • configurationValue: number

      The configuration value to select

    Returns Promise<void>

    Promise containing any error

transferIn

  • transferIn(endpointNumber: number, length: number): Promise<USBInTransferResult>
  • Undertake a transfer in from the device

    Parameters

    • endpointNumber: number

      The number of the endpoint to transfer from

    • length: number

      The amount of data to transfer

    Returns Promise<USBInTransferResult>

    Promise containing a result

transferOut

  • transferOut(endpointNumber: number, data: BufferSource): Promise<USBOutTransferResult>
  • Undertake a transfer out to the device

    Note: The bytesWritten always set to the length of the data

    Parameters

    • endpointNumber: number

      The number of the endpoint to transfer to

    • data: BufferSource

      The data to transfer

    Returns Promise<USBOutTransferResult>

    Promise containing a result