Table of Contents

Class USBDevice

Namespace
CSharpToJavaScript.APIs.JS
Assembly
CSharpToJavaScript.dll
NOTE
Experimental
The USBDevice interface of the WebUSB API provides access to metadata about a paired USB device and methods for controlling it.
[Value("USBDevice")]
public class USBDevice
Inheritance
USBDevice
Inherited Members

Remarks

Constructors

USBDevice()

public USBDevice()

Properties

Configuration

NOTE
Experimental
The configuration read only property of the
USBDevice interface returns a USBConfiguration object for
the currently selected interface for a paired USB device.
[Value("configuration")]
public USBConfiguration? Configuration { get; }

Property Value

USBConfiguration

A USBConfiguration object.

Remarks

Configurations

NOTE
Experimental
The configurations read only property of the
USBDevice interface an {{jsxref("array")}} of device-specific interfaces
for controlling a paired USB device.
[Value("configurations")]
public USBConfiguration[] Configurations { get; }

Property Value

USBConfiguration[]

An {{jsxref("array")}} of USBConfiguration objects.

Remarks

DeviceClass

NOTE
Experimental
The deviceClass read only property of the
USBDevice interface 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.
[Value("deviceClass")]
public byte DeviceClass { get; }

Property Value

byte

A number.

Remarks

DeviceProtocol

NOTE
Experimental
The deviceProtocol read only property of the
USBDevice interface 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.
[Value("deviceProtocol")]
public byte DeviceProtocol { get; }

Property Value

byte

A number.

Remarks

DeviceSubclass

NOTE
Experimental
The deviceSubclass read only property of the
USBDevice interface 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.
[Value("deviceSubclass")]
public byte DeviceSubclass { get; }

Property Value

byte

A number.

Remarks

DeviceVersionMajor

NOTE
Experimental
The deviceVersionMajor read only property of the
USBDevice interface he major version number of the device in a semantic
versioning scheme.
[Value("deviceVersionMajor")]
public byte DeviceVersionMajor { get; }

Property Value

byte

A number.

Remarks

DeviceVersionMinor

NOTE
Experimental
The deviceVersionMinor read only property of the
USBDevice interface the minor version number of the device in a semantic
versioning scheme.
[Value("deviceVersionMinor")]
public byte DeviceVersionMinor { get; }

Property Value

byte

A number.

Remarks

DeviceVersionSubminor

NOTE
Experimental
The deviceVersionSubminor read only property of the
USBDevice interface the patch version number of the device in a semantic
versioning scheme.
[Value("deviceVersionSubminor")]
public byte DeviceVersionSubminor { get; }

Property Value

byte

A number.

Remarks

ManufacturerName

NOTE
Experimental
The manufacturerName read only property of the
USBDevice interface the of the organization that manufactured the USB
device.
[Value("manufacturerName")]
public string? ManufacturerName { get; }

Property Value

string

A string.

Remarks

Opened

NOTE
Experimental
The opened read only property of the
USBDevice interface indicates whether a session has been started with a
paired USB device. A device must be opened before it can be controlled by a web page.
[Value("opened")]
public bool Opened { get; }

Property Value

bool

A Boolean.

Remarks

ProductId

NOTE
Experimental
The productId read only property of the
USBDevice interface the manufacturer-defined code that identifies a USB
device.
[Value("productId")]
public ushort ProductId { get; }

Property Value

ushort

The manufacturer-defined code that identifies a USB device.

Remarks

ProductName

NOTE
Experimental
The productName read only property of the
USBDevice interface the manufacturer-defined name that identifies a USB
device.
[Value("productName")]
public string? ProductName { get; }

Property Value

string

The manufacturer-defined name that identifies a USB device.

Remarks

SerialNumber

NOTE
Experimental
The serialNumber read only property of the
USBDevice interface is the manufacturer-defined serial number for the
specific USB device.
[Value("serialNumber")]
public string? SerialNumber { get; }

Property Value

string

The serial number for the specified USB device

Remarks

UsbVersionMajor

NOTE
Experimental
The usbVersionMajor read only property of the
USBDevice interface is one of three properties that declare the USB
protocol version supported by the device. The other two properties
are USBDevice.usbVersionMinor and USBDevice.usbVersionSubminor.
[Value("usbVersionMajor")]
public byte UsbVersionMajor { get; }

Property Value

byte

The last of three properties that declare the USB protocol version supported by the
device.

Remarks

UsbVersionMinor

NOTE
Experimental
The usbVersionMinor read only property of the
USBDevice interface is one of three properties that declare the USB
protocol version supported by the device. The other two properties
are USBDevice.usbVersionMajor and USBDevice.usbVersionSubminor.
[Value("usbVersionMinor")]
public byte UsbVersionMinor { get; }

Property Value

byte

The second of three properties that declare the USB protocol version supported by the
device.

Remarks

UsbVersionSubminor

NOTE
Experimental
The usbVersionSubminor read only property of the
USBDevice interface is one of three properties that declare the USB
protocol version supported by the device. The other two properties
are USBDevice.usbVersionMajor and USBDevice.usbVersionMinor.
[Value("usbVersionSubminor")]
public byte UsbVersionSubminor { get; }

Property Value

byte

The first of three properties that declare the USB protocol version supported by the
device.

Remarks

VendorId

NOTE
Experimental
The vendorId read only property of the
USBDevice interface is the official usb.org-assigned vendor ID.
[Value("vendorId")]
public ushort VendorId { get; }

Property Value

ushort

The official usb.org-assigned vendor ID.

Remarks

Methods

ClaimInterface(byte)

NOTE
Experimental
The claimInterface() method of the
USBDevice interface returns a {{jsxref("promise")}} that resolves when
the requested interface is claimed for exclusive access.
[Value("claimInterface")]
public Task<GlobalObject.Undefined> ClaimInterface(byte interfaceNumber)

Parameters

interfaceNumber byte

Returns

Task<GlobalObject.Undefined>

A Promise.

Remarks

ClearHalt(USBDirection, byte)

NOTE
Experimental
The clearHalt() method of the USBDevice
interface returns a Promise that resolves when a halt condition is
cleared. A halt condition is when a data transfer to or from the device has a status
of &apos;stall&apos;, which requires the web page (the host system, in USB
terminology) to clear that condition. See the for details.
[Value("clearHalt")]
public Task<GlobalObject.Undefined> ClearHalt(USBDirection direction, byte endpointNumber)

Parameters

direction USBDirection
endpointNumber byte

Returns

Task<GlobalObject.Undefined>

A Promise.

Remarks

Close()

NOTE
Experimental
The close() method of the USBDevice
interface returns a Promise that resolves when all open interfaces are
released and the device session has ended.
[Value("close")]
public Task<GlobalObject.Undefined> Close()

Returns

Task<GlobalObject.Undefined>

A Promise.

Remarks

ControlTransferIn(USBControlTransferParameters, ushort)

NOTE
Experimental
The controlTransferIn() method of the USBDevice interface returns a {{jsxref("Promise")}} that resolves with a USBInTransferResult when a command or status request has been transmitted to (received by) the USB device.
[Value("controlTransferIn")]
public Task<USBInTransferResult> ControlTransferIn(USBControlTransferParameters setup, ushort length)

Parameters

setup USBControlTransferParameters
length ushort

Returns

Task<USBInTransferResult>

{{jsxref("promise")}} that resolves with a USBInTransferResult.

Remarks

ControlTransferOut(USBControlTransferParameters, Union224)

NOTE
Experimental
The controlTransferOut() method of the USBDevice interface returns a {{jsxref("Promise")}} that resolves with a USBOutTransferResult when a command or status operation has been transmitted from the USB device.
[Value("controlTransferOut")]
public Task<USBOutTransferResult> ControlTransferOut(USBControlTransferParameters setup, Union224 data = default)

Parameters

setup USBControlTransferParameters
data Union224

Returns

Task<USBOutTransferResult>

A {{jsxref("promise")}} that resolves with a USBOutTransferResult.

Remarks

Forget()

NOTE
Experimental
The forget() method of the USBDevice interface returns a {{jsxref("Promise")}} that resolves when all pending operations are aborted, all open interfaces are released, the device session has ended, and the permission is reset.
[Value("forget")]
public Task<GlobalObject.Undefined> Forget()

Returns

Task<GlobalObject.Undefined>

A Promise which resolves with undefined once the device access permission is revoked.

Remarks

IsochronousTransferIn(byte, List<ulong>)

NOTE
Experimental
The isochronousTransferIn() method of the USBDevice interface returns a {{jsxref("Promise")}} that resolves with a USBIsochronousInTransferResult when time sensitive information has been transmitted to (received by) the USB device.
[Value("isochronousTransferIn")]
public Task<USBIsochronousInTransferResult> IsochronousTransferIn(byte endpointNumber, List<ulong> packetLengths)

Parameters

endpointNumber byte
packetLengths List<ulong>

Returns

Task<USBIsochronousInTransferResult>

A {{jsxref("Promise")}} that resolves with a USBIsochronousInTransferResult.

Remarks

IsochronousTransferOut(byte, Union224, List<ulong>)

NOTE
Experimental
The isochronousTransferOut() method of the
USBDevice interface returns a {{jsxref("Promise")}} that resolves with a USBIsochronousOutTransferResult when time sensitive information has been transmitted from the USB device.
[Value("isochronousTransferOut")]
public Task<USBIsochronousOutTransferResult> IsochronousTransferOut(byte endpointNumber, Union224 data, List<ulong> packetLengths)

Parameters

endpointNumber byte
data Union224
packetLengths List<ulong>

Returns

Task<USBIsochronousOutTransferResult>

A {{jsxref("Promise")}} that resolves with a USBIsochronousOutTransferResult.

Remarks

Open()

NOTE
Experimental
The open() method of the USBDevice
interface returns a Promise that resolves when a device session has
started.
[Value("open")]
public Task<GlobalObject.Undefined> Open()

Returns

Task<GlobalObject.Undefined>

A Promise.

Remarks

ReleaseInterface(byte)

NOTE
Experimental
The releaseInterface() method of the
USBDevice interface returns a {{jsxref("promise")}} that resolves when a
claimed interface is released from exclusive access.
[Value("releaseInterface")]
public Task<GlobalObject.Undefined> ReleaseInterface(byte interfaceNumber)

Parameters

interfaceNumber byte

Returns

Task<GlobalObject.Undefined>

A Promise.

Remarks

Reset()

NOTE
Experimental
The reset() method of the USBDevice
interface returns a Promise that resolves when the device is reset and all
app operations canceled and their promises rejected.
[Value("reset")]
public Task<GlobalObject.Undefined> Reset()

Returns

Task<GlobalObject.Undefined>

A Promise.

Remarks

SelectAlternateInterface(byte, byte)

NOTE
Experimental
The selectAlternateInterface() method of the
USBDevice interface returns a {{jsxref("promise")}} that resolves when
the specified alternative endpoint is selected.
[Value("selectAlternateInterface")]
public Task<GlobalObject.Undefined> SelectAlternateInterface(byte interfaceNumber, byte alternateSetting)

Parameters

interfaceNumber byte
alternateSetting byte

Returns

Task<GlobalObject.Undefined>

A Promise.

Remarks

SelectConfiguration(byte)

NOTE
Experimental
The selectConfiguration() method of the
USBDevice interface returns a {{jsxref("promise")}} that resolves when
the specified configuration is selected.
[Value("selectConfiguration")]
public Task<GlobalObject.Undefined> SelectConfiguration(byte configurationValue)

Parameters

configurationValue byte

Returns

Task<GlobalObject.Undefined>

A Promise.

Remarks

TransferIn(byte, ulong)

NOTE
Experimental
The transferIn() method of the USBDevice
interface returns a Promise that resolves with a
USBInTransferResult when bulk or interrupt data is received from the USB
device.
[Value("transferIn")]
public Task<USBInTransferResult> TransferIn(byte endpointNumber, ulong length)

Parameters

endpointNumber byte
length ulong

Returns

Task<USBInTransferResult>

A {{jsxref("promise")}} that resolves with a USBInTransferResult.

Remarks

TransferOut(byte, Union224)

NOTE
Experimental
The transferOut() method of the USBDevice
interface returns a Promise that resolves with a
USBOutTransferResult when bulk or interrupt data is sent to the USB
device.
[Value("transferOut")]
public Task<USBOutTransferResult> TransferOut(byte endpointNumber, Union224 data)

Parameters

endpointNumber byte
data Union224

Returns

Task<USBOutTransferResult>

A {{jsxref("promise")}} that resolves with a USBOutTransferResult.

Remarks