大网数据广告活动
Web 标准与前端开发

USBDevice

· 52CE 我爱测

The **`USBDevice`** interface of the WebUSB API provides access to metadata about a paired USB device and methods for controlling it.

WebUSB API

The USBDevice interface of the WebUSB API provides access to metadata about a paired USB device and methods for controlling it.

Instance properties

  • USBDevice.configuration
    • : A USBConfiguration object for the currently selected interface for a paired USB device.
  • USBDevice.configurations
    • : An Array of device-specific interfaces for controlling a paired USB device.
  • USBDevice.deviceClass
    • : One of three properties that identify USB devices for the purpose of loading a USB driver that will work with that device. The other two properties are USBDevice.deviceSubclass and USBDevice.deviceProtocol.
  • USBDevice.deviceProtocol
    • : One of three properties that identify USB devices for the purpose of loading a USB driver that will work with that device. The other two properties are USBDevice.deviceClass and USBDevice.deviceSubclass.
  • USBDevice.deviceSubclass
    • : One of three properties that identify USB devices for the purpose of loading a USB driver that will work with that device. The other two properties are USBDevice.deviceClass and USBDevice.deviceProtocol.
  • USBDevice.deviceVersionMajor
    • : The major version number of the device in a semantic versioning scheme.
  • USBDevice.deviceVersionMinor
    • : The minor version number of the device in a semantic versioning scheme.
  • USBDevice.deviceVersionSubminor
    • : The patch version number of the device in a semantic versioning scheme.
  • USBDevice.manufacturerName
    • : The name of the organization that manufactured the USB device.
  • USBDevice.opened
    • : Indicates whether a session has been started with a paired USB device.
  • USBDevice.productId
    • : The manufacturer-defined code that identifies a USB device.
  • USBDevice.productName
    • : The manufacturer-defined name that identifies a USB device.
  • USBDevice.serialNumber
    • : The manufacturer-defined serial number for the specific USB device.
  • USBDevice.usbVersionMajor
    • : One of three properties that declare the USB protocol version supported by the device. The other two properties are USBDevice.usbVersionMinor and USBDevice.usbVersionSubminor.
  • USBDevice.usbVersionMinor
    • : One of three properties that declare the USB protocol version supported by the device. The other two properties are USBDevice.usbVersionMajor and USBDevice.usbVersionSubminor.
  • USBDevice.usbVersionSubminor
    • : One of three properties that declare the USB protocol version supported by the device. The other two properties are USBDevice.usbVersionMajor and USBDevice.usbVersionMinor.
  • USBDevice.vendorId
    • : The official usb.org-assigned vendor ID.

Instance methods

  • USBDevice.claimInterface()
    • : Returns a Promise that resolves when the requested interface is claimed for exclusive access.
  • USBDevice.clearHalt()
    • : Returns a Promise that resolves when a halt condition is cleared.
  • USBDevice.controlTransferIn()
    • : Returns a Promise that resolves with a USBInTransferResult when a command or status operation has been transmitted to the USB device.
  • USBDevice.controlTransferOut()
    • : Returns a Promise that resolves with a USBOutTransferResult when a command or status operation has been transmitted from the USB device.
  • USBDevice.close()
    • : Returns a Promise that resolves when all open interfaces are released and the device session has ended.
  • USBDevice.forget()
    • : Returns a Promise that resolves after all open interfaces are released, the device session has ended, and the permission is reset.
  • USBDevice.isochronousTransferIn()
    • : Returns a Promise that resolves with a USBIsochronousInTransferResult when time sensitive information has been transmitted to the USB device.
  • USBDevice.isochronousTransferOut()
    • : Returns a Promise that resolves with a USBIsochronousOutTransferResult when time sensitive information has been transmitted from the USB device.
  • USBDevice.open()
    • : Returns a Promise that resolves when a device session has started.
  • USBDevice.releaseInterface()
    • : Returns a Promise that resolves when a claimed interface is released from exclusive access.
  • USBDevice.reset()
    • : Returns a Promise that resolves when the device is reset and all app operations canceled and their promises rejected.
  • USBDevice.selectAlternateInterface()
    • : Returns a Promise that resolves when the specified alternative endpoint is selected.
  • USBDevice.selectConfiguration()
    • : Returns a Promise that resolves when the specified configuration is selected.
  • USBDevice.transferIn()
    • : Returns a Promise that resolves with a USBInTransferResult when bulk or interrupt data is received from the USB device.
  • USBDevice.transferOut()
    • : Returns a Promise that resolves with a USBOutTransferResult when bulk or interrupt data is sent to the USB device.

Specifications

Browser compatibility

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。