Interface: UsbDevice

api/hardware/EvamHardwareUsbApi.UsbDevice

Usb device accessible from the Evam platform

Implemented by

Properties

classCode

Readonly classCode: number

Device class code


productId

Readonly productId: number

Device product ID


productName

Readonly productName: string

Device product name


protocolCode

Readonly protocolCode: number

Device protocol code


serialNumber

Readonly serialNumber: string

Device serial number


subclassCode

Readonly subclassCode: number

Device sub class code


vendorId

Readonly vendorId: number

Device vendor ID


version

Readonly version: string

Device USB version as “major.minor.sub-minor”

Methods

claimInterface

claimInterface(interfaceNumber, force): Promise<void>

Claims an interface by its number for exclusive communication access

Parameters

Name

Type

Description

interfaceNumber

number

The interface number from [UsbInterface]

force

boolean

Set to true to make an attempt at enforcing the claim

Returns

Promise<void>


close

close(): Promise<void>

Close a device once it is no longer needed

Returns

Promise<void>


controlTransferIn

controlTransferIn(requestType, recipient, request, value, index, length, timeout): Promise<UsbTransferResult>

Perform a control transfer - IN direction (data read)

Parameters

Name

Type

Description

requestType

USBRequestType

The request type: “standard”, “class” or “vendor”

recipient

USBRecipient

The recipient: “device” | “interface” | “endpoint” | “other”

request

number

The request byte

value

number

The value byte

index

number

The index for the request

length

number

The request length

timeout

number

timeout in milliseconds

Returns

Promise<UsbTransferResult>


controlTransferOut

controlTransferOut(requestType, recipient, request, value, index, data, timeout): Promise<UsbTransferResult>

Perform a control transfer - OUT direction (data write)

Parameters

Name

Type

Description

requestType

USBRequestType

The request type: “standard”, “class” or “vendor”

recipient

USBRecipient

The recipient: “device” | “interface” | “endpoint” | “other”

request

number

The request byte

value

number

The value byte

index

number

The index for the request

data

Uint8Array

The data to be written

timeout

number

The timeout in milliseconds

Returns

Promise<UsbTransferResult>


forget

forget(): Promise<void>

Release the authorization for this device, access will have to be requested again.

Returns

Promise<void>


getInterfaces

getInterfaces(): UsbInterface[]

Get the interfaces this device has

Returns

UsbInterface[]


open

open(): Promise<void>

Open the device for communication

Returns

Promise<void>


releaseInterface

releaseInterface(interfaceNumber): Promise<void>

Release an interface once communication is no longer needed

Parameters

Name

Type

Description

interfaceNumber

number

The interface number from [UsbInterface]

Returns

Promise<void>


transferIn

transferIn(endpointNumber, length, timeout): Promise<UsbTransferResult>

Perform a bulk transfer - IN direction (data read)

Parameters

Name

Type

Description

endpointNumber

number

The endpoint number to be targeted

length

number

The transfer length

timeout

number

The timeout in milliseconds

Returns

Promise<UsbTransferResult>


transferOut

transferOut(endpointNumber, data, timeout): Promise<UsbTransferResult>

Perform a bulk transfer - OUT direction (data write)

Parameters

Name

Type

Description

endpointNumber

number

The endpoint number to be targeted

data

Uint8Array

The data bytes to be written

timeout

number

The timeout in milliseconds

Returns

Promise<UsbTransferResult>